Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
gitlab-ci: define PYTHONPATH explicitly to see if it helps
[simgrid.git] / docs / source / _ext / autodoxy / autodoxy / __init__.py
1 import os.path
2 from lxml import etree as ET
3 from sphinx.errors import ExtensionError
4
5
6 def set_doxygen_xml(app):
7     """Load all doxygen XML files from the app config variable
8     `app.config.doxygen_xml` which should be a path to a directory
9     containing doxygen xml output
10     """
11     err = ExtensionError(
12         '[autodoxy] No doxygen xml output found in doxygen_xml="%s"' % app.config.doxygen_xml)
13
14     if not os.path.isdir(app.config.doxygen_xml):
15         raise err
16
17     files = [os.path.join(app.config.doxygen_xml, f)
18              for f in os.listdir(app.config.doxygen_xml)
19              if f.lower().endswith('.xml') and not f.startswith('._')]
20     if len(files) == 0:
21         raise err
22
23     setup.DOXYGEN_ROOT = ET.ElementTree(ET.Element('root')).getroot()
24     for file in files:
25         root = ET.parse(file).getroot()
26         for node in root:
27             setup.DOXYGEN_ROOT.append(node)
28
29
30 def get_doxygen_root():
31     """Get the root element of the doxygen XML document.
32     """
33     if not hasattr(setup, 'DOXYGEN_ROOT'):
34         setup.DOXYGEN_ROOT = ET.Element("root")  # dummy
35     return setup.DOXYGEN_ROOT
36
37
38 def setup(app):
39     import sphinx.ext.autosummary
40     from autodoxy.autodoxy import DoxygenClassDocumenter, DoxygenMethodDocumenter, DoxygenVariableDocumenter
41     from autodoxy.autosummary import DoxygenAutosummary, DoxygenAutoEnum
42     from autodoxy.autosummary.generate import process_generate_options
43
44     app.connect("builder-inited", set_doxygen_xml)
45     app.connect("builder-inited", process_generate_options)
46
47     app.setup_extension('sphinx.ext.autodoc')
48     app.setup_extension('sphinx.ext.autosummary')
49
50     app.add_autodocumenter(DoxygenClassDocumenter)
51     app.add_autodocumenter(DoxygenMethodDocumenter)
52     app.add_autodocumenter(DoxygenVariableDocumenter)
53     app.add_config_value("doxygen_xml", "", True)
54
55     app.add_directive('autodoxysummary', DoxygenAutosummary)
56     app.add_directive('autodoxyenum', DoxygenAutoEnum)
57
58     return {'version': sphinx.__display_version__, 'parallel_read_safe': True}