Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b25fc0f

Browse files
committed
Merge pull request ipython#8714 from minrk/confhacks
Run autogen scripts on readthedocs
2 parents 3356134 + 3792978 commit b25fc0f

File tree

5 files changed

+37
-12
lines changed

5 files changed

+37
-12
lines changed

docs/autogen_api.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
#!/usr/bin/env python
22
"""Script to auto-generate our API docs.
33
"""
4-
# stdlib imports
4+
55
import os
66
import sys
77

8-
# local imports
9-
sys.path.append(os.path.abspath('sphinxext'))
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+
1013
from apigen import ApiDocWriter
1114

15+
source = pjoin(here, 'source')
16+
1217
#*****************************************************************************
1318
if __name__ == '__main__':
14-
pjoin = os.path.join
1519
package = 'IPython'
16-
outdir = pjoin('source','api','generated')
20+
outdir = pjoin(source, 'api', 'generated')
1721
docwriter = ApiDocWriter(package,rst_extension='.rst')
1822
# You have to escape the . here because . is a special char for regexps.
1923
# You must do make clean if you change this!
@@ -67,6 +71,6 @@
6771
# Write index with .txt extension - we can include it, but Sphinx won't try
6872
# to compile it
6973
docwriter.write_index(outdir, 'gen.txt',
70-
relative_to = pjoin('source','api')
74+
relative_to = pjoin(source, 'api')
7175
)
7276
print ('%d files written' % len(docwriter.written_modules))

docs/autogen_config.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
#!/usr/bin/env python
22

3+
from os.path import join, dirname, abspath
4+
35
from IPython.terminal.ipapp import TerminalIPythonApp
46
from ipykernel.kernelapp import IPKernelApp
57

8+
here = abspath(dirname(__file__))
9+
options = join(here, 'source', 'config', 'options')
10+
generated = join(options, 'generated.rst')
11+
612
def write_doc(name, title, app, preamble=None):
713
filename = '%s.rst' % name
8-
with open('source/config/options/%s' % filename, 'w') as f:
14+
with open(join(options, filename), 'w') as f:
915
f.write(title + '\n')
1016
f.write(('=' * len(title)) + '\n')
1117
f.write('\n')
1218
if preamble is not None:
1319
f.write(preamble + '\n\n')
1420
f.write(app.document_config_options())
15-
with open('source/config/options/generated', 'a') as f:
21+
with open(generated, 'a') as f:
1622
f.write(filename + '\n')
1723

1824

1925
if __name__ == '__main__':
2026
# create empty file
21-
with open('source/config/options/generated', 'w'):
27+
with open(generated, 'w'):
2228
pass
2329

2430
write_doc('terminal', 'Terminal IPython options', TerminalIPythonApp())

docs/autogen_magics.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import os
2+
13
from IPython.core.alias import Alias
24
from IPython.core.interactiveshell import InteractiveShell
35
from IPython.core.magic import MagicAlias
@@ -60,5 +62,7 @@ def sortkey(s): return s[0].lower()
6062
format_docstring(func),
6163
""])
6264

63-
with open("source/interactive/magics-generated.txt", "w") as f:
64-
f.write("\n".join(output))
65+
here = os.path.dirname(__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))

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
numpydoc
22
-e .
3+
ipykernel

docs/source/conf.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,17 @@
2424
# see
2525
# http://read-the-docs.readthedocs.org/en/latest/faq.html
2626
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+
2838
# If your extensions are in another directory, add it here. If the directory
2939
# is relative to the documentation root, use os.path.abspath to make it
3040
# absolute, like shown here.

0 commit comments

Comments
 (0)