##// END OF EJS Templates
Merge branch 'doc-config-options' into docs-refresh...
Thomas Kluyver -
r13498:36514bb6 merge
parent child Browse files
Show More
@@ -0,0 +1,74
1 from IPython.utils.text import indent, wrap_paragraphs
2
3 from IPython.terminal.ipapp import TerminalIPythonApp
4 from IPython.kernel.zmq.kernelapp import IPKernelApp
5 from IPython.html.notebookapp import NotebookApp
6 from IPython.qt.console.qtconsoleapp import IPythonQtConsoleApp
7
8 def document_config_options(classes):
9 lines = []
10 for cls in classes:
11 classname = cls.__name__
12 for k, trait in sorted(cls.class_traits(config=True).items()):
13 ttype = trait.__class__.__name__
14
15 termline = classname + '.' + trait.name
16
17 # Choices or type
18 if 'Enum' in ttype:
19 # include Enum choices
20 termline += ' : ' + '|'.join(repr(x) for x in trait.values)
21 else:
22 termline += ' : ' + ttype
23 lines.append(termline)
24
25 # Default value
26 try:
27 dv = trait.get_default_value()
28 dvr = repr(dv)
29 except Exception:
30 dvr = dv = None # ignore defaults we can't construct
31 if (dv is not None) and (dvr is not None):
32 if len(dvr) > 64:
33 dvr = dvr[:61]+'...'
34 # Double up backslashes, so they get to the rendered docs
35 dvr = dvr.replace('\\n', '\\\\n')
36 lines.append(' Default: ' + dvr)
37 lines.append('')
38
39 help = trait.get_metadata('help')
40 if help is not None:
41 help = '\n'.join(wrap_paragraphs(help, 76))
42 lines.append(indent(help, 4))
43 else:
44 lines.append(' No description')
45
46 lines.append('')
47 return '\n'.join(lines)
48
49 kernel_classes = IPKernelApp().classes
50
51 def write_doc(filename, title, classes, preamble=None):
52 configdoc = document_config_options(classes)
53 with open('source/config/options/%s.rst' % filename, 'w') as f:
54 f.write(title + '\n')
55 f.write(('=' * len(title)) + '\n')
56 f.write('\n')
57 if preamble is not None:
58 f.write(preamble + '\n\n')
59 f.write(configdoc)
60
61 if __name__ == '__main__':
62 write_doc('terminal', 'Terminal IPython options', TerminalIPythonApp().classes)
63 write_doc('kernel', 'IPython kernel options', kernel_classes,
64 preamble="These options can be used in :file:`ipython_notebook_config.py` "
65 "or in :file:`ipython_qtconsole_config.py`")
66 nbclasses = set(NotebookApp().classes) - set(kernel_classes)
67 write_doc('notebook', 'IPython notebook options', nbclasses,
68 preamble="Any of the :doc:`kernel` can also be used.")
69 qtclasses = set(IPythonQtConsoleApp().classes) - set(kernel_classes)
70 write_doc('qtconsole', 'IPython Qt console options', qtclasses,
71 preamble="Any of the :doc:`kernel` can also be used.")
72
73 with open('source/config/options/generated', 'w'):
74 pass No newline at end of file
@@ -0,0 +1,10
1 ===============
2 IPython options
3 ===============
4
5 .. toctree::
6
7 terminal
8 kernel
9 notebook
10 qtconsole
@@ -4,6 +4,7 dist
4 _build
4 _build
5 docs/man/*.gz
5 docs/man/*.gz
6 docs/source/api/generated
6 docs/source/api/generated
7 docs/source/config/options
7 docs/gh-pages
8 docs/gh-pages
8 IPython/html/notebook/static/mathjax
9 IPython/html/notebook/static/mathjax
9 *.py[co]
10 *.py[co]
@@ -40,6 +40,7 clean_api:
40
40
41 clean: clean_api
41 clean: clean_api
42 -rm -rf build/* dist/*
42 -rm -rf build/* dist/*
43 -rm -rf $(SRCDIR)/config/options/generated
43
44
44 pdf: latex
45 pdf: latex
45 cd build/latex && make all-pdf
46 cd build/latex && make all-pdf
@@ -56,8 +57,8 dist: html
56 cp -al build/html .
57 cp -al build/html .
57 @echo "Build finished. Final docs are in html/"
58 @echo "Build finished. Final docs are in html/"
58
59
59 html: api
60 html: api autoconfig
60 html_noapi: clean_api
61 html_noapi: clean_api autoconfig
61
62
62 html html_noapi:
63 html html_noapi:
63 mkdir -p build/html build/doctrees
64 mkdir -p build/html build/doctrees
@@ -65,6 +66,12 html html_noapi:
65 @echo
66 @echo
66 @echo "Build finished. The HTML pages are in build/html."
67 @echo "Build finished. The HTML pages are in build/html."
67
68
69 autoconfig: source/config/options/generated
70
71 source/config/options/generated:
72 python autogen_config.py
73 @echo "Created docs for config options"
74
68 api: source/api/generated/gen.txt
75 api: source/api/generated/gen.txt
69
76
70 source/api/generated/gen.txt:
77 source/api/generated/gen.txt:
@@ -98,7 +105,7 qthelp:
98 @echo "To view the help file:"
105 @echo "To view the help file:"
99 @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/IPython.qhc"
106 @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/IPython.qhc"
100
107
101 latex: api
108 latex: api autoconfig
102 mkdir -p build/latex build/doctrees
109 mkdir -p build/latex build/doctrees
103 $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex
110 $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex
104 @echo
111 @echo
@@ -8,6 +8,7 Configuration and customization
8 :maxdepth: 2
8 :maxdepth: 2
9
9
10 intro
10 intro
11 options/index
11 extensions/index
12 extensions/index
12 integrating
13 integrating
13 inputtransforms
14 inputtransforms
General Comments 0
You need to be logged in to leave comments. Login now