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