##// END OF EJS Templates
Make each config option individually linkable
Thomas Kluyver -
Show More
@@ -0,0 +1,17
1 """Directives and roles for documenting traitlets config options.
2
3 ::
4
5 .. configtrait:: Application.log_datefmt
6
7 Description goes here.
8
9 Cross reference like this: :configtrait:`Application.log_datefmt`.
10 """
11 from sphinx.locale import l_
12 from sphinx.util.docfields import Field
13
14 def setup(app):
15 app.add_object_type('configtrait', 'configtrait', objname='Config option')
16 metadata = {'parallel_read_safe': True, 'parallel_write_safe': True}
17 return metadata
@@ -1,144 +1,144
1 1 # Makefile for Sphinx documentation
2 2 #
3 3
4 4 # You can set these variables from the command line.
5 5 SPHINXOPTS =
6 6 SPHINXBUILD = sphinx-build
7 7 PAPER =
8 8 SRCDIR = source
9 9 BUILDDIR = build
10 10 PYTHON = python3
11 11
12 12 # Internal variables.
13 13 PAPEROPT_a4 = -D latex_paper_size=a4
14 14 PAPEROPT_letter = -D latex_paper_size=letter
15 15 ALLSPHINXOPTS = -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(SRCDIR)
16 16
17 17 .PHONY: help clean html web pickle htmlhelp latex changes linkcheck api
18 18
19 19 default: html
20 20
21 21 help:
22 22 @echo "Please use \`make <target>' where <target> is one of"
23 23 @echo " html standalone HTML files"
24 24 @echo " html_noapi same as above, without the time consuming API docs"
25 25 @echo " pickle pickle files (usable by e.g. sphinx-web)"
26 26 @echo " htmlhelp HTML files and a HTML help project"
27 27 @echo " latex LaTeX files, you can set PAPER=a4 or PAPER=letter"
28 28 @echo " texinfo Texinfo files"
29 29 @echo " info Texinfo files and run them through makeinfo"
30 30 @echo " changes an overview over all changed/added/deprecated items"
31 31 @echo " linkcheck check all external links for integrity (takes a long time)"
32 32 @echo
33 33 @echo "Compound utility targets:"
34 34 @echo "pdf latex and then runs the PDF generation"
35 35 @echo "all html and pdf"
36 36 @echo "dist all, and then puts the results in dist/"
37 37
38 38 clean_api:
39 39 -rm -rf $(SRCDIR)/api/generated
40 40
41 41 clean: clean_api
42 42 -rm -rf build/* dist/*
43 43 -rm -f $(SRCDIR)/config/options/config-generated.txt
44 44 -rm -f $(SRCDIR)/config/shortcuts/*.csv
45 45 -rm -f $(SRCDIR)/interactive/magics-generated.txt
46 46
47 47 pdf: latex
48 48 cd build/latex && make all-pdf
49 49
50 50 all: html pdf
51 51
52 52 # For final distribution, only build HTML (our pdf is now so large as to be
53 53 # unusable, takes forever to build and just bloats the downloads). We leave
54 54 # them hardlinked at the top-level so users find them easily, though the
55 55 # original build/html dir is left in-place (useful to reload builds while
56 56 # testing).
57 57 dist: html
58 58 rm -rf html
59 59 cp -al build/html .
60 60 @echo "Build finished. Final docs are in html/"
61 61
62 62 html: api autoconfig automagic autogen_shortcuts
63 63 html_noapi: clean_api autoconfig automagic autogen_shortcuts
64 64
65 65 html html_noapi:
66 66 mkdir -p build/html build/doctrees
67 67 $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html
68 68 @echo
69 69 @echo "Build finished. The HTML pages are in build/html."
70 70
71 71 automagic: source/interactive/magics-generated.txt
72 72
73 73 source/interactive/magics-generated.txt: autogen_magics.py
74 74 $(PYTHON) autogen_magics.py
75 75 @echo "Created docs for line & cell magics"
76 76
77 77 autoconfig: source/config/options/config-generated.txt
78 78
79 source/config/options/config-generated.txt:
79 source/config/options/config-generated.txt: autogen_config.py
80 80 $(PYTHON) autogen_config.py
81 81 @echo "Created docs for config options"
82 82
83 83 api: source/api/generated/gen.txt
84 84
85 85 source/api/generated/gen.txt:
86 86 $(PYTHON) autogen_api.py
87 87 @echo "Build API docs finished."
88 88
89 89 autogen_shortcuts: autogen_shortcuts.py ../IPython/terminal/interactiveshell.py source/config/shortcuts/index.rst
90 90 $(PYTHON) autogen_shortcuts.py
91 91 @echo "Created docs for shortcuts"
92 92
93 93 pickle:
94 94 mkdir -p build/pickle build/doctrees
95 95 $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle
96 96 @echo
97 97 @echo "Build finished; now you can process the pickle files or run"
98 98 @echo " sphinx-web build/pickle"
99 99 @echo "to start the sphinx-web server."
100 100
101 101 web: pickle
102 102
103 103 htmlhelp:
104 104 mkdir -p build/htmlhelp build/doctrees
105 105 $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp
106 106 @echo
107 107 @echo "Build finished; now you can run HTML Help Workshop with the" \
108 108 ".hhp project file in build/htmlhelp."
109 109
110 110 latex: api autoconfig
111 111 mkdir -p build/latex build/doctrees
112 112 $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex
113 113 @echo
114 114 @echo "Build finished; the LaTeX files are in build/latex."
115 115 @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
116 116 "run these through (pdf)latex."
117 117
118 118 changes:
119 119 mkdir -p build/changes build/doctrees
120 120 $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes
121 121 @echo
122 122 @echo "The overview file is in build/changes."
123 123
124 124 linkcheck:
125 125 mkdir -p build/linkcheck build/doctrees
126 126 $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck
127 127 @echo
128 128 @echo "Link check complete; look for any errors in the above output " \
129 129 "or in build/linkcheck/output.rst."
130 130
131 131 texinfo:
132 132 mkdir -p $(BUILDDIR)/texinfo
133 133 $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
134 134 @echo
135 135 @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
136 136 @echo "Run \`make' in that directory to run these through makeinfo" \
137 137 "(use \`make info' here to do that automatically)."
138 138
139 139 info:
140 140 mkdir -p $(BUILDDIR)/texinfo
141 141 $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
142 142 @echo "Running Texinfo files through makeinfo..."
143 143 make -C $(BUILDDIR)/texinfo info
144 144 @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
@@ -1,33 +1,91
1 1 #!/usr/bin/env python
2 2
3 3 from os.path import join, dirname, abspath
4 4
5 5 from IPython.terminal.ipapp import TerminalIPythonApp
6 6 from ipykernel.kernelapp import IPKernelApp
7 from traitlets import Undefined
7 8
8 9 here = abspath(dirname(__file__))
9 10 options = join(here, 'source', 'config', 'options')
10 11 generated = join(options, 'config-generated.txt')
11 12
13 from ipython_genutils.text import indent, dedent
14
15 def interesting_default_value(dv):
16 if (dv is None) or (dv is Undefined):
17 return False
18 if isinstance(dv, (str, list, tuple, dict, set)):
19 return bool(dv)
20 return True
21
22 def class_config_rst_doc(cls):
23 """Generate rST documentation for this class' config options.
24
25 Excludes traits defined on parent classes.
26 """
27 lines = []
28 classname = cls.__name__
29 for k, trait in sorted(cls.class_traits(config=True).items()):
30 ttype = trait.__class__.__name__
31
32 lines += ['.. configtrait:: ' + classname + '.' + trait.name,
33 ''
34 ]
35
36 help = trait.help.rstrip() or 'No description'
37 lines.append(indent(dedent(help), 4) + '\n')
38
39 # Choices or type
40 if 'Enum' in ttype:
41 # include Enum choices
42 lines.append(indent(
43 ':options: ' + ', '.join('``%r``' % x for x in trait.values), 4))
44 else:
45 lines.append(indent(':trait type: ' + ttype, 4))
46
47 # Default value
48 # Ignore boring default values like None, [] or ''
49 if interesting_default_value(trait.default_value):
50 try:
51 dvr = trait.default_value_repr()
52 except Exception:
53 dvr = None # ignore defaults we can't construct
54 if dvr is not None:
55 if len(dvr) > 64:
56 dvr = dvr[:61] + '...'
57 # Double up backslashes, so they get to the rendered docs
58 dvr = dvr.replace('\\n', '\\\\n')
59 lines.append(indent(':default: ``%s``' % dvr, 4))
60
61 # Blank line
62 lines.append('')
63
64 return '\n'.join(lines)
65
12 66
13 67 def write_doc(name, title, app, preamble=None):
14 68 filename = join(options, name+'.rst')
15 69 with open(filename, 'w') as f:
16 70 f.write(title + '\n')
17 71 f.write(('=' * len(title)) + '\n')
18 72 f.write('\n')
19 73 if preamble is not None:
20 74 f.write(preamble + '\n\n')
21 f.write(app.document_config_options())
75 #f.write(app.document_config_options())
76
77 for c in app._classes_inc_parents():
78 f.write(class_config_rst_doc(c))
79 f.write('\n')
22 80
23 81
24 82 if __name__ == '__main__':
25 83 # Touch this file for the make target
26 84 with open(generated, 'w'):
27 85 pass
28 86
29 87 write_doc('terminal', 'Terminal IPython options', TerminalIPythonApp())
30 88 write_doc('kernel', 'IPython kernel options', IPKernelApp(),
31 89 preamble=("These options can be used in :file:`ipython_kernel_config.py`. "
32 90 "The kernel also respects any options in `ipython_config.py`"),
33 91 )
@@ -1,296 +1,297
1 1 # -*- coding: utf-8 -*-
2 2 #
3 3 # IPython documentation build configuration file.
4 4
5 5 # NOTE: This file has been edited manually from the auto-generated one from
6 6 # sphinx. Do NOT delete and re-generate. If any changes from sphinx are
7 7 # needed, generate a scratch one and merge by hand any new fields needed.
8 8
9 9 #
10 10 # This file is execfile()d with the current directory set to its containing dir.
11 11 #
12 12 # The contents of this file are pickled, so don't put values in the namespace
13 13 # that aren't pickleable (module imports are okay, they're removed automatically).
14 14 #
15 15 # All configuration values have a default value; values that are commented out
16 16 # serve to show the default value.
17 17
18 18 import sys, os
19 19
20 20 # http://read-the-docs.readthedocs.io/en/latest/faq.html
21 21 ON_RTD = os.environ.get('READTHEDOCS', None) == 'True'
22 22
23 23 if ON_RTD:
24 24 tags.add('rtd')
25 25
26 26 # RTD doesn't use the Makefile, so re-run autogen_{things}.py here.
27 27 for name in ('config', 'api', 'magics', 'shortcuts'):
28 28 fname = 'autogen_{}.py'.format(name)
29 29 fpath = os.path.abspath(os.path.join('..', fname))
30 30 with open(fpath) as f:
31 31 exec(compile(f.read(), fname, 'exec'), {
32 32 '__file__': fpath,
33 33 '__name__': '__main__',
34 34 })
35 35 else:
36 36 import sphinx_rtd_theme
37 37 html_theme = "sphinx_rtd_theme"
38 38 html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
39 39
40 40 # If your extensions are in another directory, add it here. If the directory
41 41 # is relative to the documentation root, use os.path.abspath to make it
42 42 # absolute, like shown here.
43 43 sys.path.insert(0, os.path.abspath('../sphinxext'))
44 44
45 45 # We load the ipython release info into a dict by explicit execution
46 46 iprelease = {}
47 47 exec(compile(open('../../IPython/core/release.py').read(), '../../IPython/core/release.py', 'exec'),iprelease)
48 48
49 49 # General configuration
50 50 # ---------------------
51 51
52 52 # Add any Sphinx extension module names here, as strings. They can be extensions
53 53 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
54 54 extensions = [
55 55 'sphinx.ext.autodoc',
56 56 'sphinx.ext.autosummary',
57 57 'sphinx.ext.doctest',
58 58 'sphinx.ext.inheritance_diagram',
59 59 'sphinx.ext.intersphinx',
60 60 'IPython.sphinxext.ipython_console_highlighting',
61 61 'IPython.sphinxext.ipython_directive',
62 62 'sphinx.ext.napoleon', # to preprocess docstrings
63 63 'github', # for easy GitHub links
64 64 'magics',
65 'configtraits',
65 66 ]
66 67
67 68 if ON_RTD:
68 69 # Remove extensions not currently supported on RTD
69 70 extensions.remove('IPython.sphinxext.ipython_directive')
70 71 extensions.remove('IPython.sphinxext.ipython_console_highlighting')
71 72
72 73 # Add any paths that contain templates here, relative to this directory.
73 74 templates_path = ['_templates']
74 75
75 76 # The suffix of source filenames.
76 77 source_suffix = '.rst'
77 78
78 79 rst_prolog = ''
79 80
80 81 def is_stable(extra):
81 82 for ext in {'dev', 'b', 'rc'}:
82 83 if ext in extra:
83 84 return False
84 85 return True
85 86
86 87 if is_stable(iprelease['_version_extra']):
87 88 tags.add('ipystable')
88 89 else:
89 90 tags.add('ipydev')
90 91 rst_prolog += """
91 92 .. warning::
92 93
93 94 This documentation covers a development version of IPython. The development
94 95 version may differ significantly from the latest stable release.
95 96 """
96 97
97 98 rst_prolog += """
98 99 .. important::
99 100
100 101 This documentation covers IPython versions 6.0 and higher. Beginning with
101 102 version 6.0, IPython stopped supporting compatibility with Python versions
102 103 lower than 3.3 including all versions of Python 2.7.
103 104
104 105 If you are looking for an IPython version compatible with Python 2.7,
105 106 please use the IPython 5.x LTS release and refer to its documentation (LTS
106 107 is the long term support release).
107 108
108 109 """
109 110
110 111 # The master toctree document.
111 112 master_doc = 'index'
112 113
113 114 # General substitutions.
114 115 project = 'IPython'
115 116 copyright = 'The IPython Development Team'
116 117
117 118 # ghissue config
118 119 github_project_url = "https://github.com/ipython/ipython"
119 120
120 121 # numpydoc config
121 122 numpydoc_show_class_members = False # Otherwise Sphinx emits thousands of warnings
122 123 numpydoc_class_members_toctree = False
123 124
124 125 # The default replacements for |version| and |release|, also used in various
125 126 # other places throughout the built documents.
126 127 #
127 128 # The full version, including alpha/beta/rc tags.
128 129 release = "%s" % iprelease['version']
129 130 # Just the X.Y.Z part, no '-dev'
130 131 version = iprelease['version'].split('-', 1)[0]
131 132
132 133
133 134 # There are two options for replacing |today|: either, you set today to some
134 135 # non-false value, then it is used:
135 136 #today = ''
136 137 # Else, today_fmt is used as the format for a strftime call.
137 138 today_fmt = '%B %d, %Y'
138 139
139 140 # List of documents that shouldn't be included in the build.
140 141 #unused_docs = []
141 142
142 143 # Exclude these glob-style patterns when looking for source files. They are
143 144 # relative to the source/ directory.
144 145 exclude_patterns = ['whatsnew/pr']
145 146
146 147
147 148 # If true, '()' will be appended to :func: etc. cross-reference text.
148 149 #add_function_parentheses = True
149 150
150 151 # If true, the current module name will be prepended to all description
151 152 # unit titles (such as .. function::).
152 153 #add_module_names = True
153 154
154 155 # If true, sectionauthor and moduleauthor directives will be shown in the
155 156 # output. They are ignored by default.
156 157 #show_authors = False
157 158
158 159 # The name of the Pygments (syntax highlighting) style to use.
159 160 pygments_style = 'sphinx'
160 161
161 162 # Set the default role so we can use `foo` instead of ``foo``
162 163 default_role = 'literal'
163 164
164 165 # Options for HTML output
165 166 # -----------------------
166 167
167 168 # The style sheet to use for HTML and HTML Help pages. A file of that name
168 169 # must exist either in Sphinx' static/ path, or in one of the custom paths
169 170 # given in html_static_path.
170 171 # html_style = 'default.css'
171 172
172 173
173 174 # The name for this set of Sphinx documents. If None, it defaults to
174 175 # "<project> v<release> documentation".
175 176 #html_title = None
176 177
177 178 # The name of an image file (within the static path) to place at the top of
178 179 # the sidebar.
179 180 #html_logo = None
180 181
181 182 # Add any paths that contain custom static files (such as style sheets) here,
182 183 # relative to this directory. They are copied after the builtin static files,
183 184 # so a file named "default.css" will overwrite the builtin "default.css".
184 185 html_static_path = ['_static']
185 186
186 187 # Favicon needs the directory name
187 188 html_favicon = '_static/favicon.ico'
188 189 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
189 190 # using the given strftime format.
190 191 html_last_updated_fmt = '%b %d, %Y'
191 192
192 193 # If true, SmartyPants will be used to convert quotes and dashes to
193 194 # typographically correct entities.
194 195 #html_use_smartypants = True
195 196
196 197 # Custom sidebar templates, maps document names to template names.
197 198 #html_sidebars = {}
198 199
199 200 # Additional templates that should be rendered to pages, maps page names to
200 201 # template names.
201 202 html_additional_pages = {
202 203 'interactive/htmlnotebook': 'notebook_redirect.html',
203 204 'interactive/notebook': 'notebook_redirect.html',
204 205 'interactive/nbconvert': 'notebook_redirect.html',
205 206 'interactive/public_server': 'notebook_redirect.html',
206 207 }
207 208
208 209 # If false, no module index is generated.
209 210 #html_use_modindex = True
210 211
211 212 # If true, the reST sources are included in the HTML build as _sources/<name>.
212 213 #html_copy_source = True
213 214
214 215 # If true, an OpenSearch description file will be output, and all pages will
215 216 # contain a <link> tag referring to it. The value of this option must be the
216 217 # base URL from which the finished HTML is served.
217 218 #html_use_opensearch = ''
218 219
219 220 # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
220 221 #html_file_suffix = ''
221 222
222 223 # Output file base name for HTML help builder.
223 224 htmlhelp_basename = 'ipythondoc'
224 225
225 226 intersphinx_mapping = {'python': ('https://docs.python.org/3/', None),
226 227 'rpy2': ('https://rpy2.readthedocs.io/en/version_2.8.x/', None),
227 228 'traitlets': ('https://traitlets.readthedocs.io/en/latest/', None),
228 229 'jupyterclient': ('https://jupyter-client.readthedocs.io/en/latest/', None),
229 230 'ipyparallel': ('https://ipyparallel.readthedocs.io/en/latest/', None),
230 231 'jupyter': ('https://jupyter.readthedocs.io/en/latest/', None),
231 232 'jedi': ('https://jedi.readthedocs.io/en/latest/', None),
232 233 'traitlets': ('https://traitlets.readthedocs.io/en/latest/', None),
233 234 'ipykernel': ('https://ipykernel.readthedocs.io/en/latest/', None),
234 235 'prompt_toolkit' : ('https://python-prompt-toolkit.readthedocs.io/en/stable/', None),
235 236 'ipywidgets': ('https://ipywidgets.readthedocs.io/en/stable/', None),
236 237 'ipyparallel': ('https://ipyparallel.readthedocs.io/en/stable/', None)
237 238 }
238 239
239 240 # Options for LaTeX output
240 241 # ------------------------
241 242
242 243 # The paper size ('letter' or 'a4').
243 244 latex_paper_size = 'letter'
244 245
245 246 # The font size ('10pt', '11pt' or '12pt').
246 247 latex_font_size = '11pt'
247 248
248 249 # Grouping the document tree into LaTeX files. List of tuples
249 250 # (source start file, target name, title, author, document class [howto/manual]).
250 251
251 252 latex_documents = [
252 253 ('index', 'ipython.tex', 'IPython Documentation',
253 254 u"""The IPython Development Team""", 'manual', True),
254 255 ('parallel/winhpc_index', 'winhpc_whitepaper.tex',
255 256 'Using IPython on Windows HPC Server 2008',
256 257 u"Brian E. Granger", 'manual', True)
257 258 ]
258 259
259 260 # The name of an image file (relative to this directory) to place at the top of
260 261 # the title page.
261 262 #latex_logo = None
262 263
263 264 # For "manual" documents, if this is true, then toplevel headings are parts,
264 265 # not chapters.
265 266 #latex_use_parts = False
266 267
267 268 # Additional stuff for the LaTeX preamble.
268 269 #latex_preamble = ''
269 270
270 271 # Documents to append as an appendix to all manuals.
271 272 #latex_appendices = []
272 273
273 274 # If false, no module index is generated.
274 275 latex_use_modindex = True
275 276
276 277
277 278 # Options for texinfo output
278 279 # --------------------------
279 280
280 281 texinfo_documents = [
281 282 (master_doc, 'ipython', 'IPython Documentation',
282 283 'The IPython Development Team',
283 284 'IPython',
284 285 'IPython Documentation',
285 286 'Programming',
286 287 1),
287 288 ]
288 289
289 290 modindex_common_prefix = ['IPython.']
290 291
291 292
292 293 # Cleanup
293 294 # -------
294 295 # delete release info to avoid pickling errors from sphinx
295 296
296 297 del iprelease
General Comments 0
You need to be logged in to leave comments. Login now