autogen_api.py
83 lines
| 2.9 KiB
| text/x-python
|
PythonLexer
/ docs / autogen_api.py
Fernando Perez
|
r1850 | #!/usr/bin/env python | ||
"""Script to auto-generate our API docs. | ||||
""" | ||||
Min RK
|
r21590 | |||
Fernando Perez
|
r1850 | import os | ||
import sys | ||||
Min RK
|
r21590 | pjoin = os.path.join | ||
here = os.path.abspath(os.path.dirname(__file__)) | ||||
sys.path.append(pjoin(os.path.abspath(here), 'sphinxext')) | ||||
Fernando Perez
|
r1850 | from apigen import ApiDocWriter | ||
Min RK
|
r21590 | source = pjoin(here, 'source') | ||
Fernando Perez
|
r1850 | #***************************************************************************** | ||
if __name__ == '__main__': | ||||
package = 'IPython' | ||||
Min RK
|
r21590 | outdir = pjoin(source, 'api', 'generated') | ||
Paul Ivanov
|
r11730 | docwriter = ApiDocWriter(package,rst_extension='.rst') | ||
Brian Granger
|
r2275 | # You have to escape the . here because . is a special char for regexps. | ||
# You must do make clean if you change this! | ||||
Thomas Kluyver
|
r13586 | docwriter.package_skip_patterns += [r'\.external$', | ||
# Extensions are documented elsewhere. | ||||
Brian Granger
|
r2064 | r'\.extensions', | ||
Thomas Kluyver
|
r18299 | # Magics are documented separately | ||
r'\.core\.magics', | ||||
Thomas Kluyver
|
r21577 | # This isn't API | ||
r'\.sphinxext', | ||||
# Shims | ||||
r'\.kernel', | ||||
klonuo
|
r22482 | r'\.terminal\.pt_inputhooks', | ||
Fernando Perez
|
r1850 | ] | ||
Fernando Perez
|
r2404 | |||
Thomas Kluyver
|
r13586 | # The inputhook* modules often cause problems on import, such as trying to | ||
# load incompatible Qt bindings. It's easiest to leave them all out. The | ||||
Nikita Kniazev
|
r27139 | docwriter.module_skip_patterns += [ | ||
r"\.lib\.inputhook.+", | ||||
r"\.ipdoctest", | ||||
r"\.testing\.plugin", | ||||
# Backwards compat import for lib.lexers | ||||
r"\.nbconvert\.utils\.lexers", | ||||
# We document this manually. | ||||
r"\.utils\.py3compat", | ||||
# These are exposed in display | ||||
r"\.core\.display", | ||||
r"\.lib\.display", | ||||
# Shims | ||||
r"\.config", | ||||
r"\.consoleapp", | ||||
r"\.frontend$", | ||||
r"\.html", | ||||
r"\.nbconvert", | ||||
r"\.nbformat", | ||||
r"\.parallel", | ||||
r"\.qt", | ||||
# this is deprecated. | ||||
r"\.utils\.version", | ||||
# Private APIs (there should be a lot more here) | ||||
r"\.terminal\.ptutils", | ||||
] | ||||
Thomas Kluyver
|
r21577 | # main API is in the inputhook module, which is documented. | ||
Thomas Kluyver
|
r17120 | |||
# These modules import functions and classes from other places to expose | ||||
# them as part of the public API. They must have __all__ defined. The | ||||
# non-API modules they import from should be excluded by the skip patterns | ||||
# above. | ||||
Philippe Blain
|
r28188 | docwriter.names_from__all__.update( | ||
{ | ||||
"IPython", | ||||
"IPython.display", | ||||
} | ||||
) | ||||
Fernando Perez
|
r2568 | # Now, generate the outputs | ||
Fernando Perez
|
r1850 | docwriter.write_api_docs(outdir) | ||
Paul Ivanov
|
r11758 | # Write index with .txt extension - we can include it, but Sphinx won't try | ||
Thomas Kluyver
|
r9244 | # to compile it | ||
Paul Ivanov
|
r11758 | docwriter.write_index(outdir, 'gen.txt', | ||
Min RK
|
r21590 | relative_to = pjoin(source, 'api') | ||
Fernando Perez
|
r1850 | ) | ||
MinRK
|
r11213 | print ('%d files written' % len(docwriter.written_modules)) | ||