Show More
@@ -1,19 +1,23 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 | # stdlib imports |
|
4 | ||
5 | import os |
|
5 | import os | |
6 | import sys |
|
6 | import sys | |
7 |
|
7 | |||
8 | # local imports |
|
8 | pjoin = os.path.join | |
9 | sys.path.append(os.path.abspath('sphinxext')) |
|
9 | ||
|
10 | here = os.path.abspath(os.path.dirname(__file__)) | |||
|
11 | sys.path.append(pjoin(os.path.abspath(here), 'sphinxext')) | |||
|
12 | ||||
10 | from apigen import ApiDocWriter |
|
13 | from apigen import ApiDocWriter | |
11 |
|
14 | |||
|
15 | source = pjoin(here, 'source') | |||
|
16 | ||||
12 | #***************************************************************************** |
|
17 | #***************************************************************************** | |
13 | if __name__ == '__main__': |
|
18 | if __name__ == '__main__': | |
14 | pjoin = os.path.join |
|
|||
15 | package = 'IPython' |
|
19 | package = 'IPython' | |
16 |
outdir = pjoin( |
|
20 | outdir = pjoin(source, 'api', 'generated') | |
17 | docwriter = ApiDocWriter(package,rst_extension='.rst') |
|
21 | docwriter = ApiDocWriter(package,rst_extension='.rst') | |
18 | # 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. | |
19 | # You must do make clean if you change this! |
|
23 | # You must do make clean if you change this! | |
@@ -67,6 +71,6 b" if __name__ == '__main__':" | |||||
67 | # Write index with .txt extension - we can include it, but Sphinx won't try |
|
71 | # Write index with .txt extension - we can include it, but Sphinx won't try | |
68 | # to compile it |
|
72 | # to compile it | |
69 | docwriter.write_index(outdir, 'gen.txt', |
|
73 | docwriter.write_index(outdir, 'gen.txt', | |
70 |
relative_to = pjoin( |
|
74 | relative_to = pjoin(source, 'api') | |
71 | ) |
|
75 | ) | |
72 | print ('%d files written' % len(docwriter.written_modules)) |
|
76 | print ('%d files written' % len(docwriter.written_modules)) |
@@ -1,24 +1,30 b'' | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
2 |
|
2 | |||
|
3 | from os.path import join, dirname, abspath | |||
|
4 | ||||
3 | from IPython.terminal.ipapp import TerminalIPythonApp |
|
5 | from IPython.terminal.ipapp import TerminalIPythonApp | |
4 | from ipykernel.kernelapp import IPKernelApp |
|
6 | from ipykernel.kernelapp import IPKernelApp | |
5 |
|
7 | |||
|
8 | here = abspath(dirname(__file__)) | |||
|
9 | options = join(here, 'source', 'config', 'options') | |||
|
10 | generated = join(options, 'generated.rst') | |||
|
11 | ||||
6 | def write_doc(name, title, app, preamble=None): |
|
12 | def write_doc(name, title, app, preamble=None): | |
7 | filename = '%s.rst' % name |
|
13 | filename = '%s.rst' % name | |
8 |
with open( |
|
14 | with open(join(options, filename), 'w') as f: | |
9 | f.write(title + '\n') |
|
15 | f.write(title + '\n') | |
10 | f.write(('=' * len(title)) + '\n') |
|
16 | f.write(('=' * len(title)) + '\n') | |
11 | f.write('\n') |
|
17 | f.write('\n') | |
12 | if preamble is not None: |
|
18 | if preamble is not None: | |
13 | f.write(preamble + '\n\n') |
|
19 | f.write(preamble + '\n\n') | |
14 | f.write(app.document_config_options()) |
|
20 | f.write(app.document_config_options()) | |
15 |
with open( |
|
21 | with open(generated, 'a') as f: | |
16 | f.write(filename + '\n') |
|
22 | f.write(filename + '\n') | |
17 |
|
23 | |||
18 |
|
24 | |||
19 | if __name__ == '__main__': |
|
25 | if __name__ == '__main__': | |
20 | # create empty file |
|
26 | # create empty file | |
21 |
with open( |
|
27 | with open(generated, 'w'): | |
22 | pass |
|
28 | pass | |
23 |
|
29 | |||
24 | write_doc('terminal', 'Terminal IPython options', TerminalIPythonApp()) |
|
30 | write_doc('terminal', 'Terminal IPython options', TerminalIPythonApp()) |
@@ -1,3 +1,5 b'' | |||||
|
1 | import os | |||
|
2 | ||||
1 | from IPython.core.alias import Alias |
|
3 | from IPython.core.alias import Alias | |
2 | from IPython.core.interactiveshell import InteractiveShell |
|
4 | from IPython.core.interactiveshell import InteractiveShell | |
3 | from IPython.core.magic import MagicAlias |
|
5 | from IPython.core.magic import MagicAlias | |
@@ -60,5 +62,7 b" for name, func in sorted(magics['cell'].items(), key=sortkey):" | |||||
60 | format_docstring(func), |
|
62 | format_docstring(func), | |
61 | ""]) |
|
63 | ""]) | |
62 |
|
64 | |||
63 | with open("source/interactive/magics-generated.txt", "w") as f: |
|
65 | here = os.path.dirname(__file__) | |
64 | f.write("\n".join(output)) No newline at end of file |
|
66 | dest = os.path.join(here, 'source', 'interactive', 'magics-generated.txt') | |
|
67 | with open(dest, "w") as f: | |||
|
68 | f.write("\n".join(output)) |
@@ -24,7 +24,17 b' if ON_RTD:' | |||||
24 | # see |
|
24 | # see | |
25 | # http://read-the-docs.readthedocs.org/en/latest/faq.html |
|
25 | # http://read-the-docs.readthedocs.org/en/latest/faq.html | |
26 | tags.add('rtd') |
|
26 | tags.add('rtd') | |
27 |
|
27 | |||
|
28 | # RTD doesn't use the Makefile, so re-run autogen_{things}.py here. | |||
|
29 | for name in ('config', 'api', 'magics'): | |||
|
30 | fname = 'autogen_{}.py'.format(name) | |||
|
31 | fpath = os.path.abspath(os.path.join('..', fname)) | |||
|
32 | with open(fpath) as f: | |||
|
33 | exec(compile(f.read(), fname, 'exec'), { | |||
|
34 | '__file__': fpath, | |||
|
35 | '__name__': '__main__', | |||
|
36 | }) | |||
|
37 | ||||
28 | # If your extensions are in another directory, add it here. If the directory |
|
38 | # If your extensions are in another directory, add it here. If the directory | |
29 | # is relative to the documentation root, use os.path.abspath to make it |
|
39 | # is relative to the documentation root, use os.path.abspath to make it | |
30 | # absolute, like shown here. |
|
40 | # absolute, like shown here. |
General Comments 0
You need to be logged in to leave comments.
Login now