| 1 |
#!/usr/bin/env python |
| 2 |
"""Script to auto-generate our API docs. |
| 3 |
""" |
| 4 |
|
| 5 |
import os |
| 6 |
import sys |
| 7 |
|
| 8 |
pjoin = os.path.join |
| 9 |
|
| 10 |
here = os.path.abspath(os.path.dirname(__file__)) |
| 11 |
sys.path.append(pjoin(os.path.abspath(here), 'sphinxext')) |
| 12 |
|
| 13 |
from apigen import ApiDocWriter |
| 14 |
|
| 15 |
source = pjoin(here, 'source') |
| 16 |
|
| 17 |
#***************************************************************************** |
| 18 |
if __name__ == '__main__': |
| 19 |
package = 'IPython' |
| 20 |
outdir = pjoin(source, 'api', 'generated') |
| 21 |
docwriter = ApiDocWriter(package,rst_extension='.rst') |
| 22 |
# You have to escape the . here because . is a special char for regexps. |
| 23 |
# You must do make clean if you change this! |
| 24 |
docwriter.package_skip_patterns += [r'\.external$', |
| 25 |
# Extensions are documented elsewhere. |
| 26 |
r'\.extensions', |
| 27 |
# This isn't API |
| 28 |
r'\.sphinxext', |
| 29 |
# Shims |
| 30 |
r'\.kernel', |
| 31 |
r'\.terminal\.pt_inputhooks', |
| 32 |
] |
| 33 |
|
| 34 |
# The inputhook* modules often cause problems on import, such as trying to |
| 35 |
# load incompatible Qt bindings. It's easiest to leave them all out. The |
| 36 |
docwriter.module_skip_patterns += [ |
| 37 |
r"\.lib\.inputhook.+", |
| 38 |
r"\.ipdoctest", |
| 39 |
r"\.testing\.plugin", |
| 40 |
# We document this manually. |
| 41 |
r"\.utils\.py3compat", |
| 42 |
# These are exposed in display |
| 43 |
r"\.core\.display", |
| 44 |
r"\.lib\.display", |
| 45 |
r"\.utils\.version", |
| 46 |
# Private APIs (there should be a lot more here) |
| 47 |
r"\.terminal\.ptutils", |
| 48 |
] |
| 49 |
# main API is in the inputhook module, which is documented. |
| 50 |
|
| 51 |
# These modules import functions and classes from other places to expose |
| 52 |
# them as part of the public API. They must have __all__ defined. The |
| 53 |
# non-API modules they import from should be excluded by the skip patterns |
| 54 |
# above. |
| 55 |
docwriter.names_from__all__.update( |
| 56 |
{ |
| 57 |
"IPython", |
| 58 |
"IPython.display", |
| 59 |
} |
| 60 |
) |
| 61 |
|
| 62 |
# Now, generate the outputs |
| 63 |
docwriter.write_api_docs(outdir) |
| 64 |
# Write index with .txt extension - we can include it, but Sphinx won't try |
| 65 |
# to compile it |
| 66 |
docwriter.write_index(outdir, 'gen.txt', |
| 67 |
relative_to = pjoin(source, 'api') |
| 68 |
) |
| 69 |
print ('%d files written' % len(docwriter.written_modules)) |