Skip to content

Commit 03bd887

Browse files
authored
📚 DOCS: Add outline of extension logic (#1012)
This commit adds a section in the contributing documentation, to outline the logic of the extension, in relation to what events it adds to the sphinx build. Hopefully, this can help contributers to understand how the extension works, and how/where to suggest fixes/improvements in the code base
1 parent 1fc6bde commit 03bd887

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

‎docs/contributing.rst

+60
Original file line numberDiff line numberDiff line change
@@ -182,5 +182,65 @@ The release jobs will build the source and wheel distribution and try to upload
182182
to ``test.pypi.org`` and ``pypy.org``.
183183

184184

185+
Structure of the extension's logic
186+
----------------------------------
187+
188+
The following is an outline of the build events which this extension adds to the :ref:`Sphinx build process <events>`:
189+
190+
#. After configuration has been initialised (``config-inited`` event):
191+
192+
- Register additional directives, directive options and warnings (``load_config``)
193+
- Check configuration consistency (``check_configuration``)
194+
195+
#. Before reading changed documents (``env-before-read-docs`` event):
196+
197+
- Initialise ``BuildEnvironment`` variables (``prepare_env``)
198+
- Register services (``prepare_env``)
199+
- Register functions (``prepare_env``)
200+
- Initialise default extra options (``prepare_env``)
201+
- Initialise extra link types (``prepare_env``)
202+
- Ensure default configurations are set (``prepare_env``)
203+
- Start process timing, if enabled (``prepare_env``)
204+
- Load external needs (``load_external_needs``)
205+
206+
#. For all removed and changed documents (``env-before-read-docs`` event):
207+
208+
- Remove all cached need items that originate from the document (``purge_needs``)
209+
210+
#. For changed documents (``doctree-read`` event, priority 880 of transforms)
211+
212+
- Determine and add data on containing sections and parents to needs (``add_sections``)
213+
214+
#. When building in parallel mode (``env-merge-info`` event), merge ``BuildEnvironment`` data (``merge_data``)
215+
216+
#. After all documents have been read and transformed (``env-updated`` event) (NOTE these are skipped for ``needs`` builder)
217+
218+
- Copy vendored JS libraries (with CSS) to build folder (``install_lib_static_files``)
219+
- Generate permalink file (``install_permalink_file``)
220+
- Copy vendored CSS files to build folder (``install_styles_static_files``)
221+
222+
#. Note, the ``BuildEnvironment`` is cached at this point, only if any documents were updated.
223+
224+
#. For all changed documents, or their dependants (``doctree-resolved``)
225+
226+
- Replace all ```Needextract``` nodes with a list of the collected ``Need`` (``process_creator``)
227+
- Remove all ``Need`` nodes, if ``needs_include_needs`` is ``True`` (``process_need_nodes``)
228+
- Call dynamic functions, set as values on the need data items and replace them with their return values (``process_need_nodes -> resolve_dynamic_values``)
229+
- Replace needs data variant values (``process_need_nodes -> resolve_variants_options``)
230+
- Check for dead links (``process_need_nodes -> check_links``)
231+
- Generate back links (``process_need_nodes -> create_back_links``)
232+
- Process constraints, for each ``Need`` node (``process_need_nodes -> process_constraints``)
233+
- Perform all modifications on need data items, due to ``Needextend`` nodes (``process_need_nodes -> process_needextend``)
234+
- Format each ``Need`` node to give the desired visual output (``process_need_nodes -> print_need_nodes``)
235+
- Process all need specific nodes, replacing them with the desired visual output (``process_creator``)
236+
- Remove ``Need`` nodes marked as ``hidden`` (``remove_hidden_needs``)
237+
238+
#. At the end of the build (``build-finished`` event)
239+
240+
- Call all user defined need data checks, a.k.a warnings (``process_warnings``)
241+
- Write the ``needs.json`` to the output folder (``build_needs_json``)
242+
- Write all required UML files to the output file (``build_needumls_pumls``)
243+
- Print process timing, if enabled (``process_timing``)
244+
185245
.. Include our contributors and maintainers.
186246
.. include:: ../AUTHORS

0 commit comments

Comments
 (0)