Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
doc: let's import existing stuff
[simgrid.git] / docs / source / _ext / 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 def get_doxygen_root():
30     """Get the root element of the doxygen XML document.
31     """
32     if not hasattr(setup, 'DOXYGEN_ROOT'):
33         setup.DOXYGEN_ROOT = ET.Element("root")  # dummy
34     return setup.DOXYGEN_ROOT
35
36 def setup(app):
37     import sphinx.ext.autosummary
38     from autodoxy import DoxygenClassDocumenter, DoxygenMethodDocumenter, DoxygenTypeDocumenter
39     from autodoxy.autosummary import DoxygenAutosummary, DoxygenAutoEnum
40     from autodoxy.autosummary.generate import process_generate_options
41
42     app.connect("builder-inited", set_doxygen_xml)
43     app.connect("builder-inited", process_generate_options)
44
45     app.setup_extension('sphinx.ext.autodoc')
46     app.setup_extension('sphinx.ext.autosummary')
47
48     app.add_autodocumenter(DoxygenClassDocumenter)
49     app.add_autodocumenter(DoxygenMethodDocumenter)
50     app.add_autodocumenter(DoxygenTypeDocumenter)
51     app.add_config_value("doxygen_xml", "", 'env')
52     app.add_config_value('autosummary_toctree', '', 'html')
53
54     app.add_directive('autodoxysummary', DoxygenAutosummary)
55     app.add_directive('autodoxyenum', DoxygenAutoEnum)
56
57     return {'version': sphinx.__display_version__, 'parallel_read_safe': True}