1SPHINX-ALL(1) Sphinx SPHINX-ALL(1)
2
3
4
6 sphinx-all - Sphinx documentation generator system manual
7
9 This is the documentation for the Sphinx documentation builder. Sphinx
10 is a tool that translates a set of reStructuredText source files into
11 various output formats, automatically producing cross-references,
12 indices etc. That is, if you have a directory containing a bunch of
13 reST-formatted documents (and possibly subdirectories of docs in there
14 as well), Sphinx can generate a nicely-organized arrangement of HTML
15 files (in some other directory) for easy browsing and navigation. But
16 from the same source, it can also generate a LaTeX file that you can
17 compile into a PDF version of the documents, or a PDF file directly
18 using rst2pdf.
19
20 The focus is on hand-written documentation, rather than auto-generated
21 API docs. Though there is support for that kind of docs as well (which
22 is intended to be freely mixed with hand-written content), if you need
23 pure API docs have a look at Epydoc, which also understands reST.
24
25 Conversion from other systems
26 This section is intended to collect helpful hints for those wanting to
27 migrate to reStructuredText/Sphinx from other documentation systems.
28
29 · Gerard Flanagan has written a script to convert pure HTML to reST; it
30 can be found at the Python Package Index.
31
32 · For converting the old Python docs to Sphinx, a converter was written
33 which can be found at the Python SVN repository. It contains generic
34 code to convert Python-doc-style LaTeX markup to Sphinx reST.
35
36 · Marcin Wojdyr has written a script to convert Docbook to reST with
37 Sphinx markup; it is at Google Code.
38
39 · Christophe de Vienne wrote a tool to convert from Open/LibreOffice
40 documents to Sphinx: odt2sphinx.
41
42 · To convert different markups, Pandoc is a very helpful tool.
43
44 Use with other systems
45 See the pertinent section in the FAQ list.
46
47 Prerequisites
48 Sphinx needs at least Python 2.4 or Python 3.1 to run, as well as the
49 docutils and Jinja2 libraries. Sphinx should work with docutils ver‐
50 sion 0.7 or some (not broken) SVN trunk snapshot. If you like to have
51 source code highlighting support, you must also install the Pygments
52 library.
53
54 If you use Python 2.4 you also need uuid.
55
56 Usage
57 See tutorial for an introduction. It also contains links to more
58 advanced sections in this manual for the topics it discusses.
59
61 This document is meant to give a tutorial-like overview of all common
62 tasks while using Sphinx.
63
64 The green arrows designate "more info" links leading to advanced sec‐
65 tions about the described task.
66
67 Setting up the documentation sources
68 The root directory of a documentation collection is called the source
69 directory. This directory also contains the Sphinx configuration file
70 conf.py, where you can configure all aspects of how Sphinx reads your
71 sources and builds your documentation. [1]
72
73 Sphinx comes with a script called sphinx-quickstart that sets up a
74 source directory and creates a default conf.py with the most useful
75 configuration values from a few questions it asks you. Just run
76
77 $ sphinx-quickstart
78
79 and answer its questions. (Be sure to say yes to the "autodoc" exten‐
80 sion.)
81
82 There is also an automatic "API documentation" generator called
83 sphinx-apidoc; see invocation-apidoc for details.
84
85 Defining document structure
86 Let's assume you've run sphinx-quickstart. It created a source direc‐
87 tory with conf.py and a master document, index.rst (if you accepted the
88 defaults). The main function of the master document is to serve as a
89 welcome page, and to contain the root of the "table of contents tree"
90 (or toctree). This is one of the main things that Sphinx adds to
91 reStructuredText, a way to connect multiple files to a single hierarchy
92 of documents.
93
94 reStructuredText directives
95 toctree is a reStructuredText directive, a very versatile piece of
96 markup. Directives can have arguments, options and content.
97
98 Arguments are given directly after the double colon following the
99 directive's name. Each directive decides whether it can have argu‐
100 ments, and how many.
101
102 Options are given after the arguments, in form of a "field list". The
103 maxdepth is such an option for the toctree directive.
104
105 Content follows the options or arguments after a blank line. Each
106 directive decides whether to allow content, and what to do with it.
107
108 A common gotcha with directives is that the first line of the content
109 must be indented to the same level as the options are.
110
111 The toctree directive initially is empty, and looks like this:
112
113 .. toctree::
114 :maxdepth: 2
115
116 You add documents listing them in the content of the directive:
117
118 .. toctree::
119 :maxdepth: 2
120
121 intro
122 tutorial
123 ...
124
125 This is exactly how the toctree for this documentation looks. The doc‐
126 uments to include are given as document names, which in short means
127 that you leave off the file name extension and use slashes as directory
128 separators.
129
130 [image: more info] [image]
131 Read more about the toctree directive.
132
133 You can now create the files you listed in the toctree and add content,
134 and their section titles will be inserted (up to the "maxdepth" level)
135 at the place where the toctree directive is placed. Also, Sphinx now
136 knows about the order and hierarchy of your documents. (They may con‐
137 tain toctree directives themselves, which means you can create deeply
138 nested hierarchies if necessary.)
139
140 Adding content
141 In Sphinx source files, you can use most features of standard reStruc‐
142 turedText. There are also several features added by Sphinx. For exam‐
143 ple, you can add cross-file references in a portable way (which works
144 for all output types) using the ref role.
145
146 For an example, if you are viewing the HTML version you can look at the
147 source for this document -- use the "Show Source" link in the sidebar.
148
149 [image: more info] [image]
150 See rst-primer for a more in-depth introduction to reStructuredText
151 and sphinxmarkup for a full list of markup added by Sphinx.
152
153 Running the build
154 Now that you have added some files and content, let's make a first
155 build of the docs. A build is started with the sphinx-build program,
156 called like this:
157
158 $ sphinx-build -b html sourcedir builddir
159
160 where sourcedir is the source directory, and builddir is the directory
161 in which you want to place the built documentation. The -b option
162 selects a builder; in this example Sphinx will build HTML files.
163
164 [image: more info] [image]
165 See invocation for all options that sphinx-build supports.
166
167 However, sphinx-quickstart script creates a Makefile and a make.bat
168 which make life even easier for you: with them you only need to run
169
170 $ make html
171
172 to build HTML docs in the build directory you chose. Execute make
173 without an argument to see which targets are available.
174
175 How do I generate PDF documents?
176
177 make latexpdf runs the LaTeX builder and readily invokes the
178 pdfTeX toolchain for you.
179
180 Documenting objects
181 One of Sphinx' main objectives is easy documentation of objects (in a
182 very general sense) in any domain. A domain is a collection of object
183 types that belong together, complete with markup to create and refer‐
184 ence descriptions of these objects.
185
186 The most prominent domain is the Python domain. To e.g. document the
187 Python built-in function enumerate(), you would add this to one of your
188 source files:
189
190 .. py:function:: enumerate(sequence[, start=0])
191
192 Return an iterator that yields tuples of an index and an item of the
193 *sequence*. (And so on.)
194
195 This is rendered like this:
196
197 enumerate(sequence[, start=0])
198 Return an iterator that yields tuples of an index and an item of
199 the sequence. (And so on.)
200
201 The argument of the directive is the signature of the object you
202 describe, the content is the documentation for it. Multiple signatures
203 can be given, each in its own line.
204
205 The Python domain also happens to be the default domain, so you don't
206 need to prefix the markup with the domain name:
207
208 .. function:: enumerate(sequence[, start=0])
209
210 ...
211
212 does the same job if you keep the default setting for the default
213 domain.
214
215 There are several more directives for documenting other types of Python
216 objects, for example py:class or py:method. There is also a cross-ref‐
217 erencing role for each of these object types. This markup will create
218 a link to the documentation of enumerate():
219
220 The :py:func:`enumerate` function can be used for ...
221
222 And here is the proof: A link to enumerate().
223
224 Again, the py: can be left out if the Python domain is the default one.
225 It doesn't matter which file contains the actual documentation for enu‐
226 merate(); Sphinx will find it and create a link to it.
227
228 Each domain will have special rules for how the signatures can look
229 like, and make the formatted output look pretty, or add specific fea‐
230 tures like links to parameter types, e.g. in the C/C++ domains.
231
232 [image: more info] [image]
233 See domains for all the available domains and their directives/roles.
234
235 Basic configuration
236 Earlier we mentioned that the conf.py file controls how Sphinx pro‐
237 cesses your documents. In that file, which is executed as a Python
238 source file, you assign configuration values. For advanced users:
239 since it is executed by Sphinx, you can do non-trivial tasks in it,
240 like extending sys.path or importing a module to find out the version
241 your are documenting.
242
243 The config values that you probably want to change are already put into
244 the conf.py by sphinx-quickstart and initially commented out (with
245 standard Python syntax: a # comments the rest of the line). To change
246 the default value, remove the hash sign and modify the value. To cus‐
247 tomize a config value that is not automatically added by sphinx-quick‐
248 start, just add an additional assignment.
249
250 Keep in mind that the file uses Python syntax for strings, numbers,
251 lists and so on. The file is saved in UTF-8 by default, as indicated
252 by the encoding declaration in the first line. If you use non-ASCII
253 characters in any string value, you need to use Python Unicode strings
254 (like project = u'Exposé').
255
256 [image: more info] [image]
257 See build-config for documentation of all available config values.
258
259 Autodoc
260 When documenting Python code, it is common to put a lot of documenta‐
261 tion in the source files, in documentation strings. Sphinx supports
262 the inclusion of docstrings from your modules with an extension (an
263 extension is a Python module that provides additional features for
264 Sphinx projects) called "autodoc".
265
266 In order to use autodoc, you need to activate it in conf.py by putting
267 the string 'sphinx.ext.autodoc' into the list assigned to the exten‐
268 sions config value. Then, you have a few additional directives at your
269 disposal.
270
271 For example, to document the function io.open(), reading its signature
272 and docstring from the source file, you'd write this:
273
274 .. autofunction:: io.open
275
276 You can also document whole classes or even modules automatically,
277 using member options for the auto directives, like
278
279 .. automodule:: io
280 :members:
281
282 autodoc needs to import your modules in order to extract the doc‐
283 strings. Therefore, you must add the appropriate path to sys.path in
284 your conf.py.
285
286 [image: more info] [image]
287 See sphinx.ext.autodoc for the complete description of the features of
288 autodoc.
289
290 More topics to be covered
291 · Other extensions (math, intersphinx, viewcode, doctest)
292
293 · Static files
294
295 · Selecting a theme
296
297 · Templating
298
299 · Using extensions
300
301 · Writing extensions
302
304 [1] This is the usual lay-out. However, conf.py can also live in
305 another directory, the configuration directory. See invocation.
306
308 The sphinx-build script builds a Sphinx documentation set. It is
309 called like this:
310
311 $ sphinx-build [options] sourcedir builddir [filenames]
312
313 where sourcedir is the source directory, and builddir is the directory
314 in which you want to place the built documentation. Most of the time,
315 you don't need to specify any filenames.
316
317 The sphinx-build script has several options:
318
319 -b buildername
320 The most important option: it selects a builder. The most com‐
321 mon builders are:
322
323 html Build HTML pages. This is the default builder.
324
325 dirhtml
326 Build HTML pages, but with a single directory per docu‐
327 ment. Makes for prettier URLs (no .html) if served from
328 a webserver.
329
330 singlehtml
331 Build a single HTML with the whole content.
332
333 htmlhelp, qthelp, devhelp, epub
334 Build HTML files with additional information for building
335 a documentation collection in one of these formats.
336
337 latex Build LaTeX sources that can be compiled to a PDF docu‐
338 ment using pdflatex.
339
340 man Build manual pages in groff format for UNIX systems.
341
342 texinfo
343 Build Texinfo files that can be processed into Info files
344 using makeinfo.
345
346 text Build plain text files.
347
348 gettext
349 Build gettext-style message catalogs (.pot files).
350
351 doctest
352 Run all doctests in the documentation, if the doctest
353 extension is enabled.
354
355 linkcheck
356 Check the integrity of all external links.
357
358 See builders for a list of all builders shipped with Sphinx.
359 Extensions can add their own builders.
360
361 -a If given, always write all output files. The default is to only
362 write output files for new and changed source files. (This may
363 not apply to all builders.)
364
365 -E Don't use a saved environment (the structure caching all
366 cross-references), but rebuild it completely. The default is to
367 only read and parse source files that are new or have changed
368 since the last run.
369
370 -t tag Define the tag tag. This is relevant for only directives that
371 only include their content if this tag is set.
372
373 New in version 0.6.
374
375 -d path
376 Since Sphinx has to read and parse all source files before it
377 can write an output file, the parsed source files are cached as
378 "doctree pickles". Normally, these files are put in a directory
379 called .doctrees under the build directory; with this option you
380 can select a different cache directory (the doctrees can be
381 shared between all builders).
382
383 -c path
384 Don't look for the conf.py in the source directory, but use the
385 given configuration directory instead. Note that various other
386 files and paths given by configuration values are expected to be
387 relative to the configuration directory, so they will have to be
388 present at this location too.
389
390 New in version 0.3.
391
392 -C Don't look for a configuration file; only take options via the
393 -D option.
394
395 New in version 0.5.
396
397 -D setting=value
398 Override a configuration value set in the conf.py file. The
399 value must be a string or dictionary value. For the latter,
400 supply the setting name and key like this: -D latex_ele‐
401 ments.docclass=scrartcl. For boolean values, use 0 or 1 as the
402 value.
403
404 Changed in version 0.6: The value can now be a dictionary value.
405
406 -A name=value
407 Make the name assigned to value in the HTML templates.
408
409 New in version 0.5.
410
411 -n Run in nit-picky mode. Currently, this generates warnings for
412 all missing references.
413
414 -N Do not emit colored output. (On Windows, colored output is dis‐
415 abled in any case.)
416
417 -q Do not output anything on standard output, only write warnings
418 and errors to standard error.
419
420 -Q Do not output anything on standard output, also suppress warn‐
421 ings. Only errors are written to standard error.
422
423 -w file
424 Write warnings (and errors) to the given file, in addition to
425 standard error.
426
427 -W Turn warnings into errors. This means that the build stops at
428 the first warning and sphinx-build exits with exit status 1.
429
430 -P (Useful for debugging only.) Run the Python debugger, pdb, if
431 an unhandled exception occurs while building.
432
433 You can also give one or more filenames on the command line after the
434 source and build directories. Sphinx will then try to build only these
435 output files (and their dependencies).
436
437 Makefile options
438 The Makefile and make.bat files created by sphinx-quickstart usually
439 run sphinx-build only with the -b and -d options. However, they sup‐
440 port the following variables to customize behavior:
441
442 PAPER The value for latex_paper_size.
443
444 SPHINXBUILD
445 The command to use instead of sphinx-build.
446
447 BUILDDIR
448 The build directory to use instead of the one chosen in
449 sphinx-quickstart.
450
451 SPHINXOPTS
452 Additional options for sphinx-build.
453
455 The sphinx-apidoc generates completely automatic API documentation for
456 a Python package. It is called like this:
457
458 $ sphinx-apidoc [options] -o outputdir packagedir [pathnames]
459
460 where packagedir is the path to the package to document, and outputdir
461 is the directory where the generated sources are placed. Any pathnames
462 given are paths to be excluded ignored during generation.
463
464 The sphinx-apidoc script has several options:
465
466 -o outputdir
467 Gives the directory in which to place the generated output.
468
469 -f, --force
470 Normally, sphinx-apidoc does not overwrite any files. Use this
471 option to force the overwrite of all files that it generates.
472
473 -n, --dry-run
474 With this option given, no files will be written at all.
475
476 -s suffix
477 This option selects the file name suffix of output files. By
478 default, this is rst.
479
480 -d maxdepth
481 This sets the maximum depth of the table of contents, if one is
482 generated.
483
484 -T, --no-toc
485 This prevents the generation of a table-of-contents file mod‐
486 ules.rst. This has no effect when --full is given.
487
488 -F, --full
489 This option makes sphinx-apidoc create a full Sphinx project,
490 using the same mechanism as sphinx-quickstart. Most configura‐
491 tion values are set to default values, but you can influence the
492 most important ones using the following options.
493
494 -H project
495 Sets the project name to put in generated files (see project).
496
497 -A author
498 Sets the author name(s) to put in generated files (see copy‐
499 right).
500
501 -V version
502 Sets the project version to put in generated files (see ver‐
503 sion).
504
505 -R release
506 Sets the project release to put in generated files (see
507 release).
508
510 This section is a brief introduction to reStructuredText (reST) con‐
511 cepts and syntax, intended to provide authors with enough information
512 to author documents productively. Since reST was designed to be a sim‐
513 ple, unobtrusive markup language, this will not take too long.
514
515 See also
516
517 The authoritative reStructuredText User Documentation. The
518 "ref" links in this document link to the description of the
519 individual constructs in the reST reference.
520
521 Paragraphs
522 The paragraph (ref) is the most basic block in a reST document. Para‐
523 graphs are simply chunks of text separated by one or more blank lines.
524 As in Python, indentation is significant in reST, so all lines of the
525 same paragraph must be left-aligned to the same level of indentation.
526
527 Inline markup
528 The standard reST inline markup is quite simple: use
529
530 · one asterisk: *text* for emphasis (italics),
531
532 · two asterisks: **text** for strong emphasis (boldface), and
533
534 · backquotes: ``text`` for code samples.
535
536 If asterisks or backquotes appear in running text and could be confused
537 with inline markup delimiters, they have to be escaped with a back‐
538 slash.
539
540 Be aware of some restrictions of this markup:
541
542 · it may not be nested,
543
544 · content may not start or end with whitespace: * text* is wrong,
545
546 · it must be separated from surrounding text by non-word characters.
547 Use a backslash escaped space to work around that: thisis\ *one*\
548 word.
549
550 These restrictions may be lifted in future versions of the docutils.
551
552 reST also allows for custom "interpreted text roles"', which signify
553 that the enclosed text should be interpreted in a specific way. Sphinx
554 uses this to provide semantic markup and cross-referencing of identi‐
555 fiers, as described in the appropriate section. The general syntax is
556 :rolename:`content`.
557
558 Standard reST provides the following roles:
559
560 · emphasis -- alternate spelling for *emphasis*
561
562 · strong -- alternate spelling for **strong**
563
564 · literal -- alternate spelling for ``literal``
565
566 · subscript -- subscript text
567
568 · superscript -- superscript text
569
570 · title-reference -- for titles of books, periodicals, and other mate‐
571 rials
572
573 See inline-markup for roles added by Sphinx.
574
575 Lists and Quote-like blocks
576 List markup (ref) is natural: just place an asterisk at the start of a
577 paragraph and indent properly. The same goes for numbered lists; they
578 can also be autonumbered using a # sign:
579
580 * This is a bulleted list.
581 * It has two items, the second
582 item uses two lines.
583
584 1. This is a numbered list.
585 2. It has two items too.
586
587 #. This is a numbered list.
588 #. It has two items too.
589
590 Nested lists are possible, but be aware that they must be separated
591 from the parent list items by blank lines:
592
593 * this is
594 * a list
595
596 * with a nested list
597 * and some subitems
598
599 * and here the parent list continues
600
601 Definition lists (ref) are created as follows:
602
603 term (up to a line of text)
604 Definition of the term, which must be indented
605
606 and can even consist of multiple paragraphs
607
608 next term
609 Description.
610
611 Note that the term cannot have more than one line of text.
612
613 Quoted paragraphs (ref) are created by just indenting them more than
614 the surrounding paragraphs.
615
616 Line blocks (ref) are a way of preserving line breaks:
617
618 | These lines are
619 | broken exactly like in
620 | the source file.
621
622 There are also several more special blocks available:
623
624 · field lists (ref)
625
626 · option lists (ref)
627
628 · quoted literal blocks (ref)
629
630 · doctest blocks (ref)
631
632 Source Code
633 Literal code blocks (ref) are introduced by ending a paragraph with the
634 special marker ::. The literal block must be indented (and, like all
635 paragraphs, separated from the surrounding ones by blank lines):
636
637 This is a normal text paragraph. The next paragraph is a code sample::
638
639 It is not processed in any way, except
640 that the indentation is removed.
641
642 It can span multiple lines.
643
644 This is a normal text paragraph again.
645
646 The handling of the :: marker is smart:
647
648 · If it occurs as a paragraph of its own, that paragraph is completely
649 left out of the document.
650
651 · If it is preceded by whitespace, the marker is removed.
652
653 · If it is preceded by non-whitespace, the marker is replaced by a sin‐
654 gle colon.
655
656 That way, the second sentence in the above example's first paragraph
657 would be rendered as "The next paragraph is a code sample:".
658
659 Tables
660 Two forms of tables are supported. For grid tables (ref), you have to
661 "paint" the cell grid yourself. They look like this:
662
663 +------------------------+------------+----------+----------+
664 | Header row, column 1 | Header 2 | Header 3 | Header 4 |
665 | (header rows optional) | | | |
666 +========================+============+==========+==========+
667 | body row 1, column 1 | column 2 | column 3 | column 4 |
668 +------------------------+------------+----------+----------+
669 | body row 2 | ... | ... | |
670 +------------------------+------------+----------+----------+
671
672 Simple tables (ref) are easier to write, but limited: they must contain
673 more than one row, and the first column cannot contain multiple lines.
674 They look like this:
675
676 ===== ===== =======
677 A B A and B
678 ===== ===== =======
679 False False False
680 True False False
681 False True False
682 True True True
683 ===== ===== =======
684
685 Hyperlinks
686 External links
687 Use `Link text <http://example.com/>`_ for inline web links. If the
688 link text should be the web address, you don't need special markup at
689 all, the parser finds links and mail addresses in ordinary text.
690
691 You can also separate the link and the target definition (ref), like
692 this:
693
694 This is a paragraph that contains `a link`_.
695
696 .. _a link: http://example.com/
697
698 Internal links
699 Internal linking is done via a special reST role provided by Sphinx,
700 see the section on specific markup, ref-role.
701
702 Sections
703 Section headers (ref) are created by underlining (and optionally over‐
704 lining) the section title with a punctuation character, at least as
705 long as the text:
706
707 =================
708 This is a heading
709 =================
710
711 Normally, there are no heading levels assigned to certain characters as
712 the structure is determined from the succession of headings. However,
713 for the Python documentation, this convention is used which you may
714 follow:
715
716 · # with overline, for parts
717
718 · * with overline, for chapters
719
720 · =, for sections
721
722 · -, for subsections
723
724 · ^, for subsubsections
725
726 · ", for paragraphs
727
728 Of course, you are free to use your own marker characters (see the reST
729 documentation), and use a deeper nesting level, but keep in mind that
730 most target formats (HTML, LaTeX) have a limited supported nesting
731 depth.
732
733 Explicit Markup
734 "Explicit markup" (ref) is used in reST for most constructs that need
735 special handling, such as footnotes, specially-highlighted paragraphs,
736 comments, and generic directives.
737
738 An explicit markup block begins with a line starting with .. followed
739 by whitespace and is terminated by the next paragraph at the same level
740 of indentation. (There needs to be a blank line between explicit
741 markup and normal paragraphs. This may all sound a bit complicated,
742 but it is intuitive enough when you write it.)
743
744 Directives
745 A directive (ref) is a generic block of explicit markup. Besides
746 roles, it is one of the extension mechanisms of reST, and Sphinx makes
747 heavy use of it.
748
749 Docutils supports the following directives:
750
751 · Admonitions: attention, caution, danger, error, hint, important,
752 note, tip, warning and the generic admonition. (Most themes style
753 only "note" and "warning" specially.)
754
755 · Images:
756
757 · image (see also Images below)
758
759 · figure (an image with caption and optional legend)
760
761 · Additional body elements:
762
763 · contents (a local, i.e. for the current file only, table of con‐
764 tents)
765
766 · container (a container with a custom class, useful to generate an
767 outer <div> in HTML)
768
769 · rubric (a heading without relation to the document sectioning)
770
771 · topic, sidebar (special highlighted body elements)
772
773 · parsed-literal (literal block that supports inline markup)
774
775 · epigraph (a block quote with optional attribution line)
776
777 · highlights, pull-quote (block quotes with their own class
778 attribute)
779
780 · compound (a compound paragraph)
781
782 · Special tables:
783
784 · table (a table with title)
785
786 · csv-table (a table generated from comma-separated values)
787
788 · list-table (a table generated from a list of lists)
789
790 · Special directives:
791
792 · raw (include raw target-format markup)
793
794 · include (include reStructuredText from another file) -- in Sphinx,
795 when given an absolute include file path, this directive takes it
796 as relative to the source directory
797
798 · class (assign a class attribute to the next element) [1]
799
800 · HTML specifics:
801
802 · meta (generation of HTML <meta> tags)
803
804 · title (override document title)
805
806 · Influencing markup:
807
808 · default-role (set a new default role)
809
810 · role (create a new role)
811
812 Since these are only per-file, better use Sphinx' facilities for set‐
813 ting the default_role.
814
815 Do not use the directives sectnum, header and footer.
816
817 Directives added by Sphinx are described in sphinxmarkup.
818
819 Basically, a directive consists of a name, arguments, options and con‐
820 tent. (Keep this terminology in mind, it is used in the next chapter
821 describing custom directives.) Looking at this example,
822
823 .. function:: foo(x)
824 foo(y, z)
825 :module: some.module.name
826
827 Return a line of text input from the user.
828
829 function is the directive name. It is given two arguments here, the
830 remainder of the first line and the second line, as well as one option
831 module (as you can see, options are given in the lines immediately fol‐
832 lowing the arguments and indicated by the colons). Options must be
833 indented to the same level as the directive content.
834
835 The directive content follows after a blank line and is indented rela‐
836 tive to the directive start.
837
838 Images
839 reST supports an image directive (ref), used like so:
840
841 .. image:: gnu.png
842 (options)
843
844 When used within Sphinx, the file name given (here gnu.png) must either
845 be relative to the source file, or absolute which means that they are
846 relative to the top source directory. For example, the file
847 sketch/spam.rst could refer to the image images/spam.png as
848 ../images/spam.png or /images/spam.png.
849
850 Sphinx will automatically copy image files over to a subdirectory of
851 the output directory on building (e.g. the _static directory for HTML
852 output.)
853
854 Interpretation of image size options (width and height) is as follows:
855 if the size has no unit or the unit is pixels, the given size will only
856 be respected for output channels that support pixels (i.e. not in LaTeX
857 output). Other units (like pt for points) will be used for HTML and
858 LaTeX output.
859
860 Sphinx extends the standard docutils behavior by allowing an asterisk
861 for the extension:
862
863 .. image:: gnu.*
864
865 Sphinx then searches for all images matching the provided pattern and
866 determines their type. Each builder then chooses the best image out of
867 these candidates. For instance, if the file name gnu.* was given and
868 two files gnu.pdf and gnu.png existed in the source tree, the LaTeX
869 builder would choose the former, while the HTML builder would prefer
870 the latter.
871
872 Changed in version 0.4: Added the support for file names ending in an
873 asterisk.
874
875 Changed in version 0.6: Image paths can now be absolute.
876
877 Footnotes
878 For footnotes (ref), use [#name]_ to mark the footnote location, and
879 add the footnote body at the bottom of the document after a "Footnotes"
880 rubric heading, like so:
881
882 Lorem ipsum [#f1]_ dolor sit amet ... [#f2]_
883
884 .. rubric:: Footnotes
885
886 .. [#f1] Text of the first footnote.
887 .. [#f2] Text of the second footnote.
888
889 You can also explicitly number the footnotes ([1]_) or use auto-num‐
890 bered footnotes without names ([#]_).
891
892 Citations
893 Standard reST citations (ref) are supported, with the additional fea‐
894 ture that they are "global", i.e. all citations can be referenced from
895 all files. Use them like so:
896
897 Lorem ipsum [Ref]_ dolor sit amet.
898
899 .. [Ref] Book or article reference, URL or whatever.
900
901 Citation usage is similar to footnote usage, but with a label that is
902 not numeric or begins with #.
903
904 Substitutions
905 reST supports "substitutions" (ref), which are pieces of text and/or
906 markup referred to in the text by |name|. They are defined like foot‐
907 notes with explicit markup blocks, like this:
908
909 .. |name| replace:: replacement *text*
910
911 or this:
912
913 .. |caution| image:: warning.png
914 :alt: Warning!
915
916 See the reST reference for substitutions for details.
917
918 If you want to use some substitutions for all documents, put them into
919 rst_prolog or put them into a separate file and include it into all
920 documents you want to use them in, using the include directive. (Be
921 sure to give the include file a file name extension differing from that
922 of other source files, to avoid Sphinx finding it as a standalone docu‐
923 ment.)
924
925 Sphinx defines some default substitutions, see default-substitutions.
926
927 Comments
928 Every explicit markup block which isn't a valid markup construct (like
929 the footnotes above) is regarded as a comment (ref). For example:
930
931 .. This is a comment.
932
933 You can indent text after a comment start to form multiline comments:
934
935 ..
936 This whole indented block
937 is a comment.
938
939 Still in the comment.
940
941 Source encoding
942 Since the easiest way to include special characters like em dashes or
943 copyright signs in reST is to directly write them as Unicode charac‐
944 ters, one has to specify an encoding. Sphinx assumes source files to
945 be encoded in UTF-8 by default; you can change this with the
946 source_encoding config value.
947
948 Gotchas
949 There are some problems one commonly runs into while authoring reST
950 documents:
951
952 · Separation of inline markup: As said above, inline markup spans must
953 be separated from the surrounding text by non-word characters, you
954 have to use a backslash-escaped space to get around that. See the
955 reference for the details.
956
957 · No nested inline markup: Something like *see :func:`foo`* is not pos‐
958 sible.
959
961 [1] When the default domain contains a class directive, this directive
962 will be shadowed. Therefore, Sphinx re-exports it as rst-class.
963
965 Sphinx adds a lot of new directives and interpreted text roles to
966 standard reST markup. This section contains the reference material for
967 these facilities.
968
969 The TOC tree
970 Since reST does not have facilities to interconnect several documents,
971 or split documents into multiple output files, Sphinx uses a custom
972 directive to add relations between the single files the documentation
973 is made of, as well as tables of contents. The toctree directive is
974 the central element.
975
976 NOTE:
977 Simple "inclusion" of one file in another can be done with the
978 include directive.
979
980 .. toctree::
981 This directive inserts a "TOC tree" at the current location,
982 using the individual TOCs (including "sub-TOC trees") of the
983 documents given in the directive body. Relative document names
984 (not beginning with a slash) are relative to the document the
985 directive occurs in, absolute names are relative to the source
986 directory. A numeric maxdepth option may be given to indicate
987 the depth of the tree; by default, all levels are included. [1]
988
989 Consider this example (taken from the Python docs' library ref‐
990 erence index):
991
992 .. toctree::
993 :maxdepth: 2
994
995 intro
996 strings
997 datatypes
998 numeric
999 (many more documents listed here)
1000
1001 This accomplishes two things:
1002
1003 · Tables of contents from all those documents are inserted, with
1004 a maximum depth of two, that means one nested heading. toc‐
1005 tree directives in those documents are also taken into
1006 account.
1007
1008 · Sphinx knows that the relative order of the documents intro,
1009 strings and so forth, and it knows that they are children of
1010 the shown document, the library index. From this information
1011 it generates "next chapter", "previous chapter" and "parent
1012 chapter" links.
1013
1014 Entries
1015
1016 Document titles in the toctree will be automatically read from
1017 the title of the referenced document. If that isn't what you
1018 want, you can specify an explicit title and target using a simi‐
1019 lar syntax to reST hyperlinks (and Sphinx's cross-referencing
1020 syntax). This looks like:
1021
1022 .. toctree::
1023
1024 intro
1025 All about strings <strings>
1026 datatypes
1027
1028 The second line above will link to the strings document, but
1029 will use the title "All about strings" instead of the title of
1030 the strings document.
1031
1032 You can also add external links, by giving an HTTP URL instead
1033 of a document name.
1034
1035 Section numbering
1036
1037 If you want to have section numbers even in HTML output, give
1038 the toctree a numbered option. For example:
1039
1040 .. toctree::
1041 :numbered:
1042
1043 foo
1044 bar
1045
1046 Numbering then starts at the heading of foo. Sub-toctrees are
1047 automatically numbered (don't give the numbered flag to those).
1048
1049 Numbering up to a specific depth is also possible, by giving the
1050 depth as a numeric argument to numbered.
1051
1052 Additional options
1053
1054 If you want only the titles of documents in the tree to show up,
1055 not other headings of the same level, you can use the titlesonly
1056 option:
1057
1058 .. toctree::
1059 :titlesonly:
1060
1061 foo
1062 bar
1063
1064 You can use "globbing" in toctree directives, by giving the glob
1065 flag option. All entries are then matched against the list of
1066 available documents, and matches are inserted into the list
1067 alphabetically. Example:
1068
1069 .. toctree::
1070 :glob:
1071
1072 intro*
1073 recipe/*
1074 *
1075
1076 This includes first all documents whose names start with intro,
1077 then all documents in the recipe folder, then all remaining doc‐
1078 uments (except the one containing the directive, of course.) [2]
1079
1080 The special entry name self stands for the document containing
1081 the toctree directive. This is useful if you want to generate a
1082 "sitemap" from the toctree.
1083
1084 You can also give a "hidden" option to the directive, like this:
1085
1086 .. toctree::
1087 :hidden:
1088
1089 doc_1
1090 doc_2
1091
1092 This will still notify Sphinx of the document hierarchy, but not
1093 insert links into the document at the location of the directive
1094 -- this makes sense if you intend to insert these links your‐
1095 self, in a different style, or in the HTML sidebar.
1096
1097 In the end, all documents in the source directory (or subdirec‐
1098 tories) must occur in some toctree directive; Sphinx will emit a
1099 warning if it finds a file that is not included, because that
1100 means that this file will not be reachable through standard nav‐
1101 igation. Use unused_docs to explicitly exclude documents from
1102 building, and exclude_trees to exclude whole directories.
1103
1104 The "master document" (selected by master_doc) is the "root" of
1105 the TOC tree hierarchy. It can be used as the documentation's
1106 main page, or as a "full table of contents" if you don't give a
1107 maxdepth option.
1108
1109 Changed in version 0.3: Added "globbing" option.
1110
1111 Changed in version 0.6: Added "numbered" and "hidden" options as
1112 well as external links and support for "self" references.
1113
1114 Changed in version 1.0: Added "titlesonly" option.
1115
1116 Changed in version 1.1: Added numeric argument to "numbered".
1117
1118 Special names
1119 Sphinx reserves some document names for its own use; you should not try
1120 to create documents with these names -- it will cause problems.
1121
1122 The special document names (and pages generated for them) are:
1123
1124 · genindex, modindex, search
1125
1126 These are used for the general index, the Python module index, and
1127 the search page, respectively.
1128
1129 The general index is populated with entries from modules, all
1130 index-generating object descriptions, and from index directives.
1131
1132 The Python module index contains one entry per py:module directive.
1133
1134 The search page contains a form that uses the generated JSON search
1135 index and JavaScript to full-text search the generated documents for
1136 search words; it should work on every major browser that supports
1137 modern JavaScript.
1138
1139 · every name beginning with _
1140
1141 Though only few such names are currently used by Sphinx, you should
1142 not create documents or document-containing directories with such
1143 names. (Using _ as a prefix for a custom template directory is
1144 fine.)
1145
1147 [1] The maxdepth option does not apply to the LaTeX writer, where the
1148 whole table of contents will always be presented at the begin of
1149 the document, and its depth is controlled by the tocdepth counter,
1150 which you can reset in your latex_preamble config value using e.g.
1151 \setcounter{tocdepth}{2}.
1152
1153 [2] A note on available globbing syntax: you can use the standard
1154 shell constructs *, ?, [...] and [!...] with the feature that
1155 these all don't match slashes. A double star ** can be used to
1156 match any sequence of characters including slashes.
1157
1158 Paragraph-level markup
1159 These directives create short paragraphs and can be used inside infor‐
1160 mation units as well as normal text:
1161
1162 .. note::
1163 An especially important bit of information about an API that a
1164 user should be aware of when using whatever bit of API the note
1165 pertains to. The content of the directive should be written in
1166 complete sentences and include all appropriate punctuation.
1167
1168 Example:
1169
1170 .. note::
1171
1172 This function is not suitable for sending spam e-mails.
1173
1174 .. warning::
1175 An important bit of information about an API that a user should
1176 be very aware of when using whatever bit of API the warning per‐
1177 tains to. The content of the directive should be written in
1178 complete sentences and include all appropriate punctuation. This
1179 differs from note in that it is recommended over note for infor‐
1180 mation regarding security.
1181
1182 .. versionadded:: version
1183 This directive documents the version of the project which added
1184 the described feature to the library or C API. When this applies
1185 to an entire module, it should be placed at the top of the mod‐
1186 ule section before any prose.
1187
1188 The first argument must be given and is the version in question;
1189 you can add a second argument consisting of a brief explanation
1190 of the change.
1191
1192 Example:
1193
1194 .. versionadded:: 2.5
1195 The *spam* parameter.
1196
1197 Note that there must be no blank line between the directive head
1198 and the explanation; this is to make these blocks visually con‐
1199 tinuous in the markup.
1200
1201 .. versionchanged:: version
1202 Similar to versionadded, but describes when and what changed in
1203 the named feature in some way (new parameters, changed side
1204 effects, etc.).
1205
1206 .. deprecated:: version
1207 Similar to versionchanged, but describes when the feature was
1208 deprecated. An explanation can also be given, for example to
1209 inform the reader what should be used instead. Example:
1210
1211 .. deprecated:: 3.1
1212 Use :func:`spam` instead.
1213
1214
1215 ----
1216
1217
1218
1219 .. seealso::
1220 Many sections include a list of references to module documenta‐
1221 tion or external documents. These lists are created using the
1222 seealso directive.
1223
1224 The seealso directive is typically placed in a section just
1225 before any sub-sections. For the HTML output, it is shown boxed
1226 off from the main flow of the text.
1227
1228 The content of the seealso directive should be a reST definition
1229 list. Example:
1230
1231 .. seealso::
1232
1233 Module :py:mod:`zipfile`
1234 Documentation of the :py:mod:`zipfile` standard module.
1235
1236 `GNU tar manual, Basic Tar Format <http://link>`_
1237 Documentation for tar archive files, including GNU tar extensions.
1238
1239 There's also a "short form" allowed that looks like this:
1240
1241 .. seealso:: modules :py:mod:`zipfile`, :py:mod:`tarfile`
1242
1243 New in version 0.5: The short form.
1244
1245 .. rubric:: title
1246 This directive creates a paragraph heading that is not used to
1247 create a table of contents node.
1248
1249 NOTE:
1250 If the title of the rubric is "Footnotes" (or the selected
1251 language's equivalent), this rubric is ignored by the LaTeX
1252 writer, since it is assumed to only contain footnote defini‐
1253 tions and therefore would create an empty heading.
1254
1255 .. centered::
1256 This directive creates a centered boldfaced line of text. Use
1257 it as follows:
1258
1259 .. centered:: LICENSE AGREEMENT
1260
1261 Deprecated since version 1.1: This presentation-only directive
1262 is a legacy from older versions. Use a rst-class directive
1263 instead and add an appropriate style.
1264
1265 .. hlist::
1266 This directive must contain a bullet list. It will transform it
1267 into a more compact list by either distributing more than one
1268 item horizontally, or reducing spacing between items, depending
1269 on the builder.
1270
1271 For builders that support the horizontal distribution, there is
1272 a columns option that specifies the number of columns; it
1273 defaults to 2. Example:
1274
1275 .. hlist::
1276 :columns: 3
1277
1278 * A list of
1279 * short items
1280 * that should be
1281 * displayed
1282 * horizontally
1283
1284 New in version 0.6.
1285
1286 Table-of-contents markup
1287 The toctree directive, which generates tables of contents of subdocu‐
1288 ments, is described in toctree-directive.
1289
1290 For local tables of contents, use the standard reST contents directive.
1291
1292 Glossary
1293 .. glossary::
1294 This directive must contain a reST definition-list-like markup
1295 with terms and definitions. The definitions will then be refer‐
1296 encable with the term role. Example:
1297
1298 .. glossary::
1299
1300 environment
1301 A structure where information about all documents under the root is
1302 saved, and used for cross-referencing. The environment is pickled
1303 after the parsing stage, so that successive runs only need to read
1304 and parse new and changed documents.
1305
1306 source directory
1307 The directory which, including its subdirectories, contains all
1308 source files for one Sphinx project.
1309
1310 In contrast to regular definition lists, multiple terms per
1311 entry are allowed, and inline markup is allowed in terms. You
1312 can link to all of the terms. For example:
1313
1314 .. glossary::
1315
1316 term 1
1317 term 2
1318 Definition of both terms.
1319
1320 (When the glossary is sorted, the first term determines the sort
1321 order.)
1322
1323 New in version 0.6: You can now give the glossary directive a
1324 :sorted: flag that will automatically sort the entries alphabet‐
1325 ically.
1326
1327 Changed in version 1.1: Now supports multiple terms and inline
1328 markup in terms.
1329
1330 Grammar production displays
1331 Special markup is available for displaying the productions of a formal
1332 grammar. The markup is simple and does not attempt to model all
1333 aspects of BNF (or any derived forms), but provides enough to allow
1334 context-free grammars to be displayed in a way that causes uses of a
1335 symbol to be rendered as hyperlinks to the definition of the symbol.
1336 There is this directive:
1337
1338 .. productionlist:: [name]
1339 This directive is used to enclose a group of productions. Each
1340 production is given on a single line and consists of a name,
1341 separated by a colon from the following definition. If the def‐
1342 inition spans multiple lines, each continuation line must begin
1343 with a colon placed at the same column as in the first line.
1344
1345 The argument to productionlist serves to distinguish different
1346 sets of production lists that belong to different grammars.
1347
1348 Blank lines are not allowed within productionlist directive
1349 arguments.
1350
1351 The definition can contain token names which are marked as
1352 interpreted text (e.g. sum ::= `integer` "+" `integer`) -- this
1353 generates cross-references to the productions of these tokens.
1354 Outside of the production list, you can reference to token pro‐
1355 ductions using token.
1356
1357 Note that no further reST parsing is done in the production, so
1358 that you don't have to escape * or | characters.
1359
1360 The following is an example taken from the Python Reference Manual:
1361
1362 .. productionlist::
1363 try_stmt: try1_stmt | try2_stmt
1364 try1_stmt: "try" ":" `suite`
1365 : ("except" [`expression` ["," `target`]] ":" `suite`)+
1366 : ["else" ":" `suite`]
1367 : ["finally" ":" `suite`]
1368 try2_stmt: "try" ":" `suite`
1369 : "finally" ":" `suite`
1370
1371 Showing code examples
1372 Examples of Python source code or interactive sessions are represented
1373 using standard reST literal blocks. They are started by a :: at the
1374 end of the preceding paragraph and delimited by indentation.
1375
1376 Representing an interactive session requires including the prompts and
1377 output along with the Python code. No special markup is required for
1378 interactive sessions. After the last line of input or output pre‐
1379 sented, there should not be an "unused" primary prompt; this is an
1380 example of what not to do:
1381
1382 >>> 1 + 1
1383 2
1384 >>>
1385
1386 Syntax highlighting is done with Pygments (if it's installed) and han‐
1387 dled in a smart way:
1388
1389 · There is a "highlighting language" for each source file. Per
1390 default, this is 'python' as the majority of files will have to high‐
1391 light Python snippets, but the doc-wide default can be set with the
1392 highlight_language config value.
1393
1394 · Within Python highlighting mode, interactive sessions are recognized
1395 automatically and highlighted appropriately. Normal Python code is
1396 only highlighted if it is parseable (so you can use Python as the
1397 default, but interspersed snippets of shell commands or other code
1398 blocks will not be highlighted as Python).
1399
1400 · The highlighting language can be changed using the highlight direc‐
1401 tive, used as follows:
1402
1403 .. highlight:: c
1404
1405 This language is used until the next highlight directive is encoun‐
1406 tered.
1407
1408 · For documents that have to show snippets in different languages,
1409 there's also a code-block directive that is given the highlighting
1410 language directly:
1411
1412 .. code-block:: ruby
1413
1414 Some Ruby code.
1415
1416 The directive's alias name sourcecode works as well.
1417
1418 · The valid values for the highlighting language are:
1419
1420 · none (no highlighting)
1421
1422 · python (the default when highlight_language isn't set)
1423
1424 · guess (let Pygments guess the lexer based on contents, only works
1425 with certain well-recognizable languages)
1426
1427 · rest
1428
1429 · c
1430
1431 · ... and any other lexer name that Pygments supports.
1432
1433 · If highlighting with the selected language fails, the block is not
1434 highlighted in any way.
1435
1436 Line numbers
1437 If installed, Pygments can generate line numbers for code blocks. For
1438 automatically-highlighted blocks (those started by ::), line numbers
1439 must be switched on in a highlight directive, with the linenothreshold
1440 option:
1441
1442 .. highlight:: python
1443 :linenothreshold: 5
1444
1445 This will produce line numbers for all code blocks longer than five
1446 lines.
1447
1448 For code-block blocks, a linenos flag option can be given to switch on
1449 line numbers for the individual block:
1450
1451 .. code-block:: ruby
1452 :linenos:
1453
1454 Some more Ruby code.
1455
1456 Additionally, an emphasize-lines option can be given to have Pygments
1457 emphasize particular lines:
1458
1459 .. code-block:: python
1460 :emphasize-lines: 3,5
1461
1462 def some_function():
1463 interesting = False
1464 print 'This line is highlighted.'
1465 print 'This one is not...'
1466 print '...but this one is.'
1467
1468 Changed in version 1.1: emphasize-lines has been added.
1469
1470 Includes
1471 .. literalinclude:: filename
1472 Longer displays of verbatim text may be included by storing the
1473 example text in an external file containing only plain text.
1474 The file may be included using the literalinclude directive. [1]
1475 For example, to include the Python source file example.py, use:
1476
1477 .. literalinclude:: example.py
1478
1479 The file name is usually relative to the current file's path.
1480 However, if it is absolute (starting with /), it is relative to
1481 the top source directory.
1482
1483 Tabs in the input are expanded if you give a tab-width option
1484 with the desired tab width.
1485
1486 The directive also supports the linenos flag option to switch on
1487 line numbers, the emphasize-lines option to emphasize particular
1488 lines, and a language option to select a language different from
1489 the current file's standard language. Example with options:
1490
1491 .. literalinclude:: example.rb
1492 :language: ruby
1493 :emphasize-lines: 12,15-18
1494 :linenos:
1495
1496 Include files are assumed to be encoded in the source_encoding.
1497 If the file has a different encoding, you can specify it with
1498 the encoding option:
1499
1500 .. literalinclude:: example.py
1501 :encoding: latin-1
1502
1503 The directive also supports including only parts of the file.
1504 If it is a Python module, you can select a class, function or
1505 method to include using the pyobject option:
1506
1507 .. literalinclude:: example.py
1508 :pyobject: Timer.start
1509
1510 This would only include the code lines belonging to the start()
1511 method in the Timer class within the file.
1512
1513 Alternately, you can specify exactly which lines to include by
1514 giving a lines option:
1515
1516 .. literalinclude:: example.py
1517 :lines: 1,3,5-10,20-
1518
1519 This includes the lines 1, 3, 5 to 10 and lines 20 to the last
1520 line.
1521
1522 Another way to control which part of the file is included is to
1523 use the start-after and end-before options (or only one of
1524 them). If start-after is given as a string option, only lines
1525 that follow the first line containing that string are included.
1526 If end-before is given as a string option, only lines that pre‐
1527 cede the first lines containing that string are included.
1528
1529 You can prepend and/or append a line to the included code, using
1530 the prepend and append option, respectively. This is useful
1531 e.g. for highlighting PHP code that doesn't include the <?php/?>
1532 markers.
1533
1534 New in version 0.4.3: The encoding option.
1535
1536 New in version 0.6: The pyobject, lines, start-after and
1537 end-before options, as well as support for absolute filenames.
1538
1539 New in version 1.0: The prepend and append options, as well as
1540 tab-width.
1541
1543 [1] There is a standard .. include directive, but it raises errors if
1544 the file is not found. This one only emits a warning.
1545
1546 Inline markup
1547 Sphinx uses interpreted text roles to insert semantic markup into docu‐
1548 ments. They are written as :rolename:`content`.
1549
1550 NOTE:
1551 The default role (`content`) has no special meaning by default. You
1552 are free to use it for anything you like, e.g. variable names; use
1553 the default_role config value to set it to a known role.
1554
1555 See domains for roles added by domains.
1556
1557 Cross-referencing syntax
1558 Cross-references are generated by many semantic interpreted text roles.
1559 Basically, you only need to write :role:`target`, and a link will be
1560 created to the item named target of the type indicated by role. The
1561 links's text will be the same as target.
1562
1563 There are some additional facilities, however, that make cross-refer‐
1564 encing roles more versatile:
1565
1566 · You may supply an explicit title and reference target, like in reST
1567 direct hyperlinks: :role:`title <target>` will refer to target, but
1568 the link text will be title.
1569
1570 · If you prefix the content with !, no reference/hyperlink will be cre‐
1571 ated.
1572
1573 · If you prefix the content with ~, the link text will only be the last
1574 component of the target. For example, :py:meth:`~Queue.Queue.get`
1575 will refer to Queue.Queue.get but only display get as the link text.
1576
1577 In HTML output, the link's title attribute (that is e.g. shown as a
1578 tool-tip on mouse-hover) will always be the full target name.
1579
1580 Cross-referencing objects
1581 These roles are described with their respective domains:
1582
1583 · Python
1584
1585 · C
1586
1587 · C++
1588
1589 · JavaScript
1590
1591 · ReST
1592
1593 Cross-referencing arbitrary locations
1594 :ref: To support cross-referencing to arbitrary locations in any docu‐
1595 ment, the standard reST labels are used. For this to work label
1596 names must be unique throughout the entire documentation. There
1597 are two ways in which you can refer to labels:
1598
1599 · If you place a label directly before a section title, you can
1600 reference to it with :ref:`label-name`. Example:
1601
1602 .. _my-reference-label:
1603
1604 Section to cross-reference
1605 --------------------------
1606
1607 This is the text of the section.
1608
1609 It refers to the section itself, see :ref:`my-reference-label`.
1610
1611 The :ref: role would then generate a link to the section, with
1612 the link title being "Section to cross-reference". This works
1613 just as well when section and reference are in different
1614 source files.
1615
1616 Automatic labels also work with figures: given
1617
1618 .. _my-figure:
1619
1620 .. figure:: whatever
1621
1622 Figure caption
1623
1624 a reference :ref:`my-figure` would insert a reference to the
1625 figure with link text "Figure caption".
1626
1627 The same works for tables that are given an explicit caption
1628 using the table directive.
1629
1630 · Labels that aren't placed before a section title can still be
1631 referenced to, but you must give the link an explicit title,
1632 using this syntax: :ref:`Link title <label-name>`.
1633
1634 Using ref is advised over standard reStructuredText links to
1635 sections (like `Section title`_) because it works across files,
1636 when section headings are changed, and for all builders that
1637 support cross-references.
1638
1639 Cross-referencing documents
1640 New in version 0.6.
1641
1642 There is also a way to directly link to documents:
1643
1644 :doc: Link to the specified document; the document name can be speci‐
1645 fied in absolute or relative fashion. For example, if the ref‐
1646 erence :doc:`parrot` occurs in the document sketches/index, then
1647 the link refers to sketches/parrot. If the reference is
1648 :doc:`/people` or :doc:`../people`, the link refers to people.
1649
1650 If no explicit link text is given (like usual: :doc:`Monty
1651 Python members </people>`), the link caption will be the title
1652 of the given document.
1653
1654 Referencing downloadable files
1655 New in version 0.6.
1656
1657 :download:
1658 This role lets you link to files within your source tree that
1659 are not reST documents that can be viewed, but files that can be
1660 downloaded.
1661
1662 When you use this role, the referenced file is automatically
1663 marked for inclusion in the output when building (obviously, for
1664 HTML output only). All downloadable files are put into the
1665 _downloads subdirectory of the output directory; duplicate file‐
1666 names are handled.
1667
1668 An example:
1669
1670 See :download:`this example script <../example.py>`.
1671
1672 The given filename is usually relative to the directory the cur‐
1673 rent source file is contained in, but if it absolute (starting
1674 with /), it is taken as relative to the top source directory.
1675
1676 The example.py file will be copied to the output directory, and
1677 a suitable link generated to it.
1678
1679 Cross-referencing other items of interest
1680 The following roles do possibly create a cross-reference, but do not
1681 refer to objects:
1682
1683 :envvar:
1684 An environment variable. Index entries are generated. Also
1685 generates a link to the matching envvar directive, if it exists.
1686
1687 :token:
1688 The name of a grammar token (used to create links between pro‐
1689 ductionlist directives).
1690
1691 :keyword:
1692 The name of a keyword in Python. This creates a link to a ref‐
1693 erence label with that name, if it exists.
1694
1695 :option:
1696 A command-line option to an executable program. The leading
1697 hyphen(s) must be included. This generates a link to a option
1698 directive, if it exists.
1699
1700 The following role creates a cross-reference to the term in the glos‐
1701 sary:
1702
1703 :term: Reference to a term in the glossary. The glossary is created
1704 using the glossary directive containing a definition list with
1705 terms and definitions. It does not have to be in the same file
1706 as the term markup, for example the Python docs have one global
1707 glossary in the glossary.rst file.
1708
1709 If you use a term that's not explained in a glossary, you'll get
1710 a warning during build.
1711
1712 Other semantic markup
1713 The following roles don't do anything special except formatting the
1714 text in a different style:
1715
1716 :abbr: An abbreviation. If the role content contains a parenthesized
1717 explanation, it will be treated specially: it will be shown in a
1718 tool-tip in HTML, and output only once in LaTeX.
1719
1720 Example: :abbr:`LIFO (last-in, first-out)`.
1721
1722 New in version 0.6.
1723
1724 :command:
1725 The name of an OS-level command, such as rm.
1726
1727 :dfn: Mark the defining instance of a term in the text. (No index
1728 entries are generated.)
1729
1730 :file: The name of a file or directory. Within the contents, you can
1731 use curly braces to indicate a "variable" part, for example:
1732
1733 ... is installed in :file:`/usr/lib/python2.{x}/site-packages` ...
1734
1735 In the built documentation, the x will be displayed differently
1736 to indicate that it is to be replaced by the Python minor ver‐
1737 sion.
1738
1739 :guilabel:
1740 Labels presented as part of an interactive user interface should
1741 be marked using guilabel. This includes labels from text-based
1742 interfaces such as those created using curses or other
1743 text-based libraries. Any label used in the interface should be
1744 marked with this role, including button labels, window titles,
1745 field names, menu and menu selection names, and even values in
1746 selection lists.
1747
1748 Changed in version 1.0: An accelerator key for the GUI label can
1749 be included using an ampersand; this will be stripped and dis‐
1750 played underlined in the output (example: :guilabel:`&Cancel`).
1751 To include a literal ampersand, double it.
1752
1753 :kbd: Mark a sequence of keystrokes. What form the key sequence takes
1754 may depend on platform- or application-specific conventions.
1755 When there are no relevant conventions, the names of modifier
1756 keys should be spelled out, to improve accessibility for new
1757 users and non-native speakers. For example, an xemacs key
1758 sequence may be marked like :kbd:`C-x C-f`, but without refer‐
1759 ence to a specific application or platform, the same sequence
1760 should be marked as :kbd:`Control-x Control-f`.
1761
1762 :mailheader:
1763 The name of an RFC 822-style mail header. This markup does not
1764 imply that the header is being used in an email message, but can
1765 be used to refer to any header of the same "style." This is
1766 also used for headers defined by the various MIME specifica‐
1767 tions. The header name should be entered in the same way it
1768 would normally be found in practice, with the camel-casing con‐
1769 ventions being preferred where there is more than one common
1770 usage. For example: :mailheader:`Content-Type`.
1771
1772 :makevar:
1773 The name of a make variable.
1774
1775 :manpage:
1776 A reference to a Unix manual page including the section, e.g.
1777 :manpage:`ls(1)`.
1778
1779 :menuselection:
1780 Menu selections should be marked using the menuselection role.
1781 This is used to mark a complete sequence of menu selections,
1782 including selecting submenus and choosing a specific operation,
1783 or any subsequence of such a sequence. The names of individual
1784 selections should be separated by -->.
1785
1786 For example, to mark the selection "Start > Programs", use this
1787 markup:
1788
1789 :menuselection:`Start --> Programs`
1790
1791 When including a selection that includes some trailing indica‐
1792 tor, such as the ellipsis some operating systems use to indicate
1793 that the command opens a dialog, the indicator should be omitted
1794 from the selection name.
1795
1796 menuselection also supports ampersand accelerators just like
1797 guilabel.
1798
1799 :mimetype:
1800 The name of a MIME type, or a component of a MIME type (the
1801 major or minor portion, taken alone).
1802
1803 :newsgroup:
1804 The name of a Usenet newsgroup.
1805
1806 :program:
1807 The name of an executable program. This may differ from the
1808 file name for the executable for some platforms. In particular,
1809 the .exe (or other) extension should be omitted for Windows pro‐
1810 grams.
1811
1812 :regexp:
1813 A regular expression. Quotes should not be included.
1814
1815 :samp: A piece of literal text, such as code. Within the contents, you
1816 can use curly braces to indicate a "variable" part, as in file.
1817 For example, in :samp:`print 1+{variable}`, the part variable
1818 would be emphasized.
1819
1820 If you don't need the "variable part" indication, use the stan‐
1821 dard ``code`` instead.
1822
1823 There is also an index role to generate index entries.
1824
1825 The following roles generate external links:
1826
1827 :pep: A reference to a Python Enhancement Proposal. This generates
1828 appropriate index entries. The text "PEP number" is generated;
1829 in the HTML output, this text is a hyperlink to an online copy
1830 of the specified PEP. You can link to a specific section by
1831 saying :pep:`number#anchor`.
1832
1833 :rfc: A reference to an Internet Request for Comments. This generates
1834 appropriate index entries. The text "RFC number" is generated;
1835 in the HTML output, this text is a hyperlink to an online copy
1836 of the specified RFC. You can link to a specific section by
1837 saying :rfc:`number#anchor`.
1838
1839 Note that there are no special roles for including hyperlinks as you
1840 can use the standard reST markup for that purpose.
1841
1842 Substitutions
1843 The documentation system provides three substitutions that are defined
1844 by default. They are set in the build configuration file.
1845
1846 |release|
1847 Replaced by the project release the documentation refers to.
1848 This is meant to be the full version string including
1849 alpha/beta/release candidate tags, e.g. 2.5.2b3. Set by
1850 release.
1851
1852 |version|
1853 Replaced by the project version the documentation refers to.
1854 This is meant to consist only of the major and minor version
1855 parts, e.g. 2.5, even for version 2.5.1. Set by version.
1856
1857 |today|
1858 Replaced by either today's date (the date on which the document
1859 is read), or the date set in the build configuration file. Nor‐
1860 mally has the format April 14, 2007. Set by today_fmt and
1861 today.
1862
1863 Miscellaneous markup
1864 File-wide metadata
1865 reST has the concept of "field lists"; these are a sequence of fields
1866 marked up like this:
1867
1868 :fieldname: Field content
1869
1870 A field list near the top of a file is parsed by docutils as the
1871 "docinfo" which is normally used to record the author, date of publica‐
1872 tion and other metadata. In Sphinx, a field list preceding any other
1873 markup is moved from the docinfo to the Sphinx environment as document
1874 metadata and is not displayed in the output; a field list appearing
1875 after the document title will be part of the docinfo as normal and will
1876 be displayed in the output.
1877
1878 At the moment, these metadata fields are recognized:
1879
1880 tocdepth
1881 The maximum depth for a table of contents of this file.
1882
1883 New in version 0.4.
1884
1885 nocomments
1886 If set, the web application won't display a comment form for a
1887 page generated from this source file.
1888
1889 orphan If set, warnings about this file not being included in any toc‐
1890 tree will be suppressed.
1891
1892 New in version 1.0.
1893
1894 Meta-information markup
1895 .. sectionauthor:: name <email>
1896 Identifies the author of the current section. The argument
1897 should include the author's name such that it can be used for
1898 presentation and email address. The domain name portion of the
1899 address should be lower case. Example:
1900
1901 .. sectionauthor:: Guido van Rossum <guido@python.org>
1902
1903 By default, this markup isn't reflected in the output in any way
1904 (it helps keep track of contributions), but you can set the con‐
1905 figuration value show_authors to True to make them produce a
1906 paragraph in the output.
1907
1908 .. codeauthor:: name <email>
1909 The codeauthor directive, which can appear multiple times, names
1910 the authors of the described code, just like sectionauthor names
1911 the author(s) of a piece of documentation. It too only produces
1912 output if the show_authors configuration value is True.
1913
1914 Index-generating markup
1915 Sphinx automatically creates index entries from all object descriptions
1916 (like functions, classes or attributes) like discussed in domains.
1917
1918 However, there is also explicit markup available, to make the index
1919 more comprehensive and enable index entries in documents where informa‐
1920 tion is not mainly contained in information units, such as the language
1921 reference.
1922
1923 .. index:: <entries>
1924 This directive contains one or more index entries. Each entry
1925 consists of a type and a value, separated by a colon.
1926
1927 For example:
1928
1929 .. index::
1930 single: execution; context
1931 module: __main__
1932 module: sys
1933 triple: module; search; path
1934
1935 The execution context
1936 ---------------------
1937
1938 ...
1939
1940 This directive contains five entries, which will be converted to
1941 entries in the generated index which link to the exact location
1942 of the index statement (or, in case of offline media, the corre‐
1943 sponding page number).
1944
1945 Since index directives generate cross-reference targets at their
1946 location in the source, it makes sense to put them before the
1947 thing they refer to -- e.g. a heading, as in the example above.
1948
1949 The possible entry types are:
1950
1951 single Creates a single index entry. Can be made a subentry by
1952 separating the subentry text with a semicolon (this nota‐
1953 tion is also used below to describe what entries are cre‐
1954 ated).
1955
1956 pair pair: loop; statement is a shortcut that creates two
1957 index entries, namely loop; statement and statement;
1958 loop.
1959
1960 triple Likewise, triple: module; search; path is a shortcut that
1961 creates three index entries, which are module; search
1962 path, search; path, module and path; module search.
1963
1964 see see: entry; other creates an index entry that refers from
1965 entry to other.
1966
1967 seealso
1968 Like see, but inserts "see also" instead of "see".
1969
1970 module, keyword, operator, object, exception, statement, builtin
1971 These all create two index entries. For example, module:
1972 hashlib creates the entries module; hashlib and hashlib;
1973 module. (These are Python-specific and therefore depre‐
1974 cated.)
1975
1976 You can mark up "main" index entries by prefixing them with an
1977 exclamation mark. The references to "main" entries are empha‐
1978 sized in the generated index. For example, if two pages contain
1979
1980 .. index:: Python
1981
1982 and one page contains
1983
1984 .. index:: ! Python
1985
1986 then the backlink to the latter page is emphasized among the
1987 three backlinks.
1988
1989 For index directives containing only "single" entries, there is
1990 a shorthand notation:
1991
1992 .. index:: BNF, grammar, syntax, notation
1993
1994 This creates four index entries.
1995
1996 Changed in version 1.1: Added see and seealso types, as well as
1997 marking main entries.
1998
1999 :index:
2000 While the index directive is a block-level markup and links to
2001 the beginning of the next paragraph, there is also a correspond‐
2002 ing role that sets the link target directly where it is used.
2003
2004 The content of the role can be a simple phrase, which is then
2005 kept in the text and used as an index entry. It can also be a
2006 combination of text and index entry, styled like with explicit
2007 targets of cross-references. In that case, the "target" part
2008 can be a full entry as described for the directive above. For
2009 example:
2010
2011 This is a normal reST :index:`paragraph` that contains several
2012 :index:`index entries <pair: index; entry>`.
2013
2014 New in version 1.1.
2015
2016 Including content based on tags
2017 .. only:: <expression>
2018 Include the content of the directive only if the expression is
2019 true. The expression should consist of tags, like this:
2020
2021 .. only:: html and draft
2022
2023 Undefined tags are false, defined tags (via the -t command-line
2024 option or within conf.py) are true. Boolean expressions, also
2025 using parentheses (like html and (latex or draft)) are sup‐
2026 ported.
2027
2028 The format of the current builder (html, latex or text) is
2029 always set as a tag.
2030
2031 NOTE:
2032 Due to docutils' specifics of parsing of directive content,
2033 you cannot put a section with the same level as the main doc‐
2034 ument heading inside an only directive. Such sections will
2035 appear to be ignored in the parsed document.
2036
2037 New in version 0.6.
2038
2039 Tables
2040 Use standard reStructuredText tables. They work fine in HTML output,
2041 however there are some gotchas when using tables in LaTeX: the column
2042 width is hard to determine correctly automatically. For this reason,
2043 the following directive exists:
2044
2045 .. tabularcolumns:: column spec
2046 This directive gives a "column spec" for the next table occur‐
2047 ring in the source file. The spec is the second argument to the
2048 LaTeX tabulary package's environment (which Sphinx uses to
2049 translate tables). It can have values like
2050
2051 |l|l|l|
2052
2053 which means three left-adjusted, nonbreaking columns. For col‐
2054 umns with longer text that should automatically be broken, use
2055 either the standard p{width} construct, or tabulary's automatic
2056 specifiers:
2057
2058 ┌──┬────────────────────────────┐
2059 │L │ ragged-left column with │
2060 │ │ automatic width │
2061 ├──┼────────────────────────────┤
2062 │R │ ragged-right column with │
2063 │ │ automatic width │
2064 ├──┼────────────────────────────┤
2065 │C │ centered column with auto‐ │
2066 │ │ matic width │
2067 ├──┼────────────────────────────┤
2068 │J │ justified column with │
2069 │ │ automatic width │
2070 └──┴────────────────────────────┘
2071
2072 The automatic width is determined by rendering the content in
2073 the table, and scaling them according to their share of the
2074 total width.
2075
2076 By default, Sphinx uses a table layout with L for every column.
2077
2078 New in version 0.3.
2079
2080 WARNING:
2081 Tables that contain list-like elements such as object descriptions,
2082 blockquotes or any kind of lists cannot be set out of the box with
2083 tabulary. They are therefore set with the standard LaTeX tabular
2084 environment if you don't give a tabularcolumns directive. If you
2085 do, the table will be set with tabulary, but you must use the
2086 p{width} construct for the columns that contain these elements.
2087
2088 Literal blocks do not work with tabulary at all, so tables contain‐
2089 ing a literal block are always set with tabular. Also, the verbatim
2090 environment used for literal blocks only works in p{width} columns,
2091 which means that by default, Sphinx generates such column specs for
2092 such tables. Use the tabularcolumns directive to get finer control
2093 over such tables.
2094
2095 More markup is added by domains.
2096
2098 New in version 1.0.
2099
2100 What is a Domain?
2101 Originally, Sphinx was conceived for a single project, the documenta‐
2102 tion of the Python language. Shortly afterwards, it was made available
2103 for everyone as a documentation tool, but the documentation of Python
2104 modules remained deeply built in -- the most fundamental directives,
2105 like function, were designed for Python objects. Since Sphinx has
2106 become somewhat popular, interest developed in using it for many dif‐
2107 ferent purposes: C/C++ projects, JavaScript, or even reStructuredText
2108 markup (like in this documentation).
2109
2110 While this was always possible, it is now much easier to easily support
2111 documentation of projects using different programming languages or even
2112 ones not supported by the main Sphinx distribution, by providing a
2113 domain for every such purpose.
2114
2115 A domain is a collection of markup (reStructuredText directives and
2116 roles) to describe and link to objects belonging together, e.g. ele‐
2117 ments of a programming language. Directive and role names in a domain
2118 have names like domain:name, e.g. py:function. Domains can also pro‐
2119 vide custom indices (like the Python Module Index).
2120
2121 Having domains means that there are no naming problems when one set of
2122 documentation wants to refer to e.g. C++ and Python classes. It also
2123 means that extensions that support the documentation of whole new lan‐
2124 guages are much easier to write.
2125
2126 This section describes what the domains that come with Sphinx provide.
2127 The domain API is documented as well, in the section domain-api.
2128
2129 Basic Markup
2130 Most domains provide a number of object description directives, used to
2131 describe specific objects provided by modules. Each directive requires
2132 one or more signatures to provide basic information about what is being
2133 described, and the content should be the description. The basic ver‐
2134 sion makes entries in the general index; if no index entry is desired,
2135 you can give the directive option flag :noindex:. An example using a
2136 Python domain directive:
2137
2138 .. py:function:: spam(eggs)
2139 ham(eggs)
2140
2141 Spam or ham the foo.
2142
2143 This describes the two Python functions spam and ham. (Note that when
2144 signatures become too long, you can break them if you add a backslash
2145 to lines that are continued in the next line. Example:
2146
2147 .. py:function:: filterwarnings(action, message='', category=Warning, \
2148 module='', lineno=0, append=False)
2149 :noindex:
2150
2151 (This example also shows how to use the :noindex: flag.)
2152
2153 The domains also provide roles that link back to these object descrip‐
2154 tions. For example, to link to one of the functions described in the
2155 example above, you could say
2156
2157 The function :py:func:`spam` does a similar thing.
2158
2159 As you can see, both directive and role names contain the domain name
2160 and the directive name. Default Domain
2161
2162 To avoid having to writing the domain name all the time when you e.g.
2163 only describe Python objects, a default domain can be selected with
2164 either the config value primary_domain or this directive:
2165
2166 .. default-domain:: name
2167 Select a new default domain. While the primary_domain selects a
2168 global default, this only has an effect within the same file.
2169
2170 If no other default is selected, the Python domain (named py) is the
2171 default one, mostly for compatibility with documentation written for
2172 older versions of Sphinx.
2173
2174 Directives and roles that belong to the default domain can be mentioned
2175 without giving the domain name, i.e.
2176
2177 .. function:: pyfunc()
2178
2179 Describes a Python function.
2180
2181 Reference to :func:`pyfunc`.
2182
2183 Cross-referencing syntax
2184 For cross-reference roles provided by domains, the same facilities
2185 exist as for general cross-references. See xref-syntax.
2186
2187 In short:
2188
2189 · You may supply an explicit title and reference target: :role:`title
2190 <target>` will refer to target, but the link text will be title.
2191
2192 · If you prefix the content with !, no reference/hyperlink will be cre‐
2193 ated.
2194
2195 · If you prefix the content with ~, the link text will only be the last
2196 component of the target. For example, :py:meth:`~Queue.Queue.get`
2197 will refer to Queue.Queue.get but only display get as the link text.
2198
2199 The Python Domain
2200 The Python domain (name py) provides the following directives for mod‐
2201 ule declarations:
2202
2203 .. py:module:: name
2204 This directive marks the beginning of the description of a mod‐
2205 ule (or package submodule, in which case the name should be
2206 fully qualified, including the package name). It does not cre‐
2207 ate content (like e.g. py:class does).
2208
2209 This directive will also cause an entry in the global module
2210 index.
2211
2212 The platform option, if present, is a comma-separated list of
2213 the platforms on which the module is available (if it is avail‐
2214 able on all platforms, the option should be omitted). The keys
2215 are short identifiers; examples that are in use include "IRIX",
2216 "Mac", "Windows", and "Unix". It is important to use a key
2217 which has already been used when applicable.
2218
2219 The synopsis option should consist of one sentence describing
2220 the module's purpose -- it is currently only used in the Global
2221 Module Index.
2222
2223 The deprecated option can be given (with no value) to mark a
2224 module as deprecated; it will be designated as such in various
2225 locations then.
2226
2227 .. py:currentmodule:: name
2228 This directive tells Sphinx that the classes, functions etc.
2229 documented from here are in the given module (like py:module),
2230 but it will not create index entries, an entry in the Global
2231 Module Index, or a link target for py:mod. This is helpful in
2232 situations where documentation for things in a module is spread
2233 over multiple files or sections -- one location has the py:mod‐
2234 ule directive, the others only py:currentmodule.
2235
2236 The following directives are provided for module and class contents:
2237
2238 .. py:data:: name
2239 Describes global data in a module, including both variables and
2240 values used as "defined constants." Class and object attributes
2241 are not documented using this environment.
2242
2243 .. py:exception:: name
2244 Describes an exception class. The signature can, but need not
2245 include parentheses with constructor arguments.
2246
2247 .. py:function:: name(signature)
2248 Describes a module-level function. The signature should include
2249 the parameters, enclosing optional parameters in brackets.
2250 Default values can be given if it enhances clarity; see signa‐
2251 tures. For example:
2252
2253 .. py:function:: Timer.repeat([repeat=3[, number=1000000]])
2254
2255 Object methods are not documented using this directive. Bound
2256 object methods placed in the module namespace as part of the
2257 public interface of the module are documented using this, as
2258 they are equivalent to normal functions for most purposes.
2259
2260 The description should include information about the parameters
2261 required and how they are used (especially whether mutable
2262 objects passed as parameters are modified), side effects, and
2263 possible exceptions. A small example may be provided.
2264
2265 .. py:class:: name[(signature)]
2266 Describes a class. The signature can include parentheses with
2267 parameters which will be shown as the constructor arguments.
2268 See also signatures.
2269
2270 Methods and attributes belonging to the class should be placed
2271 in this directive's body. If they are placed outside, the sup‐
2272 plied name should contain the class name so that cross-refer‐
2273 ences still work. Example:
2274
2275 .. py:class:: Foo
2276 .. py:method:: quux()
2277
2278 -- or --
2279
2280 .. py:class:: Bar
2281
2282 .. py:method:: Bar.quux()
2283
2284 The first way is the preferred one.
2285
2286 .. py:attribute:: name
2287 Describes an object data attribute. The description should
2288 include information about the type of the data to be expected
2289 and whether it may be changed directly.
2290
2291 .. py:method:: name(signature)
2292 Describes an object method. The parameters should not include
2293 the self parameter. The description should include similar
2294 information to that described for function. See also signa‐
2295 tures.
2296
2297 .. py:staticmethod:: name(signature)
2298 Like py:method, but indicates that the method is a static
2299 method.
2300
2301 New in version 0.4.
2302
2303 .. py:classmethod:: name(signature)
2304 Like py:method, but indicates that the method is a class method.
2305
2306 New in version 0.6.
2307
2308 .. py:decorator:: name
2309
2310 .. py:decorator:: name(signature)
2311 Describes a decorator function. The signature should not repre‐
2312 sent the signature of the actual function, but the usage as a
2313 decorator. For example, given the functions
2314
2315 def removename(func):
2316 func.__name__ = ''
2317 return func
2318
2319 def setnewname(name):
2320 def decorator(func):
2321 func.__name__ = name
2322 return func
2323 return decorator
2324
2325 the descriptions should look like this:
2326
2327 .. py:decorator:: removename
2328
2329 Remove name of the decorated function.
2330
2331 .. py:decorator:: setnewname(name)
2332
2333 Set name of the decorated function to *name*.
2334
2335 There is no py:deco role to link to a decorator that is marked
2336 up with this directive; rather, use the py:func role.
2337
2338 .. py:decoratormethod:: name
2339
2340 .. py:decoratormethod:: name(signature)
2341 Same as py:decorator, but for decorators that are methods.
2342
2343 Refer to a decorator method using the py:meth role.
2344
2345 Python Signatures
2346 Signatures of functions, methods and class constructors can be given
2347 like they would be written in Python, with the exception that optional
2348 parameters can be indicated by brackets:
2349
2350 .. py:function:: compile(source[, filename[, symbol]])
2351
2352 It is customary to put the opening bracket before the comma. In addi‐
2353 tion to this "nested" bracket style, a "flat" style can also be used,
2354 due to the fact that most optional parameters can be given indepen‐
2355 dently:
2356
2357 .. py:function:: compile(source[, filename, symbol])
2358
2359 Default values for optional arguments can be given (but if they contain
2360 commas, they will confuse the signature parser). Python 3-style argu‐
2361 ment annotations can also be given as well as return type annotations:
2362
2363 .. py:function:: compile(source : string[, filename, symbol]) -> ast object
2364
2365 Info field lists
2366 New in version 0.4.
2367
2368 Inside Python object description directives, reST field lists with
2369 these fields are recognized and formatted nicely:
2370
2371 · param, parameter, arg, argument, key, keyword: Description of a
2372 parameter.
2373
2374 · type: Type of a parameter.
2375
2376 · raises, raise, except, exception: That (and when) a specific excep‐
2377 tion is raised.
2378
2379 · var, ivar, cvar: Description of a variable.
2380
2381 · returns, return: Description of the return value.
2382
2383 · rtype: Return type.
2384
2385 The field names must consist of one of these keywords and an argument
2386 (except for returns and rtype, which do not need an argument). This is
2387 best explained by an example:
2388
2389 .. py:function:: format_exception(etype, value, tb[, limit=None])
2390
2391 Format the exception with a traceback.
2392
2393 :param etype: exception type
2394 :param value: exception value
2395 :param tb: traceback object
2396 :param limit: maximum number of stack frames to show
2397 :type limit: integer or None
2398 :rtype: list of strings
2399
2400 This will render like this:
2401
2402 format_exception(etype, value, tb[, limit=None])
2403 Format the exception with a traceback.
2404
2405 Parameters
2406
2407 · etype -- exception type
2408
2409 · value -- exception value
2410
2411 · tb -- traceback object
2412
2413 · limit (integer or None) -- maximum number of stack
2414 frames to show
2415
2416 Return type
2417 list of strings
2418
2419 It is also possible to combine parameter type and description, if the
2420 type is a single word, like this:
2421
2422 :param integer limit: maximum number of stack frames to show
2423
2424 Cross-referencing Python objects
2425 The following roles refer to objects in modules and are possibly hyper‐
2426 linked if a matching identifier is found:
2427
2428 :py:mod:
2429 Reference a module; a dotted name may be used. This should also
2430 be used for package names.
2431
2432 :py:func:
2433 Reference a Python function; dotted names may be used. The role
2434 text needs not include trailing parentheses to enhance readabil‐
2435 ity; they will be added automatically by Sphinx if the add_func‐
2436 tion_parentheses config value is true (the default).
2437
2438 :py:data:
2439 Reference a module-level variable.
2440
2441 :py:const:
2442 Reference a "defined" constant. This may be a C-language
2443 #define or a Python variable that is not intended to be changed.
2444
2445 :py:class:
2446 Reference a class; a dotted name may be used.
2447
2448 :py:meth:
2449 Reference a method of an object. The role text can include the
2450 type name and the method name; if it occurs within the descrip‐
2451 tion of a type, the type name can be omitted. A dotted name may
2452 be used.
2453
2454 :py:attr:
2455 Reference a data attribute of an object.
2456
2457 :py:exc:
2458 Reference an exception. A dotted name may be used.
2459
2460 :py:obj:
2461 Reference an object of unspecified type. Useful e.g. as the
2462 default_role.
2463
2464 New in version 0.4.
2465
2466 The name enclosed in this markup can include a module name and/or a
2467 class name. For example, :py:func:`filter` could refer to a function
2468 named filter in the current module, or the built-in function of that
2469 name. In contrast, :py:func:`foo.filter` clearly refers to the filter
2470 function in the foo module.
2471
2472 Normally, names in these roles are searched first without any further
2473 qualification, then with the current module name prepended, then with
2474 the current module and class name (if any) prepended. If you prefix
2475 the name with a dot, this order is reversed. For example, in the docu‐
2476 mentation of Python's codecs module, :py:func:`open` always refers to
2477 the built-in function, while :py:func:`.open` refers to codecs.open().
2478
2479 A similar heuristic is used to determine whether the name is an
2480 attribute of the currently documented class.
2481
2482 Also, if the name is prefixed with a dot, and no exact match is found,
2483 the target is taken as a suffix and all object names with that suffix
2484 are searched. For example, :py:meth:`.TarFile.close` references the
2485 tarfile.TarFile.close() function, even if the current module is not
2486 tarfile. Since this can get ambiguous, if there is more than one pos‐
2487 sible match, you will get a warning from Sphinx.
2488
2489 Note that you can combine the ~ and . prefixes:
2490 :py:meth:`~.TarFile.close` will reference the tarfile.TarFile.close()
2491 method, but the visible link caption will only be close().
2492
2493 The C Domain
2494 The C domain (name c) is suited for documentation of C API.
2495
2496 .. c:function:: type name(signature)
2497 Describes a C function. The signature should be given as in C,
2498 e.g.:
2499
2500 .. c:function:: PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
2501
2502 This is also used to describe function-like preprocessor macros.
2503 The names of the arguments should be given so they may be used
2504 in the description.
2505
2506 Note that you don't have to backslash-escape asterisks in the
2507 signature, as it is not parsed by the reST inliner.
2508
2509 .. c:member:: type name
2510 Describes a C struct member. Example signature:
2511
2512 .. c:member:: PyObject* PyTypeObject.tp_bases
2513
2514 The text of the description should include the range of values
2515 allowed, how the value should be interpreted, and whether the
2516 value can be changed. References to structure members in text
2517 should use the member role.
2518
2519 .. c:macro:: name
2520 Describes a "simple" C macro. Simple macros are macros which
2521 are used for code expansion, but which do not take arguments so
2522 cannot be described as functions. This is not to be used for
2523 simple constant definitions. Examples of its use in the Python
2524 documentation include PyObject_HEAD and Py_BEGIN_ALLOW_THREADS.
2525
2526 .. c:type:: name
2527 Describes a C type (whether defined by a typedef or struct). The
2528 signature should just be the type name.
2529
2530 .. c:var:: type name
2531 Describes a global C variable. The signature should include the
2532 type, such as:
2533
2534 .. c:var:: PyObject* PyClass_Type
2535
2536 Cross-referencing C constructs
2537 The following roles create cross-references to C-language constructs if
2538 they are defined in the documentation:
2539
2540 :c:data:
2541 Reference a C-language variable.
2542
2543 :c:func:
2544 Reference a C-language function. Should include trailing paren‐
2545 theses.
2546
2547 :c:macro:
2548 Reference a "simple" C macro, as defined above.
2549
2550 :c:type:
2551 Reference a C-language type.
2552
2553 The C++ Domain
2554 The C++ domain (name cpp) supports documenting C++ projects.
2555
2556 The following directives are available:
2557
2558 .. cpp:class:: signatures
2559
2560 .. cpp:function:: signatures
2561
2562 .. cpp:member:: signatures
2563
2564 .. cpp:type:: signatures
2565 Describe a C++ object. Full signature specification is sup‐
2566 ported -- give the signature as you would in the declaration.
2567 Here some examples:
2568
2569 .. cpp:function:: bool namespaced::theclass::method(int arg1, std::string arg2)
2570
2571 Describes a method with parameters and types.
2572
2573 .. cpp:function:: bool namespaced::theclass::method(arg1, arg2)
2574
2575 Describes a method without types.
2576
2577 .. cpp:function:: const T &array<T>::operator[]() const
2578
2579 Describes the constant indexing operator of a templated array.
2580
2581 .. cpp:function:: operator bool() const
2582
2583 Describe a casting operator here.
2584
2585 .. cpp:function:: constexpr void foo(std::string &bar[2]) noexcept
2586
2587 Describe a constexpr function here.
2588
2589 .. cpp:member:: std::string theclass::name
2590
2591 .. cpp:member:: std::string theclass::name[N][M]
2592
2593 .. cpp:type:: theclass::const_iterator
2594
2595 Will be rendered like this:
2596
2597 bool namespaced::theclass::method(int arg1, std::string arg2)
2598 Describes a method with parameters and types.
2599
2600 bool namespaced::theclass::method(arg1, arg2)
2601 Describes a method without types.
2602
2603 const T& array<T>::operator[]() const
2604 Describes the constant indexing operator of a tem‐
2605 plated array.
2606
2607 operator bool() const
2608 Describe a casting operator here.
2609
2610 constexpr void foo(std::string& bar[2]) noexcept
2611 Describe a constexpr function here.
2612
2613 std::string theclass::name
2614
2615 std::string theclass::name[N][M]
2616
2617 type theclass::const_iterator
2618
2619 .. cpp:namespace:: namespace
2620 Select the current C++ namespace for the following objects.
2621
2622 These roles link to the given object types:
2623
2624 :cpp:class:
2625
2626 :cpp:func:
2627
2628 :cpp:member:
2629
2630 :cpp:type:
2631 Reference a C++ object. You can give the full signature (and
2632 need to, for overloaded functions.)
2633
2634 NOTE:
2635 Sphinx' syntax to give references a custom title can inter‐
2636 fere with linking to template classes, if nothing follows the
2637 closing angle bracket, i.e. if the link looks like this:
2638 :cpp:class:`MyClass<T>`. This is interpreted as a link to T
2639 with a title of MyClass. In this case, please escape the
2640 opening angle bracket with a backslash, like this:
2641 :cpp:class:`MyClass\<T>`.
2642
2643 Note on References
2644
2645 It is currently impossible to link to a specific version of
2646 an overloaded method. Currently the C++ domain is the first
2647 domain that has basic support for overloaded methods and
2648 until there is more data for comparison we don't want to
2649 select a bad syntax to reference a specific overload. Cur‐
2650 rently Sphinx will link to the first overloaded version of
2651 the method / function.
2652
2653 The Standard Domain
2654 The so-called "standard" domain collects all markup that doesn't war‐
2655 rant a domain of its own. Its directives and roles are not prefixed
2656 with a domain name.
2657
2658 The standard domain is also where custom object descriptions, added
2659 using the add_object_type() API, are placed.
2660
2661 There is a set of directives allowing documenting command-line pro‐
2662 grams:
2663
2664 .. option:: name args, name args, ...
2665 Describes a command line option or switch. Option argument
2666 names should be enclosed in angle brackets. Example:
2667
2668 .. option:: -m <module>, --module <module>
2669
2670 Run a module as a script.
2671
2672 The directive will create a cross-reference target named after
2673 the first option, referencable by option (in the example case,
2674 you'd use something like :option:`-m`).
2675
2676 .. envvar:: name
2677 Describes an environment variable that the documented code or
2678 program uses or defines. Referencable by envvar.
2679
2680 .. program:: name
2681 Like py:currentmodule, this directive produces no output.
2682 Instead, it serves to notify Sphinx that all following option
2683 directives document options for the program called name.
2684
2685 If you use program, you have to qualify the references in your
2686 option roles by the program name, so if you have the following
2687 situation
2688
2689 .. program:: rm
2690
2691 .. option:: -r
2692
2693 Work recursively.
2694
2695 .. program:: svn
2696
2697 .. option:: -r revision
2698
2699 Specify the revision to work upon.
2700
2701 then :option:`rm -r` would refer to the first option, while
2702 :option:`svn -r` would refer to the second one.
2703
2704 The program name may contain spaces (in case you want to docu‐
2705 ment subcommands like svn add and svn commit separately).
2706
2707 New in version 0.5.
2708
2709 There is also a very generic object description directive, which is not
2710 tied to any domain:
2711
2712 .. describe:: text
2713
2714 .. object:: text
2715 This directive produces the same formatting as the specific ones
2716 provided by domains, but does not create index entries or
2717 cross-referencing targets. Example:
2718
2719 .. describe:: PAPER
2720
2721 You can set this variable to select a paper size.
2722
2723 The JavaScript Domain
2724 The JavaScript domain (name js) provides the following directives:
2725
2726 .. js:function:: name(signature)
2727 Describes a JavaScript function or method. If you want to
2728 describe arguments as optional use square brackets as documented
2729 for Python signatures.
2730
2731 You can use fields to give more details about arguments and
2732 their expected types, errors which may be thrown by the func‐
2733 tion, and the value being returned:
2734
2735 .. js:function:: $.getJSON(href, callback[, errback])
2736
2737 :param string href: An URI to the location of the resource.
2738 :param callback: Get's called with the object.
2739 :param errback:
2740 Get's called in case the request fails. And a lot of other
2741 text so we need multiple lines
2742 :throws SomeError: For whatever reason in that case.
2743 :returns: Something
2744
2745 This is rendered as:
2746
2747 $.getJSON(href, callback[, errback])
2748
2749 Arguments
2750
2751 · href (string) -- An URI to the location of
2752 the resource.
2753
2754 · callback -- Get's called with the object.
2755
2756 · errback -- Get's called in case the request
2757 fails. And a lot of other text so we need
2758 multiple lines.
2759
2760 Throws SomeError
2761 For whatever reason in that case.
2762
2763 Returns
2764 Something
2765
2766 .. js:class:: name
2767 Describes a constructor that creates an object. This is basi‐
2768 cally like a function but will show up with a class prefix:
2769
2770 .. js:class:: MyAnimal(name[, age])
2771
2772 :param string name: The name of the animal
2773 :param number age: an optional age for the animal
2774
2775 This is rendered as:
2776
2777 class MyAnimal(name[, age])
2778
2779 Arguments
2780
2781 · name (string) -- The name of the animal
2782
2783 · age (number) -- an optional age for the ani‐
2784 mal
2785
2786 .. js:data:: name
2787 Describes a global variable or constant.
2788
2789 .. js:attribute:: object.name
2790 Describes the attribute name of object.
2791
2792 These roles are provided to refer to the described objects:
2793
2794 :js:func:
2795
2796 :js:class:
2797
2798 :js:data:
2799
2800 :js:attr:
2801
2802 The reStructuredText domain
2803 The reStructuredText domain (name rst) provides the following direc‐
2804 tives:
2805
2806 .. rst:directive:: name
2807 Describes a reST directive. The name can be a single directive
2808 name or actual directive syntax (.. prefix and :: suffix) with
2809 arguments that will be rendered differently. For example:
2810
2811 .. rst:directive:: foo
2812
2813 Foo description.
2814
2815 .. rst:directive:: .. bar:: baz
2816
2817 Bar description.
2818
2819 will be rendered as:
2820
2821 .. foo::
2822 Foo description.
2823
2824 .. bar:: baz
2825 Bar description.
2826
2827 .. rst:role:: name
2828 Describes a reST role. For example:
2829
2830 .. rst:role:: foo
2831
2832 Foo description.
2833
2834 will be rendered as:
2835
2836 :foo: Foo description.
2837
2838 These roles are provided to refer to the described objects:
2839
2840 :rst:dir:
2841
2842 :rst:role:
2843
2844 More domains
2845 The sphinx-contrib repository contains more domains available as exten‐
2846 sions; currently a Ruby and an Erlang domain.
2847
2849 These are the built-in Sphinx builders. More builders can be added by
2850 extensions.
2851
2852 The builder's "name" must be given to the -b command-line option of
2853 sphinx-build to select a builder.
2854
2855 class sphinx.builders.html.StandaloneHTMLBuilder
2856 This is the standard HTML builder. Its output is a directory
2857 with HTML files, complete with style sheets and optionally the
2858 reST sources. There are quite a few configuration values that
2859 customize the output of this builder, see the chapter
2860 html-options for details.
2861
2862 Its name is html.
2863
2864 class sphinx.builders.html.DirectoryHTMLBuilder
2865 This is a subclass of the standard HTML builder. Its output is
2866 a directory with HTML files, where each file is called
2867 index.html and placed in a subdirectory named like its page
2868 name. For example, the document markup/rest.rst will not result
2869 in an output file markup/rest.html, but markup/rest/index.html.
2870 When generating links between pages, the index.html is omitted,
2871 so that the URL would look like markup/rest/.
2872
2873 Its name is dirhtml.
2874
2875 New in version 0.6.
2876
2877 class sphinx.builders.html.SingleFileHTMLBuilder
2878 This is an HTML builder that combines the whole project in one
2879 output file. (Obviously this only works with smaller projects.)
2880 The file is named like the master document. No indices will be
2881 generated.
2882
2883 Its name is singlehtml.
2884
2885 New in version 1.0.
2886
2887 class sphinx.builders.htmlhelp.HTMLHelpBuilder
2888 This builder produces the same output as the standalone HTML
2889 builder, but also generates HTML Help support files that allow
2890 the Microsoft HTML Help Workshop to compile them into a CHM
2891 file.
2892
2893 Its name is htmlhelp.
2894
2895 class sphinx.builders.qthelp.QtHelpBuilder
2896 This builder produces the same output as the standalone HTML
2897 builder, but also generates Qt help collection support files
2898 that allow the Qt collection generator to compile them.
2899
2900 Its name is qthelp.
2901
2902 class sphinx.builders.devhelp.DevhelpBuilder
2903 This builder produces the same output as the standalone HTML
2904 builder, but also generates GNOME Devhelp support file that
2905 allows the GNOME Devhelp reader to view them.
2906
2907 Its name is devhelp.
2908
2909 class sphinx.builders.epub.EpubBuilder
2910 This builder produces the same output as the standalone HTML
2911 builder, but also generates an epub file for ebook readers. See
2912 epub-faq for details about it. For definition of the epub for‐
2913 mat, have a look at http://www.idpf.org/specs.htm or
2914 http://en.wikipedia.org/wiki/EPUB.
2915
2916 Some ebook readers do not show the link targets of references.
2917 Therefore this builder adds the targets after the link when nec‐
2918 essary. The display of the URLs can be customized by adding CSS
2919 rules for the class link-target.
2920
2921 Its name is epub.
2922
2923 class sphinx.builders.latex.LaTeXBuilder
2924 This builder produces a bunch of LaTeX files in the output
2925 directory. You have to specify which documents are to be
2926 included in which LaTeX files via the latex_documents configura‐
2927 tion value. There are a few configuration values that customize
2928 the output of this builder, see the chapter latex-options for
2929 details.
2930
2931 NOTE:
2932 The produced LaTeX file uses several LaTeX packages that may
2933 not be present in a "minimal" TeX distribution installation.
2934 For TeXLive, the following packages need to be installed:
2935
2936 · latex-recommended
2937
2938 · latex-extra
2939
2940 · fonts-recommended
2941
2942 Its name is latex.
2943
2944 Note that a direct PDF builder using ReportLab is available in rst2pdf
2945 version 0.12 or greater. You need to add 'rst2pdf.pdfbuilder' to your
2946 extensions to enable it, its name is pdf. Refer to the rst2pdf manual
2947 for details.
2948
2949 class sphinx.builders.text.TextBuilder
2950 This builder produces a text file for each reST file -- this is
2951 almost the same as the reST source, but with much of the markup
2952 stripped for better readability.
2953
2954 Its name is text.
2955
2956 New in version 0.4.
2957
2958 class sphinx.builders.manpage.ManualPageBuilder
2959 This builder produces manual pages in the groff format. You
2960 have to specify which documents are to be included in which man‐
2961 ual pages via the man_pages configuration value.
2962
2963 Its name is man.
2964
2965 NOTE:
2966 This builder requires the docutils manual page writer, which
2967 is only available as of docutils 0.6.
2968
2969 New in version 1.0.
2970
2971 class sphinx.builders.texinfo.TexinfoBuilder
2972 This builder produces Texinfo files that can be processed into
2973 Info files by the makeinfo program. You have to specify which
2974 documents are to be included in which Texinfo files via the tex‐
2975 info_documents configuration value.
2976
2977 The Info format is the basis of the on-line help system used by
2978 GNU Emacs and the terminal-based program info. See texinfo-faq
2979 for more details. The Texinfo format is the official documenta‐
2980 tion system used by the GNU project. More information on Tex‐
2981 info can be found at http://www.gnu.org/software/texinfo/.
2982
2983 Its name is texinfo.
2984
2985 New in version 1.1.
2986
2987 class sphinx.builders.html.SerializingHTMLBuilder
2988 This builder uses a module that implements the Python serializa‐
2989 tion API (pickle, simplejson, phpserialize, and others) to dump
2990 the generated HTML documentation. The pickle builder is a sub‐
2991 class of it.
2992
2993 A concrete subclass of this builder serializing to the PHP seri‐
2994 alization format could look like this:
2995
2996 import phpserialize
2997
2998 class PHPSerializedBuilder(SerializingHTMLBuilder):
2999 name = 'phpserialized'
3000 implementation = phpserialize
3001 out_suffix = '.file.phpdump'
3002 globalcontext_filename = 'globalcontext.phpdump'
3003 searchindex_filename = 'searchindex.phpdump'
3004
3005 implementation
3006 A module that implements dump(), load(), dumps() and
3007 loads() functions that conform to the functions with the
3008 same names from the pickle module. Known modules imple‐
3009 menting this interface are simplejson (or json in Python
3010 2.6), phpserialize, plistlib, and others.
3011
3012 out_suffix
3013 The suffix for all regular files.
3014
3015 globalcontext_filename
3016 The filename for the file that contains the "global con‐
3017 text". This is a dict with some general configuration
3018 values such as the name of the project.
3019
3020 searchindex_filename
3021 The filename for the search index Sphinx generates.
3022
3023 See serialization-details for details about the output format.
3024
3025 New in version 0.5.
3026
3027 class sphinx.builders.html.PickleHTMLBuilder
3028 This builder produces a directory with pickle files containing
3029 mostly HTML fragments and TOC information, for use of a web
3030 application (or custom postprocessing tool) that doesn't use the
3031 standard HTML templates.
3032
3033 See serialization-details for details about the output format.
3034
3035 Its name is pickle. (The old name web still works as well.)
3036
3037 The file suffix is .fpickle. The global context is called glob‐
3038 alcontext.pickle, the search index searchindex.pickle.
3039
3040 class sphinx.builders.html.JSONHTMLBuilder
3041 This builder produces a directory with JSON files containing
3042 mostly HTML fragments and TOC information, for use of a web
3043 application (or custom postprocessing tool) that doesn't use the
3044 standard HTML templates.
3045
3046 See serialization-details for details about the output format.
3047
3048 Its name is json.
3049
3050 The file suffix is .fjson. The global context is called global‐
3051 context.json, the search index searchindex.json.
3052
3053 New in version 0.5.
3054
3055 class sphinx.builders.gettext.MessageCatalogBuilder
3056 This builder produces gettext-style message catalogs. Each
3057 top-level file or subdirectory grows a single .pot catalog tem‐
3058 plate.
3059
3060 See the documentation on intl for further reference.
3061
3062 Its name is gettext.
3063
3064 New in version 1.1.
3065
3066 class sphinx.builders.changes.ChangesBuilder
3067 This builder produces an HTML overview of all versionadded, ver‐
3068 sionchanged and deprecated directives for the current version.
3069 This is useful to generate a ChangeLog file, for example.
3070
3071 Its name is changes.
3072
3073 class sphinx.builders.linkcheck.CheckExternalLinksBuilder
3074 This builder scans all documents for external links, tries to
3075 open them with urllib2, and writes an overview which ones are
3076 broken and redirected to standard output and to output.txt in
3077 the output directory.
3078
3079 Its name is linkcheck.
3080
3081 Built-in Sphinx extensions that offer more builders are:
3082
3083 · doctest
3084
3085 · coverage
3086
3087 Serialization builder details
3088 All serialization builders outputs one file per source file and a few
3089 special files. They also copy the reST source files in the directory
3090 _sources under the output directory.
3091
3092 The PickleHTMLBuilder is a builtin subclass that implements the pickle
3093 serialization interface.
3094
3095 The files per source file have the extensions of out_suffix, and are
3096 arranged in directories just as the source files are. They unserialize
3097 to a dictionary (or dictionary like structure) with these keys:
3098
3099 body The HTML "body" (that is, the HTML rendering of the source
3100 file), as rendered by the HTML translator.
3101
3102 title The title of the document, as HTML (may contain markup).
3103
3104 toc The table of contents for the file, rendered as an HTML <ul>.
3105
3106 display_toc
3107 A boolean that is True if the toc contains more than one entry.
3108
3109 current_page_name
3110 The document name of the current file.
3111
3112 parents, prev and next
3113 Information about related chapters in the TOC tree. Each rela‐
3114 tion is a dictionary with the keys link (HREF for the relation)
3115 and title (title of the related document, as HTML). parents is
3116 a list of relations, while prev and next are a single relation.
3117
3118 sourcename
3119 The name of the source file under _sources.
3120
3121 The special files are located in the root output directory. They are:
3122
3123 SerializingHTMLBuilder.globalcontext_filename
3124 A pickled dict with these keys:
3125
3126 project, copyright, release, version
3127 The same values as given in the configuration file.
3128
3129 style html_style.
3130
3131 last_updated
3132 Date of last build.
3133
3134 builder
3135 Name of the used builder, in the case of pickles this is
3136 always 'pickle'.
3137
3138 titles A dictionary of all documents' titles, as HTML strings.
3139
3140 SerializingHTMLBuilder.searchindex_filename
3141 An index that can be used for searching the documentation. It
3142 is a pickled list with these entries:
3143
3144 · A list of indexed docnames.
3145
3146 · A list of document titles, as HTML strings, in the same order
3147 as the first list.
3148
3149 · A dict mapping word roots (processed by an English-language
3150 stemmer) to a list of integers, which are indices into the
3151 first list.
3152
3153 environment.pickle
3154 The build environment. This is always a pickle file, indepen‐
3155 dent of the builder and a copy of the environment that was used
3156 when the builder was started.
3157
3158 Todo
3159 Document common members.
3160
3161 Unlike the other pickle files this pickle file requires that the
3162 sphinx package is available on unpickling.
3163
3165 The configuration directory must contain a file named conf.py. This
3166 file (containing Python code) is called the "build configuration file"
3167 and contains all configuration needed to customize Sphinx input and
3168 output behavior.
3169
3170 The configuration file is executed as Python code at build time (using
3171 execfile(), and with the current directory set to its containing direc‐
3172 tory), and therefore can execute arbitrarily complex code. Sphinx then
3173 reads simple names from the file's namespace as its configuration.
3174
3175 Important points to note:
3176
3177 · If not otherwise documented, values must be strings, and their
3178 default is the empty string.
3179
3180 · The term "fully-qualified name" refers to a string that names an
3181 importable Python object inside a module; for example, the FQN
3182 "sphinx.builders.Builder" means the Builder class in the
3183 sphinx.builders module.
3184
3185 · Remember that document names use / as the path separator and don't
3186 contain the file name extension.
3187
3188 · Since conf.py is read as a Python file, the usual rules apply for
3189 encodings and Unicode support: declare the encoding using an encoding
3190 cookie (a comment like # -*- coding: utf-8 -*-) and use Unicode
3191 string literals when you include non-ASCII characters in configura‐
3192 tion values.
3193
3194 · The contents of the config namespace are pickled (so that Sphinx can
3195 find out when configuration changes), so it may not contain unpick‐
3196 leable values -- delete them from the namespace with del if appropri‐
3197 ate. Modules are removed automatically, so you don't need to del
3198 your imports after use.
3199
3200 · There is a special object named tags available in the config file.
3201 It can be used to query and change the tags (see tags). Use
3202 tags.has('tag') to query, tags.add('tag') and tags.remove('tag') to
3203 change.
3204
3205 General configuration
3206 extensions
3207 A list of strings that are module names of Sphinx extensions.
3208 These can be extensions coming with Sphinx (named sphinx.ext.*)
3209 or custom ones.
3210
3211 Note that you can extend sys.path within the conf file if your
3212 extensions live in another directory -- but make sure you use
3213 absolute paths. If your extension path is relative to the con‐
3214 figuration directory, use os.path.abspath() like so:
3215
3216 import sys, os
3217
3218 sys.path.append(os.path.abspath('sphinxext'))
3219
3220 extensions = ['extname']
3221
3222 That way, you can load an extension called extname from the sub‐
3223 directory sphinxext.
3224
3225 The configuration file itself can be an extension; for that, you
3226 only need to provide a setup() function in it.
3227
3228 source_suffix
3229 The file name extension of source files. Only files with this
3230 suffix will be read as sources. Default is '.rst'.
3231
3232 source_encoding
3233 The encoding of all reST source files. The recommended encod‐
3234 ing, and the default value, is 'utf-8-sig'.
3235
3236 New in version 0.5: Previously, Sphinx accepted only UTF-8
3237 encoded sources.
3238
3239 master_doc
3240 The document name of the "master" document, that is, the docu‐
3241 ment that contains the root toctree directive. Default is 'con‐
3242 tents'.
3243
3244 exclude_patterns
3245 A list of glob-style patterns that should be excluded when look‐
3246 ing for source files. [1] They are matched against the source
3247 file names relative to the source directory, using slashes as
3248 directory separators on all platforms.
3249
3250 Example patterns:
3251
3252 · 'library/xml.rst' -- ignores the library/xml.rst file
3253 (replaces entry in unused_docs)
3254
3255 · 'library/xml' -- ignores the library/xml directory (replaces
3256 entry in exclude_trees)
3257
3258 · 'library/xml*' -- ignores all files and directories starting
3259 with library/xml
3260
3261 · '**/.svn' -- ignores all .svn directories (replaces entry in
3262 exclude_dirnames)
3263
3264 exclude_patterns is also consulted when looking for static files
3265 in html_static_path.
3266
3267 New in version 1.0.
3268
3269 unused_docs
3270 A list of document names that are present, but not currently
3271 included in the toctree. Use this setting to suppress the warn‐
3272 ing that is normally emitted in that case.
3273
3274 Deprecated since version 1.0: Use exclude_patterns instead.
3275
3276 exclude_trees
3277 A list of directory paths, relative to the source directory,
3278 that are to be recursively excluded from the search for source
3279 files, that is, their subdirectories won't be searched too. The
3280 default is [].
3281
3282 New in version 0.4.
3283
3284 Deprecated since version 1.0: Use exclude_patterns instead.
3285
3286 exclude_dirnames
3287 A list of directory names that are to be excluded from any
3288 recursive operation Sphinx performs (e.g. searching for source
3289 files or copying static files). This is useful, for example, to
3290 exclude version-control-specific directories like 'CVS'. The
3291 default is [].
3292
3293 New in version 0.5.
3294
3295 Deprecated since version 1.0: Use exclude_patterns instead.
3296
3297 templates_path
3298 A list of paths that contain extra templates (or templates that
3299 overwrite builtin/theme-specific templates). Relative paths are
3300 taken as relative to the configuration directory.
3301
3302 template_bridge
3303 A string with the fully-qualified name of a callable (or simply
3304 a class) that returns an instance of TemplateBridge. This
3305 instance is then used to render HTML documents, and possibly the
3306 output of other builders (currently the changes builder). (Note
3307 that the template bridge must be made theme-aware if HTML themes
3308 are to be used.)
3309
3310 rst_epilog
3311 A string of reStructuredText that will be included at the end of
3312 every source file that is read. This is the right place to add
3313 substitutions that should be available in every file. An exam‐
3314 ple:
3315
3316 rst_epilog = """
3317 .. |psf| replace:: Python Software Foundation
3318 """
3319
3320 New in version 0.6.
3321
3322 rst_prolog
3323 A string of reStructuredText that will be included at the begin‐
3324 ning of every source file that is read.
3325
3326 New in version 1.0.
3327
3328 primary_domain
3329 The name of the default domain. Can also be None to disable a
3330 default domain. The default is 'py'. Those objects in other
3331 domains (whether the domain name is given explicitly, or
3332 selected by a default-domain directive) will have the domain
3333 name explicitly prepended when named (e.g., when the default
3334 domain is C, Python functions will be named "Python function",
3335 not just "function").
3336
3337 New in version 1.0.
3338
3339 default_role
3340 The name of a reST role (builtin or Sphinx extension) to use as
3341 the default role, that is, for text marked up `like this`. This
3342 can be set to 'py:obj' to make `filter` a cross-reference to the
3343 Python function "filter". The default is None, which doesn't
3344 reassign the default role.
3345
3346 The default role can always be set within individual documents
3347 using the standard reST default-role directive.
3348
3349 New in version 0.4.
3350
3351 keep_warnings
3352 If true, keep warnings as "system message" paragraphs in the
3353 built documents. Regardless of this setting, warnings are
3354 always written to the standard error stream when sphinx-build is
3355 run.
3356
3357 The default is False, the pre-0.5 behavior was to always keep
3358 them.
3359
3360 New in version 0.5.
3361
3362 needs_sphinx
3363 If set to a major.minor version string like '1.1', Sphinx will
3364 compare it with its version and refuse to build if it is too
3365 old. Default is no requirement.
3366
3367 New in version 1.0.
3368
3369 nitpicky
3370 If true, Sphinx will warn about all references where the target
3371 cannot be found. Default is False. You can activate this mode
3372 temporarily using the -n command-line switch.
3373
3374 New in version 1.0.
3375
3376 nitpick_ignore
3377 A list of (type, target) tuples (by default empty) that should
3378 be ignored when generating warnings in "nitpicky mode". Note
3379 that type should include the domain name. An example entry
3380 would be ('py:func', 'int').
3381
3382 New in version 1.1.
3383
3384 Project information
3385 project
3386 The documented project's name.
3387
3388 copyright
3389 A copyright statement in the style '2008, Author Name'.
3390
3391 version
3392 The major project version, used as the replacement for |ver‐
3393 sion|. For example, for the Python documentation, this may be
3394 something like 2.6.
3395
3396 release
3397 The full project version, used as the replacement for |release|
3398 and e.g. in the HTML templates. For example, for the Python
3399 documentation, this may be something like 2.6.0rc1.
3400
3401 If you don't need the separation provided between version and
3402 release, just set them both to the same value.
3403
3404 today
3405
3406 today_fmt
3407 These values determine how to format the current date, used as
3408 the replacement for |today|.
3409
3410 · If you set today to a non-empty value, it is used.
3411
3412 · Otherwise, the current time is formatted using time.strftime()
3413 and the format given in today_fmt.
3414
3415 The default is no today and a today_fmt of '%B %d, %Y' (or, if
3416 translation is enabled with language, am equivalent %format for
3417 the selected locale).
3418
3419 highlight_language
3420 The default language to highlight source code in. The default
3421 is 'python'. The value should be a valid Pygments lexer name,
3422 see code-examples for more details.
3423
3424 New in version 0.5.
3425
3426 pygments_style
3427 The style name to use for Pygments highlighting of source code.
3428 The default style is selected by the theme for HTML output, and
3429 'sphinx' otherwise.
3430
3431 Changed in version 0.3: If the value is a fully-qualified name
3432 of a custom Pygments style class, this is then used as custom
3433 style.
3434
3435 add_function_parentheses
3436 A boolean that decides whether parentheses are appended to func‐
3437 tion and method role text (e.g. the content of :func:`input`) to
3438 signify that the name is callable. Default is True.
3439
3440 add_module_names
3441 A boolean that decides whether module names are prepended to all
3442 object names (for object types where a "module" of some kind is
3443 defined), e.g. for py:function directives. Default is True.
3444
3445 show_authors
3446 A boolean that decides whether codeauthor and sectionauthor
3447 directives produce any output in the built files.
3448
3449 modindex_common_prefix
3450 A list of prefixes that are ignored for sorting the Python mod‐
3451 ule index (e.g., if this is set to ['foo.'], then foo.bar is
3452 shown under B, not F). This can be handy if you document a
3453 project that consists of a single package. Works only for the
3454 HTML builder currently. Default is [].
3455
3456 New in version 0.6.
3457
3458 trim_footnote_reference_space
3459 Trim spaces before footnote references that are necessary for
3460 the reST parser to recognize the footnote, but do not look too
3461 nice in the output.
3462
3463 New in version 0.6.
3464
3465 trim_doctest_flags
3466 If true, doctest flags (comments looking like # doctest: FLAG,
3467 ...) at the ends of lines and <BLANKLINE> markers are removed
3468 for all code blocks showing interactive Python sessions (i.e.
3469 doctests). Default is true. See the extension doctest for more
3470 possibilities of including doctests.
3471
3472 New in version 1.0.
3473
3474 Changed in version 1.1: Now also removes <BLANKLINE>.
3475
3476 Options for internationalization
3477 These options influence Sphinx' Native Language Support. See the docu‐
3478 mentation on intl for details.
3479
3480 language
3481 The code for the language the docs are written in. Any text
3482 automatically generated by Sphinx will be in that language.
3483 Also, Sphinx will try to substitute individual paragraphs from
3484 your documents with the translation sets obtained from
3485 locale_dirs. In the LaTeX builder, a suitable language will be
3486 selected as an option for the Babel package. Default is None,
3487 which means that no translation will be done.
3488
3489 New in version 0.5.
3490
3491 Currently supported languages by Sphinx are:
3492
3493 · bn -- Bengali
3494
3495 · ca -- Catalan
3496
3497 · cs -- Czech
3498
3499 · da -- Danish
3500
3501 · de -- German
3502
3503 · en -- English
3504
3505 · es -- Spanish
3506
3507 · et -- Estonian
3508
3509 · fa -- Iranian
3510
3511 · fi -- Finnish
3512
3513 · fr -- French
3514
3515 · hr -- Croatian
3516
3517 · it -- Italian
3518
3519 · ja -- Japanese
3520
3521 · ko -- Korean
3522
3523 · lt -- Lithuanian
3524
3525 · lv -- Latvian
3526
3527 · ne -- Nepali
3528
3529 · nl -- Dutch
3530
3531 · pl -- Polish
3532
3533 · pt_BR -- Brazilian Portuguese
3534
3535 · ru -- Russian
3536
3537 · sl -- Slovenian
3538
3539 · sv -- Swedish
3540
3541 · tr -- Turkish
3542
3543 · uk_UA -- Ukrainian
3544
3545 · zh_CN -- Simplified Chinese
3546
3547 · zh_TW -- Traditional Chinese
3548
3549 locale_dirs
3550 New in version 0.5.
3551
3552 Directories in which to search for additional message catalogs
3553 (see language), relative to the source directory. The directo‐
3554 ries on this path are searched by the standard gettext module.
3555
3556 Internal messages are fetched from a text domain of sphinx; so
3557 if you add the directory ./locale to this settting, the message
3558 catalogs (compiled from .po format using msgfmt) must be in
3559 ./locale/language/LC_MESSAGES/sphinx.mo. The text domain of
3560 individual documents depends on gettext_compact.
3561
3562 The default is [].
3563
3564 gettext_compact
3565 New in version 1.1.
3566
3567 If true, a document's text domain is its docname if it is a
3568 top-level project file and its very base directory otherwise.
3569
3570 By default, the document markup/code.rst ends up in the markup
3571 text domain. With this option set to False, it is markup/code.
3572
3573 Options for HTML output
3574 These options influence HTML as well as HTML Help output, and other
3575 builders that use Sphinx' HTMLWriter class.
3576
3577 html_theme
3578 The "theme" that the HTML output should use. See the section
3579 about theming. The default is 'default'.
3580
3581 New in version 0.6.
3582
3583 html_theme_options
3584 A dictionary of options that influence the look and feel of the
3585 selected theme. These are theme-specific. For the options
3586 understood by the builtin themes, see this section.
3587
3588 New in version 0.6.
3589
3590 html_theme_path
3591 A list of paths that contain custom themes, either as subdirec‐
3592 tories or as zip files. Relative paths are taken as relative to
3593 the configuration directory.
3594
3595 New in version 0.6.
3596
3597 html_style
3598 The style sheet to use for HTML pages. A file of that name must
3599 exist either in Sphinx' static/ path, or in one of the custom
3600 paths given in html_static_path. Default is the stylesheet
3601 given by the selected theme. If you only want to add or over‐
3602 ride a few things compared to the theme's stylesheet, use CSS
3603 @import to import the theme's stylesheet.
3604
3605 html_title
3606 The "title" for HTML documentation generated with Sphinx' own
3607 templates. This is appended to the <title> tag of individual
3608 pages, and used in the navigation bar as the "topmost" element.
3609 It defaults to '<project> v<revision> documentation', where the
3610 placeholders are replaced by the config values of the same name.
3611
3612 html_short_title
3613 A shorter "title" for the HTML docs. This is used in for links
3614 in the header and in the HTML Help docs. If not given, it
3615 defaults to the value of html_title.
3616
3617 New in version 0.4.
3618
3619 html_context
3620 A dictionary of values to pass into the template engine's con‐
3621 text for all pages. Single values can also be put in this dic‐
3622 tionary using the -A command-line option of sphinx-build.
3623
3624 New in version 0.5.
3625
3626 html_logo
3627 If given, this must be the name of an image file that is the
3628 logo of the docs. It is placed at the top of the sidebar; its
3629 width should therefore not exceed 200 pixels. Default: None.
3630
3631 New in version 0.4.1: The image file will be copied to the
3632 _static directory of the output HTML, so an already existing
3633 file with that name will be overwritten.
3634
3635 html_favicon
3636 If given, this must be the name of an image file (within the
3637 static path, see below) that is the favicon of the docs. Modern
3638 browsers use this as icon for tabs, windows and bookmarks. It
3639 should be a Windows-style icon file (.ico), which is 16x16 or
3640 32x32 pixels large. Default: None.
3641
3642 New in version 0.4.
3643
3644 html_static_path
3645 A list of paths that contain custom static files (such as style
3646 sheets or script files). Relative paths are taken as relative
3647 to the configuration directory. They are copied to the output
3648 directory after the theme's static files, so a file named
3649 default.css will overwrite the theme's default.css.
3650
3651 Changed in version 0.4: The paths in html_static_path can now
3652 contain subdirectories.
3653
3654 Changed in version 1.0: The entries in html_static_path can now
3655 be single files.
3656
3657 html_last_updated_fmt
3658 If this is not the empty string, a 'Last updated on:' timestamp
3659 is inserted at every page bottom, using the given strftime()
3660 format. Default is '%b %d, %Y' (or a locale-dependent equiva‐
3661 lent).
3662
3663 html_use_smartypants
3664 If true, SmartyPants will be used to convert quotes and dashes
3665 to typographically correct entities. Default: True.
3666
3667 html_add_permalinks
3668 Sphinx will add "permalinks" for each heading and description
3669 environment as paragraph signs that become visible when the
3670 mouse hovers over them.
3671
3672 This value determines the text for the permalink; it defaults to
3673 "¶". Set it to None or the empty string to disable permalinks.
3674
3675 New in version 0.6: Previously, this was always activated.
3676
3677 Changed in version 1.1: This can now be a string to select the
3678 actual text of the link. Previously, only boolean values were
3679 accepted.
3680
3681 html_sidebars
3682 Custom sidebar templates, must be a dictionary that maps docu‐
3683 ment names to template names.
3684
3685 The keys can contain glob-style patterns [1], in which case all
3686 matching documents will get the specified sidebars. (A warning
3687 is emitted when a more than one glob-style pattern matches for
3688 any document.)
3689
3690 The values can be either lists or single strings.
3691
3692 · If a value is a list, it specifies the complete list of side‐
3693 bar templates to include. If all or some of the default side‐
3694 bars are to be included, they must be put into this list as
3695 well.
3696
3697 The default sidebars (for documents that don't match any pat‐
3698 tern) are: ['localtoc.html', 'relations.html',
3699 'sourcelink.html', 'searchbox.html'].
3700
3701 · If a value is a single string, it specifies a custom sidebar
3702 to be added between the 'sourcelink.html' and 'searchbox.html'
3703 entries. This is for compatibility with Sphinx versions
3704 before 1.0.
3705
3706 Builtin sidebar templates that can be rendered are:
3707
3708 · localtoc.html -- a fine-grained table of contents of the cur‐
3709 rent document
3710
3711 · globaltoc.html -- a coarse-grained table of contents for the
3712 whole documentation set, collapsed
3713
3714 · relations.html -- two links to the previous and next documents
3715
3716 · sourcelink.html -- a link to the source of the current docu‐
3717 ment, if enabled in html_show_sourcelink
3718
3719 · searchbox.html -- the "quick search" box
3720
3721 Example:
3722
3723 html_sidebars = {
3724 '**': ['globaltoc.html', 'sourcelink.html', 'searchbox.html'],
3725 'using/windows': ['windowssidebar.html', 'searchbox.html'],
3726 }
3727
3728 This will render the custom template windowssidebar.html and the
3729 quick search box within the sidebar of the given document, and
3730 render the default sidebars for all other pages (except that the
3731 local TOC is replaced by the global TOC).
3732
3733 New in version 1.0: The ability to use globbing keys and to
3734 specify multiple sidebars.
3735
3736 Note that this value only has no effect if the chosen theme does
3737 not possess a sidebar, like the builtin scrolls and haiku
3738 themes.
3739
3740 html_additional_pages
3741 Additional templates that should be rendered to HTML pages, must
3742 be a dictionary that maps document names to template names.
3743
3744 Example:
3745
3746 html_additional_pages = {
3747 'download': 'customdownload.html',
3748 }
3749
3750 This will render the template customdownload.html as the page
3751 download.html.
3752
3753 html_domain_indices
3754 If true, generate domain-specific indices in addition to the
3755 general index. For e.g. the Python domain, this is the global
3756 module index. Default is True.
3757
3758 This value can be a bool or a list of index names that should be
3759 generated. To find out the index name for a specific index,
3760 look at the HTML file name. For example, the Python module
3761 index has the name 'py-modindex'.
3762
3763 New in version 1.0.
3764
3765 html_use_modindex
3766 If true, add a module index to the HTML documents. Default is
3767 True.
3768
3769 Deprecated since version 1.0: Use html_domain_indices.
3770
3771 html_use_index
3772 If true, add an index to the HTML documents. Default is True.
3773
3774 New in version 0.4.
3775
3776 html_split_index
3777 If true, the index is generated twice: once as a single page
3778 with all the entries, and once as one page per starting letter.
3779 Default is False.
3780
3781 New in version 0.4.
3782
3783 html_copy_source
3784 If true, the reST sources are included in the HTML build as
3785 _sources/name. The default is True.
3786
3787 WARNING:
3788 If this config value is set to False, the JavaScript search
3789 function will only display the titles of matching documents,
3790 and no excerpt from the matching contents.
3791
3792 html_show_sourcelink
3793 If true (and html_copy_source is true as well), links to the
3794 reST sources will be added to the sidebar. The default is True.
3795
3796 New in version 0.6.
3797
3798 html_use_opensearch
3799 If nonempty, an OpenSearch <http://opensearch.org> description
3800 file will be output, and all pages will contain a <link> tag
3801 referring to it. Since OpenSearch doesn't support relative URLs
3802 for its search page location, the value of this option must be
3803 the base URL from which these documents are served (without
3804 trailing slash), e.g. "http://docs.python.org". The default is
3805 ''.
3806
3807 html_file_suffix
3808 This is the file name suffix for generated HTML files. The
3809 default is ".html".
3810
3811 New in version 0.4.
3812
3813 html_link_suffix
3814 Suffix for generated links to HTML files. The default is what‐
3815 ever html_file_suffix is set to; it can be set differently (e.g.
3816 to support different web server setups).
3817
3818 New in version 0.6.
3819
3820 html_translator_class
3821 A string with the fully-qualified name of a HTML Translator
3822 class, that is, a subclass of Sphinx' HTMLTranslator, that is
3823 used to translate document trees to HTML. Default is None (use
3824 the builtin translator).
3825
3826 html_show_copyright
3827 If true, "(C) Copyright ..." is shown in the HTML footer.
3828 Default is True.
3829
3830 New in version 1.0.
3831
3832 html_show_sphinx
3833 If true, "Created using Sphinx" is shown in the HTML footer.
3834 Default is True.
3835
3836 New in version 0.4.
3837
3838 html_output_encoding
3839 Encoding of HTML output files. Default is 'utf-8'. Note that
3840 this encoding name must both be a valid Python encoding name and
3841 a valid HTML charset value.
3842
3843 New in version 1.0.
3844
3845 html_compact_lists
3846 If true, list items containing only a single paragraph will not
3847 be rendered with a <p> element. This is standard docutils
3848 behavior. Default: True.
3849
3850 New in version 1.0.
3851
3852 html_secnumber_suffix
3853 Suffix for section numbers. Default: ". ". Set to " " to sup‐
3854 press the final dot on section numbers.
3855
3856 New in version 1.0.
3857
3858 html_search_language
3859 Language to be used for generating the HTML full-text search
3860 index. This defaults to the global language selected with lan‐
3861 guage. If there is no support for this language, "en" is used
3862 which selects the English language.
3863
3864 Support is present for these languages:
3865
3866 · en -- English
3867
3868 · ja -- Japanese
3869
3870 New in version 1.1.
3871
3872 html_search_options
3873 A dictionary with options for the search language support, empty
3874 by default. The meaning of these options depends on the lan‐
3875 guage selected.
3876
3877 The English support has no options.
3878
3879 The Japanese support has these options:
3880
3881 · type -- 'mecab' or 'default' (selects either MeCab or TinySeg‐
3882 menter word splitter algorithm)
3883
3884 · dic_enc -- the encoding for the MeCab algorithm
3885
3886 · dict -- the dictionary to use for the MeCab algorithm
3887
3888 · lib -- the library name for finding the MeCab library via
3889 ctypes if the Python binding is not installed
3890
3891 New in version 1.1.
3892
3893 htmlhelp_basename
3894 Output file base name for HTML help builder. Default is
3895 'pydoc'.
3896
3897 Options for epub output
3898 These options influence the epub output. As this builder derives from
3899 the HTML builder, the HTML options also apply where appropriate. The
3900 actual values for some of the options is not really important, they
3901 just have to be entered into the Dublin Core metadata.
3902
3903 epub_basename
3904 The basename for the epub file. It defaults to the project
3905 name.
3906
3907 epub_theme
3908 The HTML theme for the epub output. Since the default themes
3909 are not optimized for small screen space, using the same theme
3910 for HTML and epub output is usually not wise. This defaults to
3911 'epub', a theme designed to save visual space.
3912
3913 epub_title
3914 The title of the document. It defaults to the html_title option
3915 but can be set independently for epub creation.
3916
3917 epub_author
3918 The author of the document. This is put in the Dublin Core
3919 metadata. The default value is 'unknown'.
3920
3921 epub_language
3922 The language of the document. This is put in the Dublin Core
3923 metadata. The default is the language option or 'en' if unset.
3924
3925 epub_publisher
3926 The publisher of the document. This is put in the Dublin Core
3927 metadata. You may use any sensible string, e.g. the project
3928 homepage. The default value is 'unknown'.
3929
3930 epub_copyright
3931 The copyright of the document. It defaults to the copyright
3932 option but can be set independently for epub creation.
3933
3934 epub_identifier
3935 An identifier for the document. This is put in the Dublin Core
3936 metadata. For published documents this is the ISBN number, but
3937 you can also use an alternative scheme, e.g. the project home‐
3938 page. The default value is 'unknown'.
3939
3940 epub_scheme
3941 The publication scheme for the epub_identifier. This is put in
3942 the Dublin Core metadata. For published books the scheme is
3943 'ISBN'. If you use the project homepage, 'URL' seems reason‐
3944 able. The default value is 'unknown'.
3945
3946 epub_uid
3947 A unique identifier for the document. This is put in the Dublin
3948 Core metadata. You may use a random string. The default value
3949 is 'unknown'.
3950
3951 epub_cover
3952 The cover page information. This is a tuple containing the
3953 filenames of the cover image and the html template. The ren‐
3954 dered html cover page is inserted as the first item in the spine
3955 in content.opf. If the template filename is empty, no html
3956 cover page is created. No cover at all is created if the tuple
3957 is empty. Examples:
3958
3959 epub_cover = ('_static/cover.png', 'epub-cover.html')
3960 epub_cover = ('_static/cover.png', '')
3961 epub_cover = ()
3962
3963 The default value is ().
3964
3965 New in version 1.1.
3966
3967 epub_pre_files
3968 Additional files that should be inserted before the text gener‐
3969 ated by Sphinx. It is a list of tuples containing the file name
3970 and the title. If the title is empty, no entry is added to
3971 toc.ncx. Example:
3972
3973 epub_pre_files = [
3974 ('index.html', 'Welcome'),
3975 ]
3976
3977 The default value is [].
3978
3979 epub_post_files
3980 Additional files that should be inserted after the text gener‐
3981 ated by Sphinx. It is a list of tuples containing the file name
3982 and the title. This option can be used to add an appendix. If
3983 the title is empty, no entry is added to toc.ncx. The default
3984 value is [].
3985
3986 epub_exclude_files
3987 A list of files that are generated/copied in the build directory
3988 but should not be included in the epub file. The default value
3989 is [].
3990
3991 epub_tocdepth
3992 The depth of the table of contents in the file toc.ncx. It
3993 should be an integer greater than zero. The default value is 3.
3994 Note: A deeply nested table of contents may be difficult to nav‐
3995 igate.
3996
3997 epub_tocdup
3998 This flag determines if a toc entry is inserted again at the
3999 beginning of it's nested toc listing. This allows easier navi‐
4000 tation to the top of a chapter, but can be confusing because it
4001 mixes entries of differnet depth in one list. The default value
4002 is True.
4003
4004 Options for LaTeX output
4005 These options influence LaTeX output.
4006
4007 latex_documents
4008 This value determines how to group the document tree into LaTeX
4009 source files. It must be a list of tuples (startdocname, tar‐
4010 getname, title, author, documentclass, toctree_only), where the
4011 items are:
4012
4013 · startdocname: document name that is the "root" of the LaTeX
4014 file. All documents referenced by it in TOC trees will be
4015 included in the LaTeX file too. (If you want only one LaTeX
4016 file, use your master_doc here.)
4017
4018 · targetname: file name of the LaTeX file in the output direc‐
4019 tory.
4020
4021 · title: LaTeX document title. Can be empty to use the title of
4022 the startdoc. This is inserted as LaTeX markup, so special
4023 characters like a backslash or ampersand must be represented
4024 by the proper LaTeX commands if they are to be inserted liter‐
4025 ally.
4026
4027 · author: Author for the LaTeX document. The same LaTeX markup
4028 caveat as for title applies. Use \and to separate multiple
4029 authors, as in: 'John \and Sarah'.
4030
4031 · documentclass: Normally, one of 'manual' or 'howto' (provided
4032 by Sphinx). Other document classes can be given, but they
4033 must include the "sphinx" package in order to define Sphinx'
4034 custom LaTeX commands. "howto" documents will not get appen‐
4035 dices. Also, howtos will have a simpler title page.
4036
4037 · toctree_only: Must be True or False. If True, the startdoc
4038 document itself is not included in the output, only the docu‐
4039 ments referenced by it via TOC trees. With this option, you
4040 can put extra stuff in the master document that shows up in
4041 the HTML, but not the LaTeX output.
4042
4043 New in version 0.3: The 6th item toctree_only. Tuples with 5
4044 items are still accepted.
4045
4046 latex_logo
4047 If given, this must be the name of an image file (relative to
4048 the configuration directory) that is the logo of the docs. It
4049 is placed at the top of the title page. Default: None.
4050
4051 latex_use_parts
4052 If true, the topmost sectioning unit is parts, else it is chap‐
4053 ters. Default: False.
4054
4055 New in version 0.3.
4056
4057 latex_appendices
4058 A list of document names to append as an appendix to all manu‐
4059 als.
4060
4061 latex_domain_indices
4062 If true, generate domain-specific indices in addition to the
4063 general index. For e.g. the Python domain, this is the global
4064 module index. Default is True.
4065
4066 This value can be a bool or a list of index names that should be
4067 generated, like for html_domain_indices.
4068
4069 New in version 1.0.
4070
4071 latex_use_modindex
4072 If true, add a module index to LaTeX documents. Default is
4073 True.
4074
4075 Deprecated since version 1.0: Use latex_domain_indices.
4076
4077 latex_show_pagerefs
4078 If true, add page references after internal references. This is
4079 very useful for printed copies of the manual. Default is False.
4080
4081 New in version 1.0.
4082
4083 latex_show_urls
4084 Control whether to display URL addresses. This is very useful
4085 for printed copies of the manual. The setting can have the fol‐
4086 lowing values:
4087
4088 · 'no' -- do not display URLs (default)
4089
4090 · 'footnote' -- display URLs in footnotes
4091
4092 · 'inline' -- display URLs inline in parentheses
4093
4094 New in version 1.0.
4095
4096 Changed in version 1.1: This value is now a string; previously
4097 it was a boolean value, and a true value selected the 'inline'
4098 display. For backwards compatibility, True is still accepted.
4099
4100 latex_elements
4101 New in version 0.5.
4102
4103 A dictionary that contains LaTeX snippets that override those
4104 Sphinx usually puts into the generated .tex files.
4105
4106 Keep in mind that backslashes must be doubled in Python string
4107 literals to avoid interpretation as escape sequences.
4108
4109 · Keys that you may want to override include:
4110
4111 'papersize'
4112 Paper size option of the document class ('a4paper' or
4113 'letterpaper'), default 'letterpaper'.
4114
4115 'pointsize'
4116 Point size option of the document class ('10pt', '11pt'
4117 or '12pt'), default '10pt'.
4118
4119 'babel'
4120 "babel" package inclusion, default '\\usepack‐
4121 age{babel}'.
4122
4123 'fontpkg'
4124 Font package inclusion, default '\\usepackage{times}'
4125 (which uses Times and Helvetica). You can set this to
4126 '' to use the Computer Modern fonts.
4127
4128 'fncychap'
4129 Inclusion of the "fncychap" package (which makes fancy
4130 chapter titles), default '\\usepackage[Bjarne]{fncy‐
4131 chap}' for English documentation, '\\usepack‐
4132 age[Sonny]{fncychap}' for internationalized docs
4133 (because the "Bjarne" style uses numbers spelled out in
4134 English). Other "fncychap" styles you can try include
4135 "Lenny", "Glenn", "Conny" and "Rejne". You can also
4136 set this to '' to disable fncychap.
4137
4138 'preamble'
4139 Additional preamble content, default empty.
4140
4141 'footer'`
4142 Additional footer content (before the indices), default
4143 empty.
4144
4145 · Keys that don't need be overridden unless in special cases
4146 are:
4147
4148 'inputenc'
4149 "inputenc" package inclusion, default '\\usepack‐
4150 age[utf8]{inputenc}'.
4151
4152 'fontenc'
4153 "fontenc" package inclusion, default '\\usepack‐
4154 age[T1]{fontenc}'.
4155
4156 'maketitle'
4157 "maketitle" call, default '\\maketitle'. Override if
4158 you want to generate a differently-styled title page.
4159
4160 'tableofcontents'
4161 "tableofcontents" call, default '\\tableofcontents'.
4162 Override if you want to generate a different table of
4163 contents or put content between the title page and the
4164 TOC.
4165
4166 'printindex'
4167 "printindex" call, the last thing in the file, default
4168 '\\printindex'. Override if you want to generate the
4169 index differently or append some content after the
4170 index.
4171
4172 · Keys that are set by other options and therefore should not be
4173 overridden are:
4174
4175 'docclass' 'classoptions' 'title' 'date' 'release' 'author'
4176 'logo' 'releasename' 'makeindex' 'shorthandoff'
4177
4178 latex_docclass
4179 A dictionary mapping 'howto' and 'manual' to names of real docu‐
4180 ment classes that will be used as the base for the two Sphinx
4181 classes. Default is to use 'article' for 'howto' and 'report'
4182 for 'manual'.
4183
4184 New in version 1.0.
4185
4186 latex_additional_files
4187 A list of file names, relative to the configuration directory,
4188 to copy to the build directory when building LaTeX output. This
4189 is useful to copy files that Sphinx doesn't copy automatically,
4190 e.g. if they are referenced in custom LaTeX added in latex_ele‐
4191 ments. Image files that are referenced in source files (e.g.
4192 via .. image::) are copied automatically.
4193
4194 You have to make sure yourself that the filenames don't collide
4195 with those of any automatically copied files.
4196
4197 New in version 0.6.
4198
4199 latex_preamble
4200 Additional LaTeX markup for the preamble.
4201
4202 Deprecated since version 0.5: Use the 'preamble' key in the
4203 latex_elements value.
4204
4205 latex_paper_size
4206 The output paper size ('letter' or 'a4'). Default is 'letter'.
4207
4208 Deprecated since version 0.5: Use the 'papersize' key in the
4209 latex_elements value.
4210
4211 latex_font_size
4212 The font size ('10pt', '11pt' or '12pt'). Default is '10pt'.
4213
4214 Deprecated since version 0.5: Use the 'pointsize' key in the
4215 latex_elements value.
4216
4217 Options for text output
4218 These options influence text output.
4219
4220 text_newlines
4221 Determines which end-of-line character(s) are used in text out‐
4222 put.
4223
4224 · 'unix': use Unix-style line endings (\n)
4225
4226 · 'windows': use Windows-style line endings (\r\n)
4227
4228 · 'native': use the line ending style of the platform the docu‐
4229 mentation is built on
4230
4231 Default: 'unix'.
4232
4233 New in version 1.1.
4234
4235 text_sectionchars
4236 A string of 7 characters that should be used for underlining
4237 sections. The first character is used for first-level headings,
4238 the second for second-level headings and so on.
4239
4240 The default is '*=-~"+`'.
4241
4242 New in version 1.1.
4243
4244 Options for manual page output
4245 These options influence manual page output.
4246
4247 man_pages
4248 This value determines how to group the document tree into manual
4249 pages. It must be a list of tuples (startdocname, name,
4250 description, authors, section), where the items are:
4251
4252 · startdocname: document name that is the "root" of the manual
4253 page. All documents referenced by it in TOC trees will be
4254 included in the manual file too. (If you want one master man‐
4255 ual page, use your master_doc here.)
4256
4257 · name: name of the manual page. This should be a short string
4258 without spaces or special characters. It is used to determine
4259 the file name as well as the name of the manual page (in the
4260 NAME section).
4261
4262 · description: description of the manual page. This is used in
4263 the NAME section.
4264
4265 · authors: A list of strings with authors, or a single string.
4266 Can be an empty string or list if you do not want to automati‐
4267 cally generate an AUTHORS section in the manual page.
4268
4269 · section: The manual page section. Used for the output file
4270 name as well as in the manual page header.
4271
4272 New in version 1.0.
4273
4274 man_show_urls
4275 If true, add URL addresses after links. Default is False.
4276
4277 New in version 1.1.
4278
4279 Options for Texinfo output
4280 These options influence Texinfo output.
4281
4282 texinfo_documents
4283 This value determines how to group the document tree into Tex‐
4284 info source files. It must be a list of tuples (startdocname,
4285 targetname, title, author, dir_entry, description, category,
4286 toctree_only), where the items are:
4287
4288 · startdocname: document name that is the "root" of the Texinfo
4289 file. All documents referenced by it in TOC trees will be
4290 included in the Texinfo file too. (If you want only one Tex‐
4291 info file, use your master_doc here.)
4292
4293 · targetname: file name (no extension) of the Texinfo file in
4294 the output directory.
4295
4296 · title: Texinfo document title. Can be empty to use the title
4297 of the startdoc. Inserted as Texinfo markup, so special char‐
4298 acters like @ and {} will need to be escaped to be inserted
4299 literally.
4300
4301 · author: Author for the Texinfo document. Inserted as Texinfo
4302 markup. Use @* to separate multiple authors, as in:
4303 'John@*Sarah'.
4304
4305 · dir_entry: The name that will appear in the top-level DIR menu
4306 file.
4307
4308 · description: Descriptive text to appear in the top-level DIR
4309 menu file.
4310
4311 · category: Specifies the section which this entry will appear
4312 in the top-level DIR menu file.
4313
4314 · toctree_only: Must be True or False. If True, the startdoc
4315 document itself is not included in the output, only the docu‐
4316 ments referenced by it via TOC trees. With this option, you
4317 can put extra stuff in the master document that shows up in
4318 the HTML, but not the Texinfo output.
4319
4320 New in version 1.1.
4321
4322 texinfo_appendices
4323 A list of document names to append as an appendix to all manu‐
4324 als.
4325
4326 New in version 1.1.
4327
4328 texinfo_domain_indices
4329 If true, generate domain-specific indices in addition to the
4330 general index. For e.g. the Python domain, this is the global
4331 module index. Default is True.
4332
4333 This value can be a bool or a list of index names that should be
4334 generated, like for html_domain_indices.
4335
4336 New in version 1.1.
4337
4338 texinfo_show_urls
4339 Control how to display URL addresses.
4340
4341 · 'footnote' -- display URLs in footnotes (default)
4342
4343 · 'no' -- do not display URLs
4344
4345 · 'inline' -- display URLs inline in parentheses
4346
4347 New in version 1.1.
4348
4349 texinfo_elements
4350 A dictionary that contains Texinfo snippets that override those
4351 Sphinx usually puts into the generated .texi files.
4352
4353 · Keys that you may want to override include:
4354
4355 'paragraphindent'
4356 Number of spaces to indent the first line of each para‐
4357 graph, default 2. Specify 0 for no indentation.
4358
4359 'exampleindent'
4360 Number of spaces to indent the lines for examples or
4361 literal blocks, default 4. Specify 0 for no indenta‐
4362 tion.
4363
4364 'preamble'
4365 Texinfo markup inserted near the beginning of the file.
4366
4367 'copying'
4368 Texinfo markup inserted within the @copying block and
4369 displayed after the title. The default value consists
4370 of a simple title page identifying the project.
4371
4372 · Keys that are set by other options and therefore should not be
4373 overridden are:
4374
4375 'author' 'body' 'date' 'direntry' 'filename' 'project'
4376 'release' 'title' 'direntry'
4377
4378 New in version 1.1.
4379
4380 Options for the linkcheck builder
4381 linkcheck_ignore
4382 A list of regular expressions that match URIs that should not be
4383 checked when doing a linkcheck build. Example:
4384
4385 linkcheck_ignore = [r'http://localhost:\d+/']
4386
4387 New in version 1.1.
4388
4389 linkcheck_timeout
4390 A timeout value, in seconds, for the linkcheck builder. Only
4391 works in Python 2.6 and higher. The default is to use Python's
4392 global socket timeout.
4393
4394 New in version 1.1.
4395
4396 linkcheck_workers
4397 The number of worker threads to use when checking links.
4398 Default is 5 threads.
4399
4400 New in version 1.1.
4401
4403 [1] A note on available globbing syntax: you can use the standard
4404 shell constructs *, ?, [...] and [!...] with the feature that
4405 these all don't match slashes. A double star ** can be used to
4406 match any sequence of characters including slashes.
4407
4409 New in version 1.1.
4410
4411 Complementary to translations provided for Sphinx-generated messages
4412 such as navigation bars, Sphinx provides mechanisms facilitating docu‐
4413 ment translations in itself. See the intl-options for details on con‐
4414 figuration.
4415 [image] Workflow visualization of translations in Sphinx. (The
4416 stick-figure is taken from an XKCD comic.).UNINDENT
4417
4418 gettext [1] is an established standard for internationalization and
4419 localization. It naïvely maps messages in a program to a translated
4420 string. Sphinx uses these facilities to translate whole documents.
4421
4422 Initially project maintainers have to collect all translatable
4423 strings (also referred to as messages) to make them known to transla‐
4424 tors. Sphinx extracts these through invocation of sphinx-build -b
4425 gettext.
4426
4427 Every single element in the doctree will end up in a single message
4428 which results in lists being equally split into different chunks
4429 while large paragraphs will remain as coarsely-grained as they were
4430 in the original document. This grants seamless document updates
4431 while still providing a little bit of context for translators in
4432 free-text passages. It is the maintainer's task to split up para‐
4433 graphs which are too large as there is no sane automated way to do
4434 that.
4435
4436 After Sphinx successfully ran the MessageCatalogBuilder you will find
4437 a collection of .pot files in your output directory. These are cata‐
4438 log templates and contain messages in your original language only.
4439
4440 They can be delivered to translators which will transform them to .po
4441 files --- so called message catalogs --- containing a mapping from
4442 the original messages to foreign-language strings.
4443
4444 Gettext compiles them into a binary format known as binary catalogs
4445 through msgfmt for efficiency reasons. If you make these files dis‐
4446 coverable with locale_dirs for your language, Sphinx will pick them
4447 up automatically.
4448
4449 An example: you have a document usage.rst in your Sphinx project.
4450 The gettext builder will put its messages into usage.pot. Imagine
4451 you have Spanish translations [2] on your hands in usage.po --- for
4452 your builds to be translated you need to follow these instructions:
4453
4454 · Compile your message catalog to a locale directory, say translated,
4455 so it ends up in ./translated/es/LC_MESSAGES/usage.mo in your source
4456 directory (where es is the language code for Spanish.)
4457
4458 msgfmt "usage.po" -o "translated/es/LC_MESSAGES/usage.mo"
4459
4460 · Set locale_dirs to ["translated/"].
4461
4462 · Set language to es (also possible via -D).
4463
4464 · Run your desired build.
4465
4467 [1] See the GNU gettext utilites for details on that software suite.
4468
4469 [2] Because nobody expects the Spanish Inquisition!
4470
4472 New in version 0.6.
4473
4474 Sphinx supports changing the appearance of its HTML output via themes.
4475 A theme is a collection of HTML templates, stylesheet(s) and other
4476 static files. Additionally, it has a configuration file which speci‐
4477 fies from which theme to inherit, which highlighting style to use, and
4478 what options exist for customizing the theme's look and feel.
4479
4480 Themes are meant to be project-unaware, so they can be used for differ‐
4481 ent projects without change.
4482
4483 Using a theme
4484 Using an existing theme is easy. If the theme is builtin to Sphinx,
4485 you only need to set the html_theme config value. With the
4486 html_theme_options config value you can set theme-specific options that
4487 change the look and feel. For example, you could have the following in
4488 your conf.py:
4489
4490 html_theme = "default"
4491 html_theme_options = {
4492 "rightsidebar": "true",
4493 "relbarbgcolor": "black"
4494 }
4495
4496 That would give you the default theme, but with a sidebar on the right
4497 side and a black background for the relation bar (the bar with the nav‐
4498 igation links at the page's top and bottom).
4499
4500 If the theme does not come with Sphinx, it can be in two forms: either
4501 a directory (containing theme.conf and other needed files), or a zip
4502 file with the same contents. Either of them must be put where Sphinx
4503 can find it; for this there is the config value html_theme_path. It
4504 gives a list of directories, relative to the directory containing
4505 conf.py, that can contain theme directories or zip files. For example,
4506 if you have a theme in the file blue.zip, you can put it right in the
4507 directory containing conf.py and use this configuration:
4508
4509 html_theme = "blue"
4510 html_theme_path = ["."]
4511
4512 Builtin themes
4513 ┌───────────────────────────┬────────────────────────────┐
4514 │Theme overview │ │
4515 ├───────────────────────────┼────────────────────────────┤
4516 │[image: default] [image] │ [image: sphinxdoc] [image] │
4517 │ │ │
4518 │ │ │
4519 │default │ sphinxdoc │
4520 ├───────────────────────────┼────────────────────────────┤
4521 │[image: scrolls] [image] │ [image: agogo] [image] │
4522 │ │ │
4523 │ │ │
4524 │scrolls │ agogo │
4525 ├───────────────────────────┼────────────────────────────┤
4526 │[image: traditional] │ [image: nature] [image] │
4527 │[image] │ │
4528 │ │ │
4529 │ │ nature │
4530 │traditional │ │
4531 ├───────────────────────────┼────────────────────────────┤
4532 │[image: haiku] [image] │ [image: pyramid] [image] │
4533 │ │ │
4534 │ │ │
4535 │haiku │ pyramid │
4536 └───────────────────────────┴────────────────────────────┘
4537
4538 Sphinx comes with a selection of themes to choose from.
4539
4540 These themes are:
4541
4542 · basic -- This is a basically unstyled layout used as the base for the
4543 other themes, and usable as the base for custom themes as well. The
4544 HTML contains all important elements like sidebar and relation bar.
4545 There are these options (which are inherited by the other themes):
4546
4547 · nosidebar (true or false): Don't include the sidebar. Defaults to
4548 false.
4549
4550 · sidebarwidth (an integer): Width of the sidebar in pixels. (Do not
4551 include px in the value.) Defaults to 230 pixels.
4552
4553 · default -- This is the default theme, which looks like the Python
4554 documentation. It can be customized via these options:
4555
4556 · rightsidebar (true or false): Put the sidebar on the right side.
4557 Defaults to false.
4558
4559 · stickysidebar (true or false): Make the sidebar "fixed" so that it
4560 doesn't scroll out of view for long body content. This may not
4561 work well with all browsers. Defaults to false.
4562
4563 · collapsiblesidebar (true or false): Add an experimental JavaScript
4564 snippet that makes the sidebar collapsible via a button on its
4565 side. Doesn't work together with "rightsidebar" or "stickyside‐
4566 bar". Defaults to false.
4567
4568 · externalrefs (true or false): Display external links differently
4569 from internal links. Defaults to false.
4570
4571 There are also various color and font options that can change the
4572 color scheme without having to write a custom stylesheet:
4573
4574 · footerbgcolor (CSS color): Background color for the footer line.
4575
4576 · footertextcolor (CSS color): Text color for the footer line.
4577
4578 · sidebarbgcolor (CSS color): Background color for the sidebar.
4579
4580 · sidebarbtncolor (CSS color): Background color for the sidebar col‐
4581 lapse button (used when collapsiblesidebar is true).
4582
4583 · sidebartextcolor (CSS color): Text color for the sidebar.
4584
4585 · sidebarlinkcolor (CSS color): Link color for the sidebar.
4586
4587 · relbarbgcolor (CSS color): Background color for the relation bar.
4588
4589 · relbartextcolor (CSS color): Text color for the relation bar.
4590
4591 · relbarlinkcolor (CSS color): Link color for the relation bar.
4592
4593 · bgcolor (CSS color): Body background color.
4594
4595 · textcolor (CSS color): Body text color.
4596
4597 · linkcolor (CSS color): Body link color.
4598
4599 · visitedlinkcolor (CSS color): Body color for visited links.
4600
4601 · headbgcolor (CSS color): Background color for headings.
4602
4603 · headtextcolor (CSS color): Text color for headings.
4604
4605 · headlinkcolor (CSS color): Link color for headings.
4606
4607 · codebgcolor (CSS color): Background color for code blocks.
4608
4609 · codetextcolor (CSS color): Default text color for code blocks, if
4610 not set differently by the highlighting style.
4611
4612 · bodyfont (CSS font-family): Font for normal text.
4613
4614 · headfont (CSS font-family): Font for headings.
4615
4616 · sphinxdoc -- The theme used for this documentation. It features a
4617 sidebar on the right side. There are currently no options beyond
4618 nosidebar and sidebarwidth.
4619
4620 · scrolls -- A more lightweight theme, based on the Jinja documenta‐
4621 tion. The following color options are available:
4622
4623 · headerbordercolor
4624
4625 · subheadlinecolor
4626
4627 · linkcolor
4628
4629 · visitedlinkcolor
4630
4631 · admonitioncolor
4632
4633 · agogo -- A theme created by Andi Albrecht. The following options are
4634 supported:
4635
4636 · bodyfont (CSS font family): Font for normal text.
4637
4638 · headerfont (CSS font family): Font for headings.
4639
4640 · pagewidth (CSS length): Width of the page content, default 70em.
4641
4642 · documentwidth (CSS length): Width of the document (without side‐
4643 bar), default 50em.
4644
4645 · sidebarwidth (CSS length): Width of the sidebar, default 20em.
4646
4647 · bgcolor (CSS color): Background color.
4648
4649 · headerbg (CSS value for "background"): background for the header
4650 area, default a grayish gradient.
4651
4652 · footerbg (CSS value for "background"): background for the footer
4653 area, default a light gray gradient.
4654
4655 · linkcolor (CSS color): Body link color.
4656
4657 · headercolor1, headercolor2 (CSS color): colors for <h1> and <h2>
4658 headings.
4659
4660 · headerlinkcolor (CSS color): Color for the backreference link in
4661 headings.
4662
4663 · textalign (CSS text-align value): Text alignment for the body,
4664 default is justify.
4665
4666 · nature -- A greenish theme. There are currently no options beyond
4667 nosidebar and sidebarwidth.
4668
4669 · pyramid -- A theme from the Pyramid web framework project, designed
4670 by Blaise Laflamme. There are currently no options beyond nosidebar
4671 and sidebarwidth.
4672
4673 · haiku -- A theme without sidebar inspired by the Haiku OS user guide.
4674 The following options are supported:
4675
4676 · full_logo (true or false, default false): If this is true, the
4677 header will only show the html_logo. Use this for large logos. If
4678 this is false, the logo (if present) will be shown floating right,
4679 and the documentation title will be put in the header.
4680
4681 · textcolor, headingcolor, linkcolor, visitedlinkcolor, hoverlink‐
4682 color (CSS colors): Colors for various body elements.
4683
4684 · traditional -- A theme resembling the old Python documentation.
4685 There are currently no options beyond nosidebar and sidebarwidth.
4686
4687 · epub -- A theme for the epub builder. There are currently no
4688 options. This theme tries to save visual space which is a sparse
4689 resource on ebook readers.
4690
4691 Creating themes
4692 As said, themes are either a directory or a zipfile (whose name is the
4693 theme name), containing the following:
4694
4695 · A theme.conf file, see below.
4696
4697 · HTML templates, if needed.
4698
4699 · A static/ directory containing any static files that will be copied
4700 to the output static directory on build. These can be images,
4701 styles, script files.
4702
4703 The theme.conf file is in INI format [1] (readable by the standard
4704 Python ConfigParser module) and has the following structure:
4705
4706 [theme]
4707 inherit = base theme
4708 stylesheet = main CSS name
4709 pygments_style = stylename
4710
4711 [options]
4712 variable = default value
4713
4714 · The inherit setting gives the name of a "base theme", or none. The
4715 base theme will be used to locate missing templates (most themes will
4716 not have to supply most templates if they use basic as the base
4717 theme), its options will be inherited, and all of its static files
4718 will be used as well.
4719
4720 · The stylesheet setting gives the name of a CSS file which will be
4721 referenced in the HTML header. If you need more than one CSS file,
4722 either include one from the other via CSS' @import, or use a custom
4723 HTML template that adds <link rel="stylesheet"> tags as necessary.
4724 Setting the html_style config value will override this setting.
4725
4726 · The pygments_style setting gives the name of a Pygments style to use
4727 for highlighting. This can be overridden by the user in the pyg‐
4728 ments_style config value.
4729
4730 · The options section contains pairs of variable names and default val‐
4731 ues. These options can be overridden by the user in
4732 html_theme_options and are accessible from all templates as
4733 theme_<name>.
4734
4735 Templating
4736 The guide to templating is helpful if you want to write your own tem‐
4737 plates. What is important to keep in mind is the order in which Sphinx
4738 searches for templates:
4739
4740 · First, in the user's templates_path directories.
4741
4742 · Then, in the selected theme.
4743
4744 · Then, in its base theme, its base's base theme, etc.
4745
4746 When extending a template in the base theme with the same name, use the
4747 theme name as an explicit directory: {% extends "basic/layout.html" %}.
4748 From a user templates_path template, you can still use the "exclamation
4749 mark" syntax as described in the templating document.
4750
4751 Static templates
4752 Since theme options are meant for the user to configure a theme more
4753 easily, without having to write a custom stylesheet, it is necessary to
4754 be able to template static files as well as HTML files. Therefore,
4755 Sphinx supports so-called "static templates", like this:
4756
4757 If the name of a file in the static/ directory of a theme (or in the
4758 user's static path, for that matter) ends with _t, it will be processed
4759 by the template engine. The _t will be left from the final file name.
4760 For example, the default theme has a file static/default.css_t which
4761 uses templating to put the color options into the stylesheet. When a
4762 documentation is built with the default theme, the output directory
4763 will contain a _static/default.css file where all template tags have
4764 been processed.
4765
4766 [1] It is not an executable Python file, as opposed to conf.py,
4767 because that would pose an unnecessary security risk if themes are
4768 shared.
4769
4771 Sphinx uses the Jinja templating engine for its HTML templates. Jinja
4772 is a text-based engine, and inspired by Django templates, so anyone
4773 having used Django will already be familiar with it. It also has
4774 excellent documentation for those who need to make themselves familiar
4775 with it.
4776
4777 Do I need to use Sphinx' templates to produce HTML?
4778 No. You have several other options:
4779
4780 · You can write a TemplateBridge subclass that calls your template
4781 engine of choice, and set the template_bridge configuration value
4782 accordingly.
4783
4784 · You can write a custom builder that derives from StandaloneHTML‐
4785 Builder and calls your template engine of choice.
4786
4787 · You can use the PickleHTMLBuilder that produces pickle files with the
4788 page contents, and postprocess them using a custom tool, or use them
4789 in your Web application.
4790
4791 Jinja/Sphinx Templating Primer
4792 The default templating language in Sphinx is Jinja. It's Django/Smarty
4793 inspired and easy to understand. The most important concept in Jinja
4794 is template inheritance, which means that you can overwrite only spe‐
4795 cific blocks within a template, customizing it while also keeping the
4796 changes at a minimum.
4797
4798 To customize the output of your documentation you can override all the
4799 templates (both the layout templates and the child templates) by adding
4800 files with the same name as the original filename into the template
4801 directory of the structure the Sphinx quickstart generated for you.
4802
4803 Sphinx will look for templates in the folders of templates_path first,
4804 and if it can't find the template it's looking for there, it falls back
4805 to the selected theme's templates.
4806
4807 A template contains variables, which are replaced with values when the
4808 template is evaluated, tags, which control the logic of the template
4809 and blocks which are used for template inheritance.
4810
4811 Sphinx' basic theme provides base templates with a couple of blocks it
4812 will fill with data. These are located in the themes/basic subdirec‐
4813 tory of the Sphinx installation directory, and used by all builtin
4814 Sphinx themes. Templates with the same name in the templates_path
4815 override templates supplied by the selected theme.
4816
4817 For example, to add a new link to the template area containing related
4818 links all you have to do is to add a new template called layout.html
4819 with the following contents:
4820
4821 {% extends "!layout.html" %}
4822 {% block rootrellink %}
4823 <li><a href="http://project.invalid/">Project Homepage</a> »</li>
4824 {{ super() }}
4825 {% endblock %}
4826
4827 By prefixing the name of the overridden template with an exclamation
4828 mark, Sphinx will load the layout template from the underlying HTML
4829 theme.
4830
4831 Important: If you override a block, call {{ super() }} somewhere to
4832 render the block's content in the extended template -- unless you don't
4833 want that content to show up.
4834
4835 Working with the builtin templates
4836 The builtin basic theme supplies the templates that all builtin Sphinx
4837 themes are based on. It has the following elements you can override or
4838 use:
4839
4840 Blocks
4841 The following blocks exist in the layout.html template:
4842
4843 doctype
4844 The doctype of the output format. By default this is XHTML 1.0
4845 Transitional as this is the closest to what Sphinx and Docutils
4846 generate and it's a good idea not to change it unless you want
4847 to switch to HTML 5 or a different but compatible XHTML doctype.
4848
4849 linktags
4850 This block adds a couple of <link> tags to the head section of
4851 the template.
4852
4853 extrahead
4854 This block is empty by default and can be used to add extra con‐
4855 tents into the <head> tag of the generated HTML file. This is
4856 the right place to add references to JavaScript or extra CSS
4857 files.
4858
4859 relbar1 / relbar2
4860 This block contains the relation bar, the list of related links
4861 (the parent documents on the left, and the links to index, mod‐
4862 ules etc. on the right). relbar1 appears before the document,
4863 relbar2 after the document. By default, both blocks are filled;
4864 to show the relbar only before the document, you would override
4865 relbar2 like this:
4866
4867 {% block relbar2 %}{% endblock %}
4868
4869 rootrellink / relbaritems
4870 Inside the relbar there are three sections: The rootrellink, the
4871 links from the documentation and the custom relbaritems. The
4872 rootrellink is a block that by default contains a list item
4873 pointing to the master document by default, the relbaritems is
4874 an empty block. If you override them to add extra links into
4875 the bar make sure that they are list items and end with the
4876 reldelim1.
4877
4878 document
4879 The contents of the document itself. It contains the block
4880 "body" where the individual content is put by subtemplates like
4881 page.html.
4882
4883 sidebar1 / sidebar2
4884 A possible location for a sidebar. sidebar1 appears before the
4885 document and is empty by default, sidebar2 after the document
4886 and contains the default sidebar. If you want to swap the side‐
4887 bar location override this and call the sidebar helper:
4888
4889 {% block sidebar1 %}{{ sidebar() }}{% endblock %}
4890 {% block sidebar2 %}{% endblock %}
4891
4892 (The sidebar2 location for the sidebar is needed by the sphinx‐
4893 doc.css stylesheet, for example.)
4894
4895 sidebarlogo
4896 The logo location within the sidebar. Override this if you want
4897 to place some content at the top of the sidebar.
4898
4899 footer The block for the footer div. If you want a custom footer or
4900 markup before or after it, override this one.
4901
4902 The following four blocks are only used for pages that do not have
4903 assigned a list of custom sidebars in the html_sidebars config value.
4904 Their use is deprecated in favor of separate sidebar templates, which
4905 can be included via html_sidebars.
4906
4907 sidebartoc
4908 The table of contents within the sidebar.
4909
4910 Deprecated since version 1.0.
4911
4912 sidebarrel
4913 The relation links (previous, next document) within the sidebar.
4914
4915 Deprecated since version 1.0.
4916
4917 sidebarsourcelink
4918 The "Show source" link within the sidebar (normally only shown
4919 if this is enabled by html_show_sourcelink).
4920
4921 Deprecated since version 1.0.
4922
4923 sidebarsearch
4924 The search box within the sidebar. Override this if you want to
4925 place some content at the bottom of the sidebar.
4926
4927 Deprecated since version 1.0.
4928
4929 Configuration Variables
4930 Inside templates you can set a couple of variables used by the layout
4931 template using the {% set %} tag:
4932
4933 reldelim1
4934 The delimiter for the items on the left side of the related bar.
4935 This defaults to ' »' Each item in the related bar ends
4936 with the value of this variable.
4937
4938 reldelim2
4939 The delimiter for the items on the right side of the related
4940 bar. This defaults to ' |'. Each item except of the last one
4941 in the related bar ends with the value of this variable.
4942
4943 Overriding works like this:
4944
4945 {% extends "!layout.html" %}
4946 {% set reldelim1 = ' >' %}
4947
4948 script_files
4949 Add additional script files here, like this:
4950
4951 {% set script_files = script_files + ["_static/myscript.js"] %}
4952
4953 css_files
4954 Similar to script_files, for CSS files.
4955
4956 Helper Functions
4957 Sphinx provides various Jinja functions as helpers in the template.
4958 You can use them to generate links or output multiply used elements.
4959
4960 pathto(document)
4961 Return the path to a Sphinx document as a URL. Use this to
4962 refer to built documents.
4963
4964 pathto(file, 1)
4965 Return the path to a file which is a filename relative to the
4966 root of the generated output. Use this to refer to static
4967 files.
4968
4969 hasdoc(document)
4970 Check if a document with the name document exists.
4971
4972 sidebar()
4973 Return the rendered sidebar.
4974
4975 relbar()
4976 Return the rendered relation bar.
4977
4978 Global Variables
4979 These global variables are available in every template and are safe to
4980 use. There are more, but most of them are an implementation detail and
4981 might change in the future.
4982
4983 builder
4984 The name of the builder (e.g. html or htmlhelp).
4985
4986 copyright
4987 The value of copyright.
4988
4989 docstitle
4990 The title of the documentation (the value of html_title).
4991
4992 embedded
4993 True if the built HTML is meant to be embedded in some viewing
4994 application that handles navigation, not the web browser, such
4995 as for HTML help or Qt help formats. In this case, the sidebar
4996 is not included.
4997
4998 favicon
4999 The path to the HTML favicon in the static path, or ''.
5000
5001 file_suffix
5002 The value of the builder's out_suffix attribute, i.e. the file
5003 name extension that the output files will get. For a standard
5004 HTML builder, this is usually .html.
5005
5006 has_source
5007 True if the reST document sources are copied (if
5008 html_copy_source is true).
5009
5010 last_updated
5011 The build date.
5012
5013 logo The path to the HTML logo image in the static path, or ''.
5014
5015 master_doc
5016 The value of master_doc, for usage with pathto().
5017
5018 next The next document for the navigation. This variable is either
5019 false or has two attributes link and title. The title contains
5020 HTML markup. For example, to generate a link to the next page,
5021 you can use this snippet:
5022
5023 {% if next %}
5024 <a href="{{ next.link|e }}">{{ next.title }}</a>
5025 {% endif %}
5026
5027 pagename
5028 The "page name" of the current file, i.e. either the document
5029 name if the file is generated from a reST source, or the equiva‐
5030 lent hierarchical name relative to the output directory ([direc‐
5031 tory/]filename_without_extension).
5032
5033 parents
5034 A list of parent documents for navigation, structured like the
5035 next item.
5036
5037 prev Like next, but for the previous page.
5038
5039 project
5040 The value of project.
5041
5042 release
5043 The value of release.
5044
5045 rellinks
5046 A list of links to put at the left side of the relbar, next to
5047 "next" and "prev". This usually contains links to the general
5048 index and other indices, such as the Python module index. If
5049 you add something yourself, it must be a tuple (pagename, link
5050 title, accesskey, link text).
5051
5052 shorttitle
5053 The value of html_short_title.
5054
5055 show_source
5056 True if html_show_sourcelink is true.
5057
5058 sphinx_version
5059 The version of Sphinx used to build.
5060
5061 style The name of the main stylesheet, as given by the theme or
5062 html_style.
5063
5064 title The title of the current document, as used in the <title> tag.
5065
5066 use_opensearch
5067 The value of html_use_opensearch.
5068
5069 version
5070 The value of version.
5071
5072 In addition to these values, there are also all theme options available
5073 (prefixed by theme_), as well as the values given by the user in
5074 html_context.
5075
5076 In documents that are created from source files (as opposed to automat‐
5077 ically-generated files like the module index, or documents that already
5078 are in HTML form), these variables are also available:
5079
5080 meta Document metadata (a dictionary), see metadata.
5081
5082 sourcename
5083 The name of the copied source file for the current document.
5084 This is only nonempty if the html_copy_source value is true.
5085
5086 toc The local table of contents for the current page, rendered as
5087 HTML bullet lists.
5088
5089 toctree
5090 A callable yielding the global TOC tree containing the current
5091 page, rendered as HTML bullet lists. Optional keyword argu‐
5092 ments:
5093
5094 · collapse (true by default): if true, all TOC entries that are
5095 not ancestors of the current page are collapsed
5096
5097 · maxdepth (defaults to the max depth selected in the toctree
5098 directive): the maximum depth of the tree; set it to -1 to
5099 allow unlimited depth
5100
5101 · titles_only (false by default): if true, put only toplevel
5102 document titles in the tree
5103
5105 Since many projects will need special features in their documentation,
5106 Sphinx is designed to be extensible on several levels.
5107
5108 This is what you can do in an extension: First, you can add new
5109 builders to support new output formats or actions on the parsed docu‐
5110 ments. Then, it is possible to register custom reStructuredText roles
5111 and directives, extending the markup. And finally, there are so-called
5112 "hook points" at strategic places throughout the build process, where
5113 an extension can register a hook and run specialized code.
5114
5115 An extension is simply a Python module. When an extension is loaded,
5116 Sphinx imports this module and executes its setup() function, which in
5117 turn notifies Sphinx of everything the extension offers -- see the
5118 extension tutorial for examples.
5119
5120 The configuration file itself can be treated as an extension if it con‐
5121 tains a setup() function. All other extensions to load must be listed
5122 in the extensions configuration value.
5123
5124 Tutorial: Writing a simple extension
5125 This section is intended as a walkthrough for the creation of custom
5126 extensions. It covers the basics of writing and activating an exten‐
5127 sions, as well as commonly used features of extensions.
5128
5129 As an example, we will cover a "todo" extension that adds capabilities
5130 to include todo entries in the documentation, and collecting these in a
5131 central place. (A similar "todo" extension is distributed with
5132 Sphinx.)
5133
5134 Build Phases
5135 One thing that is vital in order to understand extension mechanisms is
5136 the way in which a Sphinx project is built: this works in several
5137 phases.
5138
5139 Phase 0: Initialization
5140 In this phase, almost nothing interesting for us happens. The
5141 source directory is searched for source files, and extensions are
5142 initialized. Should a stored build environment exist, it is loaded,
5143 otherwise a new one is created.
5144
5145 Phase 1: Reading
5146 In Phase 1, all source files (and on subsequent builds, those that
5147 are new or changed) are read and parsed. This is the phase where
5148 directives and roles are encountered by the docutils, and the corre‐
5149 sponding functions are called. The output of this phase is a doc‐
5150 tree for each source files, that is a tree of docutils nodes. For
5151 document elements that aren't fully known until all existing files
5152 are read, temporary nodes are created.
5153
5154 During reading, the build environment is updated with all meta- and
5155 cross reference data of the read documents, such as labels, the
5156 names of headings, described Python objects and index entries. This
5157 will later be used to replace the temporary nodes.
5158
5159 The parsed doctrees are stored on the disk, because it is not possi‐
5160 ble to hold all of them in memory.
5161
5162 Phase 2: Consistency checks
5163 Some checking is done to ensure no surprises in the built documents.
5164
5165 Phase 3: Resolving
5166 Now that the metadata and cross-reference data of all existing docu‐
5167 ments is known, all temporary nodes are replaced by nodes that can
5168 be converted into output. For example, links are created for object
5169 references that exist, and simple literal nodes are created for
5170 those that don't.
5171
5172 Phase 4: Writing
5173 This phase converts the resolved doctrees to the desired output for‐
5174 mat, such as HTML or LaTeX. This happens via a so-called docutils
5175 writer that visits the individual nodes of each doctree and produces
5176 some output in the process.
5177
5178 NOTE:
5179 Some builders deviate from this general build plan, for example, the
5180 builder that checks external links does not need anything more than
5181 the parsed doctrees and therefore does not have phases 2--4.
5182
5183 Extension Design
5184 We want the extension to add the following to Sphinx:
5185
5186 · A "todo" directive, containing some content that is marked with
5187 "TODO", and only shown in the output if a new config value is set.
5188 (Todo entries should not be in the output by default.)
5189
5190 · A "todolist" directive that creates a list of all todo entries
5191 throughout the documentation.
5192
5193 For that, we will need to add the following elements to Sphinx:
5194
5195 · New directives, called todo and todolist.
5196
5197 · New document tree nodes to represent these directives, conventionally
5198 also called todo and todolist. We wouldn't need new nodes if the new
5199 directives only produced some content representable by existing
5200 nodes.
5201
5202 · A new config value todo_include_todos (config value names should
5203 start with the extension name, in order to stay unique) that controls
5204 whether todo entries make it into the output.
5205
5206 · New event handlers: one for the doctree-resolved event, to replace
5207 the todo and todolist nodes, and one for env-purge-doc (the reason
5208 for that will be covered later).
5209
5210 The Setup Function
5211 The new elements are added in the extension's setup function. Let us
5212 create a new Python module called todo.py and add the setup function:
5213
5214 def setup(app):
5215 app.add_config_value('todo_include_todos', False, False)
5216
5217 app.add_node(todolist)
5218 app.add_node(todo,
5219 html=(visit_todo_node, depart_todo_node),
5220 latex=(visit_todo_node, depart_todo_node),
5221 text=(visit_todo_node, depart_todo_node))
5222
5223 app.add_directive('todo', TodoDirective)
5224 app.add_directive('todolist', TodolistDirective)
5225 app.connect('doctree-resolved', process_todo_nodes)
5226 app.connect('env-purge-doc', purge_todos)
5227
5228 The calls in this function refer to classes and functions not yet writ‐
5229 ten. What the individual calls do is the following:
5230
5231 · add_config_value() lets Sphinx know that it should recognize the new
5232 config value todo_include_todos, whose default value should be False
5233 (this also tells Sphinx that it is a boolean value).
5234
5235 If the third argument was True, all documents would be re-read if the
5236 config value changed its value. This is needed for config values
5237 that influence reading (build phase 1).
5238
5239 · add_node() adds a new node class to the build system. It also can
5240 specify visitor functions for each supported output format. These
5241 visitor functions are needed when the new nodes stay until phase 4 --
5242 since the todolist node is always replaced in phase 3, it doesn't
5243 need any.
5244
5245 We need to create the two node classes todo and todolist later.
5246
5247 · add_directive() adds a new directive, given by name and class.
5248
5249 The handler functions are created later.
5250
5251 · Finally, connect() adds an event handler to the event whose name is
5252 given by the first argument. The event handler function is called
5253 with several arguments which are documented with the event.
5254
5255 The Node Classes
5256 Let's start with the node classes:
5257
5258 from docutils import nodes
5259
5260 class todo(nodes.Admonition, nodes.Element):
5261 pass
5262
5263 class todolist(nodes.General, nodes.Element):
5264 pass
5265
5266 def visit_todo_node(self, node):
5267 self.visit_admonition(node)
5268
5269 def depart_todo_node(self, node):
5270 self.depart_admonition(node)
5271
5272 Node classes usually don't have to do anything except inherit from the
5273 standard docutils classes defined in docutils.nodes. todo inherits
5274 from Admonition because it should be handled like a note or warning,
5275 todolist is just a "general" node.
5276
5277 The Directive Classes
5278 A directive class is a class deriving usually from docu‐
5279 tils.parsers.rst.Directive. Since the class-based directive interface
5280 doesn't exist yet in Docutils 0.4, Sphinx has another base class called
5281 sphinx.util.compat.Directive that you can derive your directive from,
5282 and it will work with both Docutils 0.4 and 0.5 upwards. The directive
5283 interface is covered in detail in the docutils documentation; the
5284 important thing is that the class has a method run that returns a list
5285 of nodes.
5286
5287 The todolist directive is quite simple:
5288
5289 from sphinx.util.compat import Directive
5290
5291 class TodolistDirective(Directive):
5292
5293 def run(self):
5294 return [todolist('')]
5295
5296 An instance of our todolist node class is created and returned. The
5297 todolist directive has neither content nor arguments that need to be
5298 handled.
5299
5300 The todo directive function looks like this:
5301
5302 from sphinx.util.compat import make_admonition
5303
5304 class TodoDirective(Directive):
5305
5306 # this enables content in the directive
5307 has_content = True
5308
5309 def run(self):
5310 env = self.state.document.settings.env
5311
5312 targetid = "todo-%d" % env.new_serialno('todo')
5313 targetnode = nodes.target('', '', ids=[targetid])
5314
5315 ad = make_admonition(todo, self.name, [_('Todo')], self.options,
5316 self.content, self.lineno, self.content_offset,
5317 self.block_text, self.state, self.state_machine)
5318
5319 if not hasattr(env, 'todo_all_todos'):
5320 env.todo_all_todos = []
5321 env.todo_all_todos.append({
5322 'docname': env.docname,
5323 'lineno': self.lineno,
5324 'todo': ad[0].deepcopy(),
5325 'target': targetnode,
5326 })
5327
5328 return [targetnode] + ad
5329
5330 Several important things are covered here. First, as you can see, you
5331 can refer to the build environment instance using self.state.docu‐
5332 ment.settings.env.
5333
5334 Then, to act as a link target (from the todolist), the todo directive
5335 needs to return a target node in addition to the todo node. The target
5336 ID (in HTML, this will be the anchor name) is generated by using
5337 env.new_serialno which is returns a new integer directive on each call
5338 and therefore leads to unique target names. The target node is instan‐
5339 tiated without any text (the first two arguments).
5340
5341 An admonition is created using a standard docutils function (wrapped in
5342 Sphinx for docutils cross-version compatibility). The first argument
5343 gives the node class, in our case todo. The third argument gives the
5344 admonition title (use arguments here to let the user specify the
5345 title). A list of nodes is returned from make_admonition.
5346
5347 Then, the todo node is added to the environment. This is needed to be
5348 able to create a list of all todo entries throughout the documentation,
5349 in the place where the author puts a todolist directive. For this
5350 case, the environment attribute todo_all_todos is used (again, the name
5351 should be unique, so it is prefixed by the extension name). It does
5352 not exist when a new environment is created, so the directive must
5353 check and create it if necessary. Various information about the todo
5354 entry's location are stored along with a copy of the node.
5355
5356 In the last line, the nodes that should be put into the doctree are
5357 returned: the target node and the admonition node.
5358
5359 The node structure that the directive returns looks like this:
5360
5361 +--------------------+
5362 | target node |
5363 +--------------------+
5364 +--------------------+
5365 | todo node |
5366 +--------------------+
5367 \__+--------------------+
5368 | admonition title |
5369 +--------------------+
5370 | paragraph |
5371 +--------------------+
5372 | ... |
5373 +--------------------+
5374
5375 The Event Handlers
5376 Finally, let's look at the event handlers. First, the one for the
5377 env-purge-doc event:
5378
5379 def purge_todos(app, env, docname):
5380 if not hasattr(env, 'todo_all_todos'):
5381 return
5382 env.todo_all_todos = [todo for todo in env.todo_all_todos
5383 if todo['docname'] != docname]
5384
5385 Since we store information from source files in the environment, which
5386 is persistent, it may become out of date when the source file changes.
5387 Therefore, before each source file is read, the environment's records
5388 of it are cleared, and the env-purge-doc event gives extensions a
5389 chance to do the same. Here we clear out all todos whose docname
5390 matches the given one from the todo_all_todos list. If there are todos
5391 left in the document, they will be added again during parsing.
5392
5393 The other handler belongs to the doctree-resolved event. This event is
5394 emitted at the end of phase 3 and allows custom resolving to be done:
5395
5396 def process_todo_nodes(app, doctree, fromdocname):
5397 if not app.config.todo_include_todos:
5398 for node in doctree.traverse(todo):
5399 node.parent.remove(node)
5400
5401 # Replace all todolist nodes with a list of the collected todos.
5402 # Augment each todo with a backlink to the original location.
5403 env = app.builder.env
5404
5405 for node in doctree.traverse(todolist):
5406 if not app.config.todo_include_todos:
5407 node.replace_self([])
5408 continue
5409
5410 content = []
5411
5412 for todo_info in env.todo_all_todos:
5413 para = nodes.paragraph()
5414 filename = env.doc2path(todo_info['docname'], base=None)
5415 description = (
5416 _('(The original entry is located in %s, line %d and can be found ') %
5417 (filename, todo_info['lineno']))
5418 para += nodes.Text(description, description)
5419
5420 # Create a reference
5421 newnode = nodes.reference('', '')
5422 innernode = nodes.emphasis(_('here'), _('here'))
5423 newnode['refdocname'] = todo_info['docname']
5424 newnode['refuri'] = app.builder.get_relative_uri(
5425 fromdocname, todo_info['docname'])
5426 newnode['refuri'] += '#' + todo_info['target']['refid']
5427 newnode.append(innernode)
5428 para += newnode
5429 para += nodes.Text('.)', '.)')
5430
5431 # Insert into the todolist
5432 content.append(todo_info['todo'])
5433 content.append(para)
5434
5435 node.replace_self(content)
5436
5437 It is a bit more involved. If our new "todo_include_todos" config
5438 value is false, all todo and todolist nodes are removed from the docu‐
5439 ments.
5440
5441 If not, todo nodes just stay where and how they are. Todolist nodes
5442 are replaced by a list of todo entries, complete with backlinks to the
5443 location where they come from. The list items are composed of the
5444 nodes from the todo entry and docutils nodes created on the fly: a
5445 paragraph for each entry, containing text that gives the location, and
5446 a link (reference node containing an italic node) with the backrefer‐
5447 ence. The reference URI is built by app.builder.get_relative_uri which
5448 creates a suitable URI depending on the used builder, and appending the
5449 todo node's (the target's) ID as the anchor name.
5450
5451 Extension API
5452 Each Sphinx extension is a Python module with at least a setup() func‐
5453 tion. This function is called at initialization time with one argu‐
5454 ment, the application object representing the Sphinx process. This
5455 application object has the following public API:
5456
5457 Sphinx.setup_extension(name)
5458 Load the extension given by the module name. Use this if your
5459 extension needs the features provided by another extension.
5460
5461 Sphinx.add_builder(builder)
5462 Register a new builder. builder must be a class that inherits
5463 from Builder.
5464
5465 Sphinx.add_config_value(name, default, rebuild)
5466 Register a configuration value. This is necessary for Sphinx to
5467 recognize new values and set default values accordingly. The
5468 name should be prefixed with the extension name, to avoid
5469 clashes. The default value can be any Python object. The
5470 string value rebuild must be one of those values:
5471
5472 · 'env' if a change in the setting only takes effect when a doc‐
5473 ument is parsed -- this means that the whole environment must
5474 be rebuilt.
5475
5476 · 'html' if a change in the setting needs a full rebuild of HTML
5477 documents.
5478
5479 · '' if a change in the setting will not need any special
5480 rebuild.
5481
5482 Changed in version 0.4: If the default value is a callable, it
5483 will be called with the config object as its argument in order
5484 to get the default value. This can be used to implement config
5485 values whose default depends on other values.
5486
5487 Changed in version 0.6: Changed rebuild from a simple boolean
5488 (equivalent to '' or 'env') to a string. However, booleans are
5489 still accepted and converted internally.
5490
5491 Sphinx.add_domain(domain)
5492 Make the given domain (which must be a class; more precisely, a
5493 subclass of Domain) known to Sphinx.
5494
5495 New in version 1.0.
5496
5497 Sphinx.override_domain(domain)
5498 Make the given domain class known to Sphinx, assuming that there
5499 is already a domain with its .name. The new domain must be a
5500 subclass of the existing one.
5501
5502 New in version 1.0.
5503
5504 Sphinx.add_index_to_domain(domain, index)
5505 Add a custom index class to the domain named domain. index must
5506 be a subclass of Index.
5507
5508 New in version 1.0.
5509
5510 Sphinx.add_event(name)
5511 Register an event called name. This is needed to be able to
5512 emit it.
5513
5514 Sphinx.add_node(node, **kwds)
5515 Register a Docutils node class. This is necessary for Docutils
5516 internals. It may also be used in the future to validate nodes
5517 in the parsed documents.
5518
5519 Node visitor functions for the Sphinx HTML, LaTeX, text and man‐
5520 page writers can be given as keyword arguments: the keyword must
5521 be one or more of 'html', 'latex', 'text', 'man', 'texinfo', the
5522 value a 2-tuple of (visit, depart) methods. depart can be None
5523 if the visit function raises docutils.nodes.SkipNode. Example:
5524
5525 class math(docutils.nodes.Element): pass
5526
5527 def visit_math_html(self, node):
5528 self.body.append(self.starttag(node, 'math'))
5529 def depart_math_html(self, node):
5530 self.body.append('</math>')
5531
5532 app.add_node(math, html=(visit_math_html, depart_math_html))
5533
5534 Obviously, translators for which you don't specify visitor meth‐
5535 ods will choke on the node when encountered in a document to
5536 translate.
5537
5538 Changed in version 0.5: Added the support for keyword arguments
5539 giving visit functions.
5540
5541 Sphinx.add_directive(name, func, content, arguments, **options)
5542
5543 Sphinx.add_directive(name, directiveclass)
5544 Register a Docutils directive. name must be the prospective
5545 directive name. There are two possible ways to write a direc‐
5546 tive:
5547
5548 · In the docutils 0.4 style, obj is the directive function.
5549 content, arguments and options are set as attributes on the
5550 function and determine whether the directive has content,
5551 arguments and options, respectively. This style is depre‐
5552 cated.
5553
5554 · In the docutils 0.5 style, directiveclass is the directive
5555 class. It must already have attributes named has_content,
5556 required_arguments, optional_arguments, final_argument_white‐
5557 space and option_spec that correspond to the options for the
5558 function way. See the Docutils docs for details.
5559
5560 The directive class must inherit from the class docu‐
5561 tils.parsers.rst.Directive.
5562
5563 For example, the (already existing) literalinclude directive
5564 would be added like this:
5565
5566 from docutils.parsers.rst import directives
5567 add_directive('literalinclude', literalinclude_directive,
5568 content = 0, arguments = (1, 0, 0),
5569 linenos = directives.flag,
5570 language = direcitves.unchanged,
5571 encoding = directives.encoding)
5572
5573 Changed in version 0.6: Docutils 0.5-style directive classes are
5574 now supported.
5575
5576 Sphinx.add_directive_to_domain(domain, name, func, content, arguments,
5577 **options)
5578
5579 Sphinx.add_directive_to_domain(domain, name, directiveclass)
5580 Like add_directive(), but the directive is added to the domain
5581 named domain.
5582
5583 New in version 1.0.
5584
5585 Sphinx.add_role(name, role)
5586 Register a Docutils role. name must be the role name that
5587 occurs in the source, role the role function (see the Docutils
5588 documentation on details).
5589
5590 Sphinx.add_role_to_domain(domain, name, role)
5591 Like add_role(), but the role is added to the domain named
5592 domain.
5593
5594 New in version 1.0.
5595
5596 Sphinx.add_generic_role(name, nodeclass)
5597 Register a Docutils role that does nothing but wrap its contents
5598 in the node given by nodeclass.
5599
5600 New in version 0.6.
5601
5602 Sphinx.add_object_type(directivename, rolename, indextemplate='',
5603 parse_node=None, ref_nodeclass=None, objname='', doc_field_types=[])
5604 This method is a very convenient way to add a new object type
5605 that can be cross-referenced. It will do this:
5606
5607 · Create a new directive (called directivename) for documenting
5608 an object. It will automatically add index entries if index‐
5609 template is nonempty; if given, it must contain exactly one
5610 instance of %s. See the example below for how the template
5611 will be interpreted.
5612
5613 · Create a new role (called rolename) to cross-reference to
5614 these object descriptions.
5615
5616 · If you provide parse_node, it must be a function that takes a
5617 string and a docutils node, and it must populate the node with
5618 children parsed from the string. It must then return the name
5619 of the item to be used in cross-referencing and index entries.
5620 See the conf.py file in the source for this documentation for
5621 an example.
5622
5623 · The objname (if not given, will default to directivename)
5624 names the type of object. It is used when listing objects,
5625 e.g. in search results.
5626
5627 For example, if you have this call in a custom Sphinx extension:
5628
5629 app.add_object_type('directive', 'dir', 'pair: %s; directive')
5630
5631 you can use this markup in your documents:
5632
5633 .. rst:directive:: function
5634
5635 Document a function.
5636
5637 <...>
5638
5639 See also the :rst:dir:`function` directive.
5640
5641 For the directive, an index entry will be generated as if you
5642 had prepended
5643
5644 .. index:: pair: function; directive
5645
5646 The reference node will be of class literal (so it will be ren‐
5647 dered in a proportional font, as appropriate for code) unless
5648 you give the ref_nodeclass argument, which must be a docutils
5649 node class (most useful are docutils.nodes.emphasis or docu‐
5650 tils.nodes.strong -- you can also use docutils.nodes.generated
5651 if you want no further text decoration).
5652
5653 For the role content, you have the same syntactical possibili‐
5654 ties as for standard Sphinx roles (see xref-syntax).
5655
5656 This method is also available under the deprecated alias
5657 add_description_unit.
5658
5659 Sphinx.add_crossref_type(directivename, rolename, indextemplate='',
5660 ref_nodeclass=None, objname='')
5661 This method is very similar to add_object_type() except that the
5662 directive it generates must be empty, and will produce no out‐
5663 put.
5664
5665 That means that you can add semantic targets to your sources,
5666 and refer to them using custom roles instead of generic ones
5667 (like ref). Example call:
5668
5669 app.add_crossref_type('topic', 'topic', 'single: %s', docutils.nodes.emphasis)
5670
5671 Example usage:
5672
5673 .. topic:: application API
5674
5675 The application API
5676 -------------------
5677
5678 <...>
5679
5680 See also :topic:`this section <application API>`.
5681
5682 (Of course, the element following the topic directive needn't be
5683 a section.)
5684
5685 Sphinx.add_transform(transform)
5686 Add the standard docutils Transform subclass transform to the
5687 list of transforms that are applied after Sphinx parses a reST
5688 document.
5689
5690 Sphinx.add_javascript(filename)
5691 Add filename to the list of JavaScript files that the default
5692 HTML template will include. The filename must be relative to
5693 the HTML static path, see the docs for the config value. A full
5694 URI with scheme, like http://example.org/foo.js, is also sup‐
5695 ported.
5696
5697 New in version 0.5.
5698
5699 Sphinx.add_stylesheet(filename)
5700 Add filename to the list of CSS files that the default HTML tem‐
5701 plate will include. Like for add_javascript(), the filename
5702 must be relative to the HTML static path, or a full URI with
5703 scheme.
5704
5705 New in version 1.0.
5706
5707 Sphinx.add_lexer(alias, lexer)
5708 Use lexer, which must be an instance of a Pygments lexer class,
5709 to highlight code blocks with the given language alias.
5710
5711 New in version 0.6.
5712
5713 Sphinx.add_autodocumenter(cls)
5714 Add cls as a new documenter class for the sphinx.ext.autodoc
5715 extension. It must be a subclass of sphinx.ext.autodoc.Docu‐
5716 menter. This allows to auto-document new types of objects. See
5717 the source of the autodoc module for examples on how to subclass
5718 Documenter.
5719
5720 New in version 0.6.
5721
5722 Sphinx.add_autodoc_attrgetter(type, getter)
5723 Add getter, which must be a function with an interface compati‐
5724 ble to the getattr() builtin, as the autodoc attribute getter
5725 for objects that are instances of type. All cases where autodoc
5726 needs to get an attribute of a type are then handled by this
5727 function instead of getattr().
5728
5729 New in version 0.6.
5730
5731 Sphinx.add_search_language(cls)
5732 Add cls, which must be a subclass of sphinx.search.Search‐
5733 Language, as a support language for building the HTML full-text
5734 search index. The class must have a lang attribute that indi‐
5735 cates the language it should be used for. See html_search_lan‐
5736 guage.
5737
5738 New in version 1.1.
5739
5740 Sphinx.connect(event, callback)
5741 Register callback to be called when event is emitted. For
5742 details on available core events and the arguments of callback
5743 functions, please see events.
5744
5745 The method returns a "listener ID" that can be used as an argu‐
5746 ment to disconnect().
5747
5748 Sphinx.disconnect(listener_id)
5749 Unregister callback listener_id.
5750
5751 Sphinx.emit(event, *arguments)
5752 Emit event and pass arguments to the callback functions. Return
5753 the return values of all callbacks as a list. Do not emit core
5754 Sphinx events in extensions!
5755
5756 Sphinx.emit_firstresult(event, *arguments)
5757 Emit event and pass arguments to the callback functions. Return
5758 the result of the first callback that doesn't return None.
5759
5760 New in version 0.5.
5761
5762 Sphinx.require_sphinx(version)
5763 Compare version (which must be a major.minor version string,
5764 e.g. '1.1') with the version of the running Sphinx, and abort
5765 the build when it is too old.
5766
5767 New in version 1.0.
5768
5769 exception sphinx.application.ExtensionError
5770 All these functions raise this exception if something went wrong
5771 with the extension API.
5772
5773 Examples of using the Sphinx extension API can be seen in the
5774 sphinx.ext package.
5775
5776 Sphinx core events
5777 These events are known to the core. The arguments shown are given to
5778 the registered event handlers.
5779
5780 builder-inited(app)
5781 Emitted when the builder object has been created. It is avail‐
5782 able as app.builder.
5783
5784 env-get-outdated(app, env, added, changed, removed)
5785 Emitted when the environment determines which source files have
5786 changed and should be re-read. added, changed and removed are
5787 sets of docnames that the environment has determined. You can
5788 return a list of docnames to re-read in addition to these.
5789
5790 New in version 1.1.
5791
5792 env-purge-doc(app, env, docname)
5793 Emitted when all traces of a source file should be cleaned from
5794 the environment, that is, if the source file is removed or
5795 before it is freshly read. This is for extensions that keep
5796 their own caches in attributes of the environment.
5797
5798 For example, there is a cache of all modules on the environment.
5799 When a source file has been changed, the cache's entries for the
5800 file are cleared, since the module declarations could have been
5801 removed from the file.
5802
5803 New in version 0.5.
5804
5805 source-read(app, docname, source)
5806 Emitted when a source file has been read. The source argument
5807 is a list whose single element is the contents of the source
5808 file. You can process the contents and replace this item to
5809 implement source-level transformations.
5810
5811 For example, if you want to use $ signs to delimit inline math,
5812 like in LaTeX, you can use a regular expression to replace $...$
5813 by :math:`...`.
5814
5815 New in version 0.5.
5816
5817 doctree-read(app, doctree)
5818 Emitted when a doctree has been parsed and read by the environ‐
5819 ment, and is about to be pickled. The doctree can be modified
5820 in-place.
5821
5822 missing-reference(app, env, node, contnode)
5823 Emitted when a cross-reference to a Python module or object can‐
5824 not be resolved. If the event handler can resolve the refer‐
5825 ence, it should return a new docutils node to be inserted in the
5826 document tree in place of the node node. Usually this node is a
5827 reference node containing contnode as a child.
5828
5829 Parameters
5830
5831 · env -- The build environment (app.builder.env).
5832
5833 · node -- The pending_xref node to be resolved. Its
5834 attributes reftype, reftarget, modname and classname
5835 attributes determine the type and target of the refer‐
5836 ence.
5837
5838 · contnode -- The node that carries the text and format‐
5839 ting inside the future reference and should be a child
5840 of the returned reference node.
5841
5842 New in version 0.5.
5843
5844 doctree-resolved(app, doctree, docname)
5845 Emitted when a doctree has been "resolved" by the environment,
5846 that is, all references have been resolved and TOCs have been
5847 inserted. The doctree can be modified in place.
5848
5849 Here is the place to replace custom nodes that don't have visi‐
5850 tor methods in the writers, so that they don't cause errors when
5851 the writers encounter them.
5852
5853 env-updated(app, env)
5854 Emitted when the update() method of the build environment has
5855 completed, that is, the environment and all doctrees are now
5856 up-to-date.
5857
5858 New in version 0.5.
5859
5860 html-collect-pages(app)
5861 Emitted when the HTML builder is starting to write non-document
5862 pages. You can add pages to write by returning an iterable from
5863 this event consisting of (pagename, context, templatename).
5864
5865 New in version 1.0.
5866
5867 html-page-context(app, pagename, templatename, context, doctree)
5868 Emitted when the HTML builder has created a context dictionary
5869 to render a template with -- this can be used to add custom ele‐
5870 ments to the context.
5871
5872 The pagename argument is the canonical name of the page being
5873 rendered, that is, without .html suffix and using slashes as
5874 path separators. The templatename is the name of the template
5875 to render, this will be 'page.html' for all pages from reST doc‐
5876 uments.
5877
5878 The context argument is a dictionary of values that are given to
5879 the template engine to render the page and can be modified to
5880 include custom values. Keys must be strings.
5881
5882 The doctree argument will be a doctree when the page is created
5883 from a reST documents; it will be None when the page is created
5884 from an HTML template alone.
5885
5886 New in version 0.4.
5887
5888 build-finished(app, exception)
5889 Emitted when a build has finished, before Sphinx exits, usually
5890 used for cleanup. This event is emitted even when the build
5891 process raised an exception, given as the exception argument.
5892 The exception is reraised in the application after the event
5893 handlers have run. If the build process raised no exception,
5894 exception will be None. This allows to customize cleanup
5895 actions depending on the exception status.
5896
5897 New in version 0.5.
5898
5899 The template bridge
5900 class sphinx.application.TemplateBridge
5901 This class defines the interface for a "template bridge", that
5902 is, a class that renders templates given a template name and a
5903 context.
5904
5905 init(builder, theme=None, dirs=None)
5906 Called by the builder to initialize the template system.
5907
5908 builder is the builder object; you'll probably want to
5909 look at the value of builder.config.templates_path.
5910
5911 theme is a sphinx.theming.Theme object or None; in the
5912 latter case, dirs can be list of fixed directories to
5913 look for templates.
5914
5915 newest_template_mtime()
5916 Called by the builder to determine if output files are
5917 outdated because of template changes. Return the mtime
5918 of the newest template file that was changed. The
5919 default implementation returns 0.
5920
5921 render(template, context)
5922 Called by the builder to render a template given as a
5923 filename with a specified context (a Python dictionary).
5924
5925 render_string(template, context)
5926 Called by the builder to render a template given as a
5927 string with a specified context (a Python dictionary).
5928
5929 Domain API
5930 class sphinx.domains.Domain(env)
5931 A Domain is meant to be a group of "object" description direc‐
5932 tives for objects of a similar nature, and corresponding roles
5933 to create references to them. Examples would be Python modules,
5934 classes, functions etc., elements of a templating language,
5935 Sphinx roles and directives, etc.
5936
5937 Each domain has a separate storage for information about exist‐
5938 ing objects and how to reference them in self.data, which must
5939 be a dictionary. It also must implement several functions that
5940 expose the object information in a uniform way to parts of
5941 Sphinx that allow the user to reference or search for objects in
5942 a domain-agnostic way.
5943
5944 About self.data: since all object and cross-referencing informa‐
5945 tion is stored on a BuildEnvironment instance, the domain.data
5946 object is also stored in the env.domaindata dict under the key
5947 domain.name. Before the build process starts, every active
5948 domain is instantiated and given the environment object; the
5949 domaindata dict must then either be nonexistent or a dictionary
5950 whose 'version' key is equal to the domain class' data_version
5951 attribute. Otherwise, IOError is raised and the pickled envi‐
5952 ronment is discarded.
5953
5954 clear_doc(docname)
5955 Remove traces of a document in the domain-specific inven‐
5956 tories.
5957
5958 directive(name)
5959 Return a directive adapter class that always gives the
5960 registered directive its full name ('domain:name') as
5961 self.name.
5962
5963 get_objects()
5964 Return an iterable of "object descriptions", which are
5965 tuples with five items:
5966
5967 · name -- fully qualified name
5968
5969 · dispname -- name to display when searching/linking
5970
5971 · type -- object type, a key in self.object_types
5972
5973 · docname -- the document where it is to be found
5974
5975 · anchor -- the anchor name for the object
5976
5977 · priority -- how "important" the object is (determines
5978 placement in search results)
5979
5980 · 1: default priority (placed before full-text matches)
5981
5982 · 0: object is important (placed before default-prior‐
5983 ity objects)
5984
5985 · 2: object is unimportant (placed after full-text
5986 matches)
5987
5988 · -1: object should not show up in search at all
5989
5990 get_type_name(type, primary=False)
5991 Return full name for given ObjType.
5992
5993 process_doc(env, docname, document)
5994 Process a document after it is read by the environment.
5995
5996 resolve_xref(env, fromdocname, builder, typ, target, node, con‐
5997 tnode)
5998 Resolve the pending_xref node with the given typ and tar‐
5999 get.
6000
6001 This method should return a new node, to replace the xref
6002 node, containing the contnode which is the markup content
6003 of the cross-reference.
6004
6005 If no resolution can be found, None can be returned; the
6006 xref node will then given to the 'missing-reference'
6007 event, and if that yields no resolution, replaced by con‐
6008 tnode.
6009
6010 The method can also raise sphinx.environment.NoUri to
6011 suppress the 'missing-reference' event being emitted.
6012
6013 role(name)
6014 Return a role adapter function that always gives the reg‐
6015 istered role its full name ('domain:name') as the first
6016 argument.
6017
6018 dangling_warnings = {}
6019 role name -> a warning message if reference is missing
6020
6021 data_version = 0
6022 data version, bump this when the format of self.data
6023 changes
6024
6025 directives = {}
6026 directive name -> directive class
6027
6028 indices = []
6029 a list of Index subclasses
6030
6031 initial_data = {}
6032 data value for a fresh environment
6033
6034 label = ''
6035 domain label: longer, more descriptive (used in messages)
6036
6037 name = ''
6038 domain name: should be short, but unique
6039
6040 object_types = {}
6041 type (usually directive) name -> ObjType instance
6042
6043 roles = {}
6044 role name -> role callable
6045
6046 class sphinx.domains.ObjType(lname, *roles, **attrs)
6047 An ObjType is the description for a type of object that a domain
6048 can document. In the object_types attribute of Domain sub‐
6049 classes, object type names are mapped to instances of this
6050 class.
6051
6052 Constructor arguments:
6053
6054 · lname: localized name of the type (do not include domain name)
6055
6056 · roles: all the roles that can refer to an object of this type
6057
6058 · attrs: object attributes -- currently only "searchprio" is
6059 known, which defines the object's priority in the full-text
6060 search index, see Domain.get_objects().
6061
6062 class sphinx.domains.Index(domain)
6063 An Index is the description for a domain-specific index. To add
6064 an index to a domain, subclass Index, overriding the three name
6065 attributes:
6066
6067 · name is an identifier used for generating file names.
6068
6069 · localname is the section title for the index.
6070
6071 · shortname is a short name for the index, for use in the rela‐
6072 tion bar in HTML output. Can be empty to disable entries in
6073 the relation bar.
6074
6075 and providing a generate() method. Then, add the index class to
6076 your domain's indices list. Extensions can add indices to
6077 existing domains using add_index_to_domain().
6078
6079 generate(docnames=None)
6080 Return entries for the index given by name. If docnames
6081 is given, restrict to entries referring to these doc‐
6082 names.
6083
6084 The return value is a tuple of (content, collapse), where
6085 collapse is a boolean that determines if sub-entries
6086 should start collapsed (for output formats that support
6087 collapsing sub-entries).
6088
6089 content is a sequence of (letter, entries) tuples, where
6090 letter is the "heading" for the given entries, usually
6091 the starting letter.
6092
6093 entries is a sequence of single entries, where a single
6094 entry is a sequence [name, subtype, docname, anchor,
6095 extra, qualifier, descr]. The items in this sequence
6096 have the following meaning:
6097
6098 · name -- the name of the index entry to be displayed
6099
6100 · subtype -- sub-entry related type: 0 -- normal entry 1
6101 -- entry with sub-entries 2 -- sub-entry
6102
6103 · docname -- docname where the entry is located
6104
6105 · anchor -- anchor for the entry within docname
6106
6107 · extra -- extra info for the entry
6108
6109 · qualifier -- qualifier for the description
6110
6111 · descr -- description for the entry
6112
6113 Qualifier and description are not rendered e.g. in LaTeX
6114 output.
6115
6116 Writing new builders
6117 Todo
6118 Expand this.
6119
6120 class sphinx.builders.Builder
6121 This is the base class for all builders.
6122
6123 These methods are predefined and will be called from the appli‐
6124 cation:
6125
6126 get_relative_uri(from_, to, typ=None)
6127 Return a relative URI between two source filenames.
6128
6129 May raise environment.NoUri if there's no way to return a
6130 sensible URI.
6131
6132 build_all()
6133 Build all source files.
6134
6135 build_specific(filenames)
6136 Only rebuild as much as needed for changes in the file‐
6137 names.
6138
6139 build_update()
6140 Only rebuild what was changed or added since last build.
6141
6142 build(docnames, summary=None, method='update')
6143 Main build method.
6144
6145 First updates the environment, and then calls write().
6146
6147 These methods can be overridden in concrete builder classes:
6148
6149 init() Load necessary templates and perform initialization. The
6150 default implementation does nothing.
6151
6152 get_outdated_docs()
6153 Return an iterable of output files that are outdated, or
6154 a string describing what an update build will build.
6155
6156 If the builder does not output individual files corre‐
6157 sponding to source files, return a string here. If it
6158 does, return an iterable of those files that need to be
6159 written.
6160
6161 get_target_uri(docname, typ=None)
6162 Return the target URI for a document name.
6163
6164 typ can be used to qualify the link characteristic for
6165 individual builders.
6166
6167 prepare_writing(docnames)
6168
6169 write_doc(docname, doctree)
6170
6171 finish()
6172 Finish the building process.
6173
6174 The default implementation does nothing.
6175
6176 Builtin Sphinx extensions
6177 These extensions are built in and can be activated by respective
6178 entries in the extensions configuration value:
6179
6180 sphinx.ext.autodoc -- Include documentation from docstrings
6181 This extension can import the modules you are documenting, and pull in
6182 documentation from docstrings in a semi-automatic way.
6183
6184 NOTE:
6185 For Sphinx (actually, the Python interpreter that executes Sphinx)
6186 to find your module, it must be importable. That means that the
6187 module or the package must be in one of the directories on sys.path
6188 -- adapt your sys.path in the configuration file accordingly.
6189
6190 For this to work, the docstrings must of course be written in correct
6191 reStructuredText. You can then use all of the usual Sphinx markup in
6192 the docstrings, and it will end up correctly in the documentation.
6193 Together with hand-written documentation, this technique eases the pain
6194 of having to maintain two locations for documentation, while at the
6195 same time avoiding auto-generated-looking pure API documentation.
6196
6197 autodoc provides several directives that are versions of the usual
6198 py:module, py:class and so forth. On parsing time, they import the
6199 corresponding module and extract the docstring of the given objects,
6200 inserting them into the page source under a suitable py:module,
6201 py:class etc. directive.
6202
6203 NOTE:
6204 Just as py:class respects the current py:module, autoclass will also
6205 do so. Likewise, automethod will respect the current py:class.
6206
6207 .. automodule::
6208
6209 .. autoclass::
6210
6211 .. autoexception::
6212 Document a module, class or exception. All three directives
6213 will by default only insert the docstring of the object itself:
6214
6215 .. autoclass:: Noodle
6216
6217 will produce source like this:
6218
6219 .. class:: Noodle
6220
6221 Noodle's docstring.
6222
6223 The "auto" directives can also contain content of their own, it
6224 will be inserted into the resulting non-auto directive source
6225 after the docstring (but before any automatic member documenta‐
6226 tion).
6227
6228 Therefore, you can also mix automatic and non-automatic member
6229 documentation, like so:
6230
6231 .. autoclass:: Noodle
6232 :members: eat, slurp
6233
6234 .. method:: boil(time=10)
6235
6236 Boil the noodle *time* minutes.
6237
6238 Options and advanced usage
6239
6240 · If you want to automatically document members, there's a mem‐
6241 bers option:
6242
6243 .. automodule:: noodle
6244 :members:
6245
6246 will document all module members (recursively), and
6247
6248 .. autoclass:: Noodle
6249 :members:
6250
6251 will document all non-private member functions and properties
6252 (that is, those whose name doesn't start with _).
6253
6254 For modules, __all__ will be respected when looking for mem‐
6255 bers; the order of the members will also be the order in
6256 __all__.
6257
6258 You can also give an explicit list of members; only these will
6259 then be documented:
6260
6261 .. autoclass:: Noodle
6262 :members: eat, slurp
6263
6264 · If you want to make the members option (or other flag options
6265 described below) the default, see autodoc_default_flags.
6266
6267 · Members without docstrings will be left out, unless you give
6268 the undoc-members flag option:
6269
6270 .. automodule:: noodle
6271 :members:
6272 :undoc-members:
6273
6274 · "Private" members (that is, those named like _private or
6275 __private) will be included if the private-members flag option
6276 is given.
6277
6278 New in version 1.1.
6279
6280 · Python "special" members (that is, those named like __spe‐
6281 cial__) will be included if the special-members flag option is
6282 given:
6283
6284 .. autoclass:: my.Class
6285 :members:
6286 :private-members:
6287 :special-members:
6288
6289 would document both "private" and "special" members of the
6290 class.
6291
6292 New in version 1.1.
6293
6294 · For classes and exceptions, members inherited from base
6295 classes will be left out when documenting all members, unless
6296 you give the inherited-members flag option, in addition to
6297 members:
6298
6299 .. autoclass:: Noodle
6300 :members:
6301 :inherited-members:
6302
6303 This can be combined with undoc-members to document all avail‐
6304 able members of the class or module.
6305
6306 Note: this will lead to markup errors if the inherited members
6307 come from a module whose docstrings are not reST formatted.
6308
6309 New in version 0.3.
6310
6311 · It's possible to override the signature for explicitly docu‐
6312 mented callable objects (functions, methods, classes) with the
6313 regular syntax that will override the signature gained from
6314 introspection:
6315
6316 .. autoclass:: Noodle(type)
6317
6318 .. automethod:: eat(persona)
6319
6320 This is useful if the signature from the method is hidden by a
6321 decorator.
6322
6323 New in version 0.4.
6324
6325 · The automodule, autoclass and autoexception directives also
6326 support a flag option called show-inheritance. When given, a
6327 list of base classes will be inserted just below the class
6328 signature (when used with automodule, this will be inserted
6329 for every class that is documented in the module).
6330
6331 New in version 0.4.
6332
6333 · All autodoc directives support the noindex flag option that
6334 has the same effect as for standard py:function etc. direc‐
6335 tives: no index entries are generated for the documented
6336 object (and all autodocumented members).
6337
6338 New in version 0.4.
6339
6340 · automodule also recognizes the synopsis, platform and depre‐
6341 cated options that the standard py:module directive supports.
6342
6343 New in version 0.5.
6344
6345 · automodule and autoclass also has an member-order option that
6346 can be used to override the global value of autodoc_mem‐
6347 ber_order for one directive.
6348
6349 New in version 0.6.
6350
6351 · The directives supporting member documentation also have a
6352 exclude-members option that can be used to exclude single mem‐
6353 ber names from documentation, if all members are to be docu‐
6354 mented.
6355
6356 New in version 0.6.
6357
6358 NOTE:
6359 In an automodule directive with the members option set, only
6360 module members whose __module__ attribute is equal to the
6361 module name as given to automodule will be documented. This
6362 is to prevent documentation of imported classes or functions.
6363
6364 .. autofunction::
6365
6366 .. autodata::
6367
6368 .. automethod::
6369
6370 .. autoattribute::
6371 These work exactly like autoclass etc., but do not offer the
6372 options used for automatic member documentation.
6373
6374 For module data members and class attributes, documentation can
6375 either be put into a special-formatted comment, or in a doc‐
6376 string after the definition. Comments need to be either on a
6377 line of their own before the definition, or immediately after
6378 the assignment on the same line. The latter form is restricted
6379 to one line only.
6380
6381 This means that in the following class definition, all
6382 attributes can be autodocumented:
6383
6384 class Foo:
6385 """Docstring for class Foo."""
6386
6387 #: Doc comment for class attribute Foo.bar.
6388 #: It can have multiple lines.
6389 bar = 1
6390
6391 flox = 1.5 #: Doc comment for Foo.flox. One line only.
6392
6393 baz = 2
6394 """Docstring for class attribute Foo.baz."""
6395
6396 def __init__(self):
6397 #: Doc comment for instance attribute qux.
6398 self.qux = 3
6399
6400 self.spam = 4
6401 """Docstring for instance attribute spam."""
6402
6403 Changed in version 0.6: autodata and autoattribute can now
6404 extract docstrings.
6405
6406 Changed in version 1.1: Comment docs are now allowed on the same
6407 line after an assignment.
6408
6409 NOTE:
6410 If you document decorated functions or methods, keep in mind
6411 that autodoc retrieves its docstrings by importing the module
6412 and inspecting the __doc__ attribute of the given function or
6413 method. That means that if a decorator replaces the deco‐
6414 rated function with another, it must copy the original
6415 __doc__ to the new function.
6416
6417 From Python 2.5, functools.wraps() can be used to create
6418 well-behaved decorating functions.
6419
6420 There are also new config values that you can set:
6421
6422 autoclass_content
6423 This value selects what content will be inserted into the main
6424 body of an autoclass directive. The possible values are:
6425
6426 "class"
6427 Only the class' docstring is inserted. This is the
6428 default. You can still document __init__ as a separate
6429 method using automethod or the members option to auto‐
6430 class.
6431
6432 "both" Both the class' and the __init__ method's docstring are
6433 concatenated and inserted.
6434
6435 "init" Only the __init__ method's docstring is inserted.
6436
6437 New in version 0.3.
6438
6439 autodoc_member_order
6440 This value selects if automatically documented members are
6441 sorted alphabetical (value 'alphabetical'), by member type
6442 (value 'groupwise') or by source order (value 'bysource'). The
6443 default is alphabetical.
6444
6445 Note that for source order, the module must be a Python module
6446 with the source code available.
6447
6448 New in version 0.6.
6449
6450 Changed in version 1.0: Support for 'bysource'.
6451
6452 autodoc_default_flags
6453 This value is a list of autodoc directive flags that should be
6454 automatically applied to all autodoc directives. The supported
6455 flags are 'members', 'undoc-members', 'private-members', 'spe‐
6456 cial-members', 'inherited-members' and 'show-inheritance'.
6457
6458 If you set one of these flags in this config value, you can use
6459 a negated form, 'no-flag', in an autodoc directive, to disable
6460 it once. For example, if autodoc_default_flags is set to ['mem‐
6461 bers', 'undoc-members'], and you write a directive like this:
6462
6463 .. automodule:: foo
6464 :no-undoc-members:
6465
6466 the directive will be interpreted as if only :members: was
6467 given.
6468
6469 New in version 1.0.
6470
6471 autodoc_docstring_signature
6472 Functions imported from C modules cannot be introspected, and
6473 therefore the signature for such functions cannot be automati‐
6474 cally determined. However, it is an often-used convention to
6475 put the signature into the first line of the function's doc‐
6476 string.
6477
6478 If this boolean value is set to True (which is the default),
6479 autodoc will look at the first line of the docstring for func‐
6480 tions and methods, and if it looks like a signature, use the
6481 line as the signature and remove it from the docstring content.
6482
6483 New in version 1.1.
6484
6485 Docstring preprocessing
6486 autodoc provides the following additional events:
6487
6488 autodoc-process-docstring(app, what, name, obj, options, lines)
6489 New in version 0.4.
6490
6491 Emitted when autodoc has read and processed a docstring. lines
6492 is a list of strings -- the lines of the processed docstring --
6493 that the event handler can modify in place to change what Sphinx
6494 puts into the output.
6495
6496 Parameters
6497
6498 · app -- the Sphinx application object
6499
6500 · what -- the type of the object which the docstring
6501 belongs to (one of "module", "class", "exception",
6502 "function", "method", "attribute")
6503
6504 · name -- the fully qualified name of the object
6505
6506 · obj -- the object itself
6507
6508 · options -- the options given to the directive: an
6509 object with attributes inherited_members, undoc_mem‐
6510 bers, show_inheritance and noindex that are true if the
6511 flag option of same name was given to the auto direc‐
6512 tive
6513
6514 · lines -- the lines of the docstring, see above
6515
6516 autodoc-process-signature(app, what, name, obj, options, signature,
6517 return_annotation)
6518 New in version 0.5.
6519
6520 Emitted when autodoc has formatted a signature for an object.
6521 The event handler can return a new tuple (signature,
6522 return_annotation) to change what Sphinx puts into the output.
6523
6524 Parameters
6525
6526 · app -- the Sphinx application object
6527
6528 · what -- the type of the object which the docstring
6529 belongs to (one of "module", "class", "exception",
6530 "function", "method", "attribute")
6531
6532 · name -- the fully qualified name of the object
6533
6534 · obj -- the object itself
6535
6536 · options -- the options given to the directive: an
6537 object with attributes inherited_members, undoc_mem‐
6538 bers, show_inheritance and noindex that are true if the
6539 flag option of same name was given to the auto direc‐
6540 tive
6541
6542 · signature -- function signature, as a string of the
6543 form "(parameter_1, parameter_2)", or None if intro‐
6544 spection didn't succeed and signature wasn't specified
6545 in the directive.
6546
6547 · return_annotation -- function return annotation as a
6548 string of the form " -> annotation", or None if there
6549 is no return annotation
6550
6551 The sphinx.ext.autodoc module provides factory functions for commonly
6552 needed docstring processing in event autodoc-process-docstring:
6553
6554 sphinx.ext.autodoc.cut_lines(pre, post=0, what=None)
6555 Return a listener that removes the first pre and last post lines
6556 of every docstring. If what is a sequence of strings, only doc‐
6557 strings of a type in what will be processed.
6558
6559 Use like this (e.g. in the setup() function of conf.py):
6560
6561 from sphinx.ext.autodoc import cut_lines
6562 app.connect('autodoc-process-docstring', cut_lines(4, what=['module']))
6563
6564 This can (and should) be used in place of automodule_skip_lines.
6565
6566 sphinx.ext.autodoc.between(marker, what=None, keepempty=False,
6567 exclude=False)
6568 Return a listener that either keeps, or if exclude is True
6569 excludes, lines between lines that match the marker regular
6570 expression. If no line matches, the resulting docstring would
6571 be empty, so no change will be made unless keepempty is true.
6572
6573 If what is a sequence of strings, only docstrings of a type in
6574 what will be processed.
6575
6576 Skipping members
6577 autodoc allows the user to define a custom method for determining
6578 whether a member should be included in the documentation by using the
6579 following event:
6580
6581 autodoc-skip-member(app, what, name, obj, skip, options)
6582 New in version 0.5.
6583
6584 Emitted when autodoc has to decide whether a member should be
6585 included in the documentation. The member is excluded if a han‐
6586 dler returns True. It is included if the handler returns False.
6587
6588 Parameters
6589
6590 · app -- the Sphinx application object
6591
6592 · what -- the type of the object which the docstring
6593 belongs to (one of "module", "class", "exception",
6594 "function", "method", "attribute")
6595
6596 · name -- the fully qualified name of the object
6597
6598 · obj -- the object itself
6599
6600 · skip -- a boolean indicating if autodoc will skip this
6601 member if the user handler does not override the deci‐
6602 sion
6603
6604 · options -- the options given to the directive: an
6605 object with attributes inherited_members, undoc_mem‐
6606 bers, show_inheritance and noindex that are true if the
6607 flag option of same name was given to the auto direc‐
6608 tive
6609
6610 sphinx.ext.autosummary -- Generate autodoc summaries
6611 New in version 0.6.
6612
6613 This extension generates function/method/attribute summary lists, simi‐
6614 lar to those output e.g. by Epydoc and other API doc generation tools.
6615 This is especially useful when your docstrings are long and detailed,
6616 and putting each one of them on a separate page makes them easier to
6617 read.
6618
6619 The sphinx.ext.autosummary extension does this in two parts:
6620
6621 1. There is an autosummary directive for generating summary listings
6622 that contain links to the documented items, and short summary blurbs
6623 extracted from their docstrings.
6624
6625 2. Optionally, the convenience script sphinx-autogen or the new auto‐
6626 summary_generate config value can be used to generate short "stub"
6627 files for the entries listed in the autosummary directives. These
6628 files by default contain only the corresponding sphinx.ext.autodoc
6629 directive, but can be customized with templates.
6630
6631 .. autosummary::
6632 Insert a table that contains links to documented items, and a
6633 short summary blurb (the first sentence of the docstring) for
6634 each of them.
6635
6636 The autosummary directive can also optionally serve as a toctree
6637 entry for the included items. Optionally, stub .rst files for
6638 these items can also be automatically generated.
6639
6640 For example,
6641
6642 .. currentmodule:: sphinx
6643
6644 .. autosummary::
6645
6646 environment.BuildEnvironment
6647 util.relative_uri
6648
6649 produces a table like this:
6650
6651 ┌──────────────────────────┬────────────────────────────┐
6652 │environment.BuildEnviron‐ │ The environment in which │
6653 │ment(srcdir, ...) │ the ReST files are trans‐ │
6654 │ │ lated. │
6655 ├──────────────────────────┼────────────────────────────┤
6656 │util.relative_uri(base, │ Return a relative URL from │
6657 │to) │ base to to. │
6658 └──────────────────────────┴────────────────────────────┘
6659
6660 Autosummary preprocesses the docstrings and signatures with the
6661 same autodoc-process-docstring and autodoc-process-signature
6662 hooks as autodoc.
6663
6664 Options
6665
6666 · If you want the autosummary table to also serve as a toctree
6667 entry, use the toctree option, for example:
6668
6669 .. autosummary::
6670 :toctree: DIRNAME
6671
6672 sphinx.environment.BuildEnvironment
6673 sphinx.util.relative_uri
6674
6675 The toctree option also signals to the sphinx-autogen script
6676 that stub pages should be generated for the entries listed in
6677 this directive. The option accepts a directory name as an
6678 argument; sphinx-autogen will by default place its output in
6679 this directory. If no argument is given, output is placed in
6680 the same directory as the file that contains the directive.
6681
6682 · If you don't want the autosummary to show function signatures
6683 in the listing, include the nosignatures option:
6684
6685 .. autosummary::
6686 :nosignatures:
6687
6688 sphinx.environment.BuildEnvironment
6689 sphinx.util.relative_uri
6690
6691 · You can specify a custom template with the template option.
6692 For example,
6693
6694 .. autosummary::
6695 :template: mytemplate.rst
6696
6697 sphinx.environment.BuildEnvironment
6698
6699 would use the template mytemplate.rst in your templates_path
6700 to generate the pages for all entries listed. See Customizing
6701 templates below.
6702
6703 New in version 1.0.
6704
6705 sphinx-autogen -- generate autodoc stub pages
6706 The sphinx-autogen script can be used to conveniently generate stub
6707 documentation pages for items included in autosummary listings.
6708
6709 For example, the command
6710
6711 $ sphinx-autogen -o generated *.rst
6712
6713 will read all autosummary tables in the *.rst files that have the :toc‐
6714 tree: option set, and output corresponding stub pages in directory gen‐
6715 erated for all documented items. The generated pages by default con‐
6716 tain text of the form:
6717
6718 sphinx.util.relative_uri
6719 ========================
6720
6721 .. autofunction:: sphinx.util.relative_uri
6722
6723 If the -o option is not given, the script will place the output files
6724 in the directories specified in the :toctree: options.
6725
6726 Generating stub pages automatically
6727 If you do not want to create stub pages with sphinx-autogen, you can
6728 also use this new config value:
6729
6730 autosummary_generate
6731 Boolean indicating whether to scan all found documents for auto‐
6732 summary directives, and to generate stub pages for each.
6733
6734 Can also be a list of documents for which stub pages should be
6735 generated.
6736
6737 The new files will be placed in the directories specified in the
6738 :toctree: options of the directives.
6739
6740 Customizing templates
6741 New in version 1.0.
6742
6743 You can customize the stub page templates, in a similar way as the HTML
6744 Jinja templates, see templating. (TemplateBridge is not supported.)
6745
6746 NOTE:
6747 If you find yourself spending much time tailoring the stub tem‐
6748 plates, this may indicate that it's a better idea to write custom
6749 narrative documentation instead.
6750
6751 Autosummary uses the following template files:
6752
6753 · autosummary/base.rst -- fallback template
6754
6755 · autosummary/module.rst -- template for modules
6756
6757 · autosummary/class.rst -- template for classes
6758
6759 · autosummary/function.rst -- template for functions
6760
6761 · autosummary/attribute.rst -- template for class attributes
6762
6763 · autosummary/method.rst -- template for class methods
6764
6765 The following variables available in the templates:
6766
6767 name Name of the documented object, excluding the module and class
6768 parts.
6769
6770 objname
6771 Name of the documented object, excluding the module parts.
6772
6773 fullname
6774 Full name of the documented object, including module and class
6775 parts.
6776
6777 module Name of the module the documented object belongs to.
6778
6779 class Name of the class the documented object belongs to. Only avail‐
6780 able for methods and attributes.
6781
6782 underline
6783 A string containing len(full_name) * '='.
6784
6785 members
6786 List containing names of all members of the module or class.
6787 Only available for modules and classes.
6788
6789 functions
6790 List containing names of "public" functions in the module.
6791 Here, "public" here means that the name does not start with an
6792 underscore. Only available for modules.
6793
6794 classes
6795 List containing names of "public" classes in the module. Only
6796 available for modules.
6797
6798 exceptions
6799 List containing names of "public" exceptions in the module.
6800 Only available for modules.
6801
6802 methods
6803 List containing names of "public" methods in the class. Only
6804 available for classes.
6805
6806 attributes
6807 List containing names of "public" attributes in the class. Only
6808 available for classes.
6809
6810 NOTE:
6811 You can use the autosummary directive in the stub pages. Stub pages
6812 are generated also based on these directives.
6813
6814 sphinx.ext.doctest -- Test snippets in the documentation
6815 This extension allows you to test snippets in the documentation in a
6816 natural way. It works by collecting specially-marked up code blocks
6817 and running them as doctest tests.
6818
6819 Within one document, test code is partitioned in groups, where each
6820 group consists of:
6821
6822 · zero or more setup code blocks (e.g. importing the module to test)
6823
6824 · one or more test blocks
6825
6826 When building the docs with the doctest builder, groups are collected
6827 for each document and run one after the other, first executing setup
6828 code blocks, then the test blocks in the order they appear in the file.
6829
6830 There are two kinds of test blocks:
6831
6832 · doctest-style blocks mimic interactive sessions by interleaving
6833 Python code (including the interpreter prompt) and output.
6834
6835 · code-output-style blocks consist of an ordinary piece of Python code,
6836 and optionally, a piece of output for that code.
6837
6838 The doctest extension provides four directives. The group argument is
6839 interpreted as follows: if it is empty, the block is assigned to the
6840 group named default. If it is *, the block is assigned to all groups
6841 (including the default group). Otherwise, it must be a comma-separated
6842 list of group names.
6843
6844 .. testsetup:: [group]
6845 A setup code block. This code is not shown in the output for
6846 other builders, but executed before the doctests of the group(s)
6847 it belongs to.
6848
6849 .. testcleanup:: [group]
6850 A cleanup code block. This code is not shown in the output for
6851 other builders, but executed after the doctests of the group(s)
6852 it belongs to.
6853
6854 New in version 1.1.
6855
6856 .. doctest:: [group]
6857 A doctest-style code block. You can use standard doctest flags
6858 for controlling how actual output is compared with what you give
6859 as output. By default, these options are enabled: ELLIPSIS
6860 (allowing you to put ellipses in the expected output that match
6861 anything in the actual output), IGNORE_EXCEPTION_DETAIL (not
6862 comparing tracebacks), DONT_ACCEPT_TRUE_FOR_1 (by default,
6863 doctest accepts "True" in the output where "1" is given -- this
6864 is a relic of pre-Python 2.2 times).
6865
6866 This directive supports two options:
6867
6868 · hide, a flag option, hides the doctest block in other
6869 builders. By default it is shown as a highlighted doctest
6870 block.
6871
6872 · options, a string option, can be used to give a comma-sepa‐
6873 rated list of doctest flags that apply to each example in the
6874 tests. (You still can give explicit flags per example, with
6875 doctest comments, but they will show up in other builders
6876 too.)
6877
6878 Note that like with standard doctests, you have to use
6879 <BLANKLINE> to signal a blank line in the expected output. The
6880 <BLANKLINE> is removed when building presentation output (HTML,
6881 LaTeX etc.).
6882
6883 Also, you can give inline doctest options, like in doctest:
6884
6885 >>> datetime.date.now() # doctest: +SKIP
6886 datetime.date(2008, 1, 1)
6887
6888 They will be respected when the test is run, but stripped from
6889 presentation output.
6890
6891 .. testcode:: [group]
6892 A code block for a code-output-style test.
6893
6894 This directive supports one option:
6895
6896 · hide, a flag option, hides the code block in other builders.
6897 By default it is shown as a highlighted code block.
6898
6899 NOTE:
6900 Code in a testcode block is always executed all at once, no
6901 matter how many statements it contains. Therefore, output
6902 will not be generated for bare expressions -- use print.
6903 Example:
6904
6905 .. testcode::
6906
6907 1+1 # this will give no output!
6908 print 2+2 # this will give output
6909
6910 .. testoutput::
6911
6912 4
6913
6914 Also, please be aware that since the doctest module does not
6915 support mixing regular output and an exception message in the
6916 same snippet, this applies to testcode/testoutput as well.
6917
6918 .. testoutput:: [group]
6919 The corresponding output, or the exception message, for the last
6920 testcode block.
6921
6922 This directive supports two options:
6923
6924 · hide, a flag option, hides the output block in other builders.
6925 By default it is shown as a literal block without highlight‐
6926 ing.
6927
6928 · options, a string option, can be used to give doctest flags
6929 (comma-separated) just like in normal doctest blocks.
6930
6931 Example:
6932
6933 .. testcode::
6934
6935 print 'Output text.'
6936
6937 .. testoutput::
6938 :hide:
6939 :options: -ELLIPSIS, +NORMALIZE_WHITESPACE
6940
6941 Output text.
6942
6943 The following is an example for the usage of the directives. The test
6944 via doctest and the test via testcode and testoutput are equivalent.
6945
6946 The parrot module
6947 =================
6948
6949 .. testsetup:: *
6950
6951 import parrot
6952
6953 The parrot module is a module about parrots.
6954
6955 Doctest example:
6956
6957 .. doctest::
6958
6959 >>> parrot.voom(3000)
6960 This parrot wouldn't voom if you put 3000 volts through it!
6961
6962 Test-Output example:
6963
6964 .. testcode::
6965
6966 parrot.voom(3000)
6967
6968 This would output:
6969
6970 .. testoutput::
6971
6972 This parrot wouldn't voom if you put 3000 volts through it!
6973
6974 There are also these config values for customizing the doctest exten‐
6975 sion:
6976
6977 doctest_path
6978 A list of directories that will be added to sys.path when the
6979 doctest builder is used. (Make sure it contains absolute
6980 paths.)
6981
6982 doctest_global_setup
6983 Python code that is treated like it were put in a testsetup
6984 directive for every file that is tested, and for every group.
6985 You can use this to e.g. import modules you will always need in
6986 your doctests.
6987
6988 New in version 0.6.
6989
6990 doctest_global_cleanup
6991 Python code that is treated like it were put in a testcleanup
6992 directive for every file that is tested, and for every group.
6993 You can use this to e.g. remove any temporary files that the
6994 tests leave behind.
6995
6996 New in version 1.1.
6997
6998 doctest_test_doctest_blocks
6999 If this is a nonempty string (the default is 'default'), stan‐
7000 dard reST doctest blocks will be tested too. They will be
7001 assigned to the group name given.
7002
7003 reST doctest blocks are simply doctests put into a paragraph of
7004 their own, like so:
7005
7006 Some documentation text.
7007
7008 >>> print 1
7009 1
7010
7011 Some more documentation text.
7012
7013 (Note that no special :: is used to introduce a doctest block;
7014 docutils recognizes them from the leading >>>. Also, no addi‐
7015 tional indentation is used, though it doesn't hurt.)
7016
7017 If this value is left at its default value, the above snippet is
7018 interpreted by the doctest builder exactly like the following:
7019
7020 Some documentation text.
7021
7022 .. doctest::
7023
7024 >>> print 1
7025 1
7026
7027 Some more documentation text.
7028
7029 This feature makes it easy for you to test doctests in doc‐
7030 strings included with the autodoc extension without marking them
7031 up with a special directive.
7032
7033 Note though that you can't have blank lines in reST doctest
7034 blocks. They will be interpreted as one block ending and
7035 another one starting. Also, removal of <BLANKLINE> and #
7036 doctest: options only works in doctest blocks, though you may
7037 set trim_doctest_flags to achieve that in all code blocks with
7038 Python console content.
7039
7040 sphinx.ext.intersphinx -- Link to other projects' documentation
7041 New in version 0.5.
7042
7043 This extension can generate automatic links to the documentation of
7044 objects in other projects.
7045
7046 Usage is simple: whenever Sphinx encounters a cross-reference that has
7047 no matching target in the current documentation set, it looks for tar‐
7048 gets in the documentation sets configured in intersphinx_mapping. A
7049 reference like :py:class:`zipfile.ZipFile` can then link to the Python
7050 documentation for the ZipFile class, without you having to specify
7051 where it is located exactly.
7052
7053 When using the "new" format (see below), you can even force lookup in a
7054 foreign set by prefixing the link target appropriately. A link like
7055 :ref:`comparison manual <python:comparisons>` will then link to the
7056 label "comparisons" in the doc set "python", if it exists.
7057
7058 Behind the scenes, this works as follows:
7059
7060 · Each Sphinx HTML build creates a file named objects.inv that contains
7061 a mapping from object names to URIs relative to the HTML set's root.
7062
7063 · Projects using the Intersphinx extension can specify the location of
7064 such mapping files in the intersphinx_mapping config value. The map‐
7065 ping will then be used to resolve otherwise missing references to
7066 objects into links to the other documentation.
7067
7068 · By default, the mapping file is assumed to be at the same location as
7069 the rest of the documentation; however, the location of the mapping
7070 file can also be specified individually, e.g. if the docs should be
7071 buildable without Internet access.
7072
7073 To use intersphinx linking, add 'sphinx.ext.intersphinx' to your exten‐
7074 sions config value, and use these new config values to activate link‐
7075 ing:
7076
7077 intersphinx_mapping
7078 This config value contains the locations and names of other
7079 projects that should be linked to in this documentation.
7080
7081 Relative local paths for target locations are taken as relative
7082 to the base of the built documentation, while relative local
7083 paths for inventory locations are taken as relative to the
7084 source directory.
7085
7086 When fetching remote inventory files, proxy settings will be
7087 read from the $HTTP_PROXY environment variable.
7088
7089 Old format for this config value
7090
7091 This is the format used before Sphinx 1.0. It is still recog‐
7092 nized.
7093
7094 A dictionary mapping URIs to either None or an URI. The keys
7095 are the base URI of the foreign Sphinx documentation sets and
7096 can be local paths or HTTP URIs. The values indicate where the
7097 inventory file can be found: they can be None (at the same loca‐
7098 tion as the base URI) or another local or HTTP URI.
7099
7100 New format for this config value
7101
7102 New in version 1.0.
7103
7104 A dictionary mapping unique identifiers to a tuple (target,
7105 inventory). Each target is the base URI of a foreign Sphinx
7106 documentation set and can be a local path or an HTTP URI. The
7107 inventory indicates where the inventory file can be found: it
7108 can be None (at the same location as the base URI) or another
7109 local or HTTP URI.
7110
7111 The unique identifier can be used to prefix cross-reference tar‐
7112 gets, so that it is clear which intersphinx set the target
7113 belongs to. A link like :ref:`comparison manual <python:compar‐
7114 isons>` will link to the label "comparisons" in the doc set
7115 "python", if it exists.
7116
7117 Example
7118
7119 To add links to modules and objects in the Python standard
7120 library documentation, use:
7121
7122 intersphinx_mapping = {'python': ('http://docs.python.org/3.2', None)}
7123
7124 This will download the corresponding objects.inv file from the
7125 Internet and generate links to the pages under the given URI.
7126 The downloaded inventory is cached in the Sphinx environment, so
7127 it must be redownloaded whenever you do a full rebuild.
7128
7129 A second example, showing the meaning of a non-None value of the
7130 second tuple item:
7131
7132 intersphinx_mapping = {'python': ('http://docs.python.org/3.2',
7133 'python-inv.txt')}
7134
7135 This will read the inventory from python-inv.txt in the source
7136 directory, but still generate links to the pages under
7137 http://docs.python.org/3.2. It is up to you to update the
7138 inventory file as new objects are added to the Python documenta‐
7139 tion.
7140
7141 intersphinx_cache_limit
7142 The maximum number of days to cache remote inventories. The
7143 default is 5, meaning five days. Set this to a negative value
7144 to cache inventories for unlimited time.
7145
7146 Math support in Sphinx
7147 New in version 0.5.
7148
7149 Since mathematical notation isn't natively supported by HTML in any
7150 way, Sphinx supports math in documentation with several extensions.
7151
7152 The basic math support is contained in sphinx.ext.mathbase. Other math
7153 support extensions should, if possible, reuse that support too.
7154
7155 NOTE:
7156 mathbase is not meant to be added to the extensions config value,
7157 instead, use either sphinx.ext.pngmath or sphinx.ext.mathjax as
7158 described below.
7159
7160 The input language for mathematics is LaTeX markup. This is the
7161 de-facto standard for plain-text math notation and has the added advan‐
7162 tage that no further translation is necessary when building LaTeX out‐
7163 put.
7164
7165 Keep in mind that when you put math markup in Python docstrings read by
7166 autodoc, you either have to double all backslashes, or use Python raw
7167 strings (r"raw").
7168
7169 mathbase defines these new markup elements:
7170
7171 :math: Role for inline math. Use like this:
7172
7173 Since Pythagoras, we know that :math:`a^2 + b^2 = c^2`.
7174
7175 .. math::
7176 Directive for displayed math (math that takes the whole line for
7177 itself).
7178
7179 The directive supports multiple equations, which should be sepa‐
7180 rated by a blank line:
7181
7182 .. math::
7183
7184 (a + b)^2 = a^2 + 2ab + b^2
7185
7186 (a - b)^2 = a^2 - 2ab + b^2
7187
7188 In addition, each single equation is set within a split environ‐
7189 ment, which means that you can have multiple aligned lines in an
7190 equation, aligned at & and separated by \\:
7191
7192 .. math::
7193
7194 (a + b)^2 &= (a + b)(a + b) \\
7195 &= a^2 + 2ab + b^2
7196
7197 For more details, look into the documentation of the AmSMath
7198 LaTeX package.
7199
7200 When the math is only one line of text, it can also be given as
7201 a directive argument:
7202
7203 .. math:: (a + b)^2 = a^2 + 2ab + b^2
7204
7205 Normally, equations are not numbered. If you want your equation
7206 to get a number, use the label option. When given, it selects
7207 an internal label for the equation, by which it can be
7208 cross-referenced, and causes an equation number to be issued.
7209 See eqref for an example. The numbering style depends on the
7210 output format.
7211
7212 There is also an option nowrap that prevents any wrapping of the
7213 given math in a math environment. When you give this option,
7214 you must make sure yourself that the math is properly set up.
7215 For example:
7216
7217 .. math::
7218 :nowrap:
7219
7220 \begin{eqnarray}
7221 y & = & ax^2 + bx + c \\
7222 f(x) & = & x^2 + 2xy + y^2
7223 \end{eqnarray}
7224
7225 :eq: Role for cross-referencing equations via their label. This cur‐
7226 rently works only within the same document. Example:
7227
7228 .. math:: e^{i\pi} + 1 = 0
7229 :label: euler
7230
7231 Euler's identity, equation :eq:`euler`, was elected one of the most
7232 beautiful mathematical formulas.
7233
7234 sphinx.ext.pngmath -- Render math as PNG images
7235 This extension renders math via LaTeX and dvipng into PNG images. This
7236 of course means that the computer where the docs are built must have
7237 both programs available.
7238
7239 There are various config values you can set to influence how the images
7240 are built:
7241
7242 pngmath_latex
7243 The command name with which to invoke LaTeX. The default is
7244 'latex'; you may need to set this to a full path if latex is not
7245 in the executable search path.
7246
7247 Since this setting is not portable from system to system, it is
7248 normally not useful to set it in conf.py; rather, giving it on
7249 the sphinx-build command line via the -D option should be
7250 preferable, like this:
7251
7252 sphinx-build -b html -D pngmath_latex=C:\tex\latex.exe . _build/html
7253
7254 Changed in version 0.5.1: This value should only contain the
7255 path to the latex executable, not further arguments; use png‐
7256 math_latex_args for that purpose.
7257
7258 pngmath_dvipng
7259 The command name with which to invoke dvipng. The default is
7260 'dvipng'; you may need to set this to a full path if dvipng is
7261 not in the executable search path.
7262
7263 pngmath_latex_args
7264 Additional arguments to give to latex, as a list. The default
7265 is an empty list.
7266
7267 New in version 0.5.1.
7268
7269 pngmath_latex_preamble
7270 Additional LaTeX code to put into the preamble of the short
7271 LaTeX files that are used to translate the math snippets. This
7272 is empty by default. Use it e.g. to add more packages whose
7273 commands you want to use in the math.
7274
7275 pngmath_dvipng_args
7276 Additional arguments to give to dvipng, as a list. The default
7277 value is ['-gamma 1.5', '-D 110'] which makes the image a bit
7278 darker and larger then it is by default.
7279
7280 An arguments you might want to add here is e.g. '-bg Transpar‐
7281 ent', which produces PNGs with a transparent background. This
7282 is not enabled by default because some Internet Explorer ver‐
7283 sions don't like transparent PNGs.
7284
7285 NOTE:
7286 When you "add" an argument, you need to reproduce the default
7287 arguments if you want to keep them; that is, like this:
7288
7289 pngmath_dvipng_args = ['-gamma 1.5', '-D 110', '-bg Transparent']
7290
7291 pngmath_use_preview
7292 dvipng has the ability to determine the "depth" of the rendered
7293 text: for example, when typesetting a fraction inline, the base‐
7294 line of surrounding text should not be flush with the bottom of
7295 the image, rather the image should extend a bit below the base‐
7296 line. This is what TeX calls "depth". When this is enabled,
7297 the images put into the HTML document will get a vertical-align
7298 style that correctly aligns the baselines.
7299
7300 Unfortunately, this only works when the preview-latex package is
7301 installed. Therefore, the default for this option is False.
7302
7303 pngmath_add_tooltips
7304 Default: true. If false, do not add the LaTeX code as an "alt"
7305 attribute for math images.
7306
7307 New in version 1.1.
7308
7309 sphinx.ext.mathjax -- Render math via JavaScript
7310 New in version 1.1.
7311
7312 This extension puts math as-is into the HTML files. The JavaScript
7313 package MathJax is then loaded and transforms the LaTeX markup to read‐
7314 able math live in the browser.
7315
7316 Because MathJax (and the necessary fonts) is very large, it is not
7317 included in Sphinx.
7318
7319 mathjax_path
7320 The path to the JavaScript file to include in the HTML files in
7321 order to load MathJax.
7322
7323 The default is the http:// URL that loads the JS files from the
7324 MathJax CDN. If you want MathJax to be available offline, you
7325 have to donwload it and set this value to a different path.
7326
7327 The path can be absolute or relative; if it is relative, it is
7328 relative to the _static directory of the built docs.
7329
7330 For example, if you put MathJax into the static path of the
7331 Sphinx docs, this value would be MathJax/MathJax.js. If you
7332 host more than one Sphinx documentation set on one server, it is
7333 advisable to install MathJax in a shared location.
7334
7335 You can also give a full http:// URL different from the CDN URL.
7336
7337 sphinx.ext.jsmath -- Render math via JavaScript
7338 This extension works just as the MathJax extension does, but uses the
7339 older package jsMath. It provides this config value:
7340
7341 jsmath_path
7342 The path to the JavaScript file to include in the HTML files in
7343 order to load JSMath. There is no default.
7344
7345 The path can be absolute or relative; if it is relative, it is
7346 relative to the _static directory of the built docs.
7347
7348 For example, if you put JSMath into the static path of the
7349 Sphinx docs, this value would be jsMath/easy/load.js. If you
7350 host more than one Sphinx documentation set on one server, it is
7351 advisable to install jsMath in a shared location.
7352
7353 sphinx.ext.graphviz -- Add Graphviz graphs
7354 New in version 0.6.
7355
7356 This extension allows you to embed Graphviz graphs in your documents.
7357
7358 It adds these directives:
7359
7360 .. graphviz::
7361 Directive to embed graphviz code. The input code for dot is
7362 given as the content. For example:
7363
7364 .. graphviz::
7365
7366 digraph foo {
7367 "bar" -> "baz";
7368 }
7369
7370 In HTML output, the code will be rendered to a PNG or SVG image
7371 (see graphviz_output_format). In LaTeX output, the code will be
7372 rendered to an embeddable PDF file.
7373
7374 You can also embed external dot files, by giving the file name
7375 as an argument to graphviz and no additional content:
7376
7377 .. graphviz:: external.dot
7378
7379 As for all file references in Sphinx, if the filename is abso‐
7380 lute, it is taken as relative to the source directory.
7381
7382 Changed in version 1.1: Added support for external files.
7383
7384 .. graph::
7385 Directive for embedding a single undirected graph. The name is
7386 given as a directive argument, the contents of the graph are the
7387 directive content. This is a convenience directive to generate
7388 graph <name> { <content> }.
7389
7390 For example:
7391
7392 .. graph:: foo
7393
7394 "bar" -- "baz";
7395
7396 .. digraph::
7397 Directive for embedding a single directed graph. The name is
7398 given as a directive argument, the contents of the graph are the
7399 directive content. This is a convenience directive to generate
7400 digraph <name> { <content> }.
7401
7402 For example:
7403
7404 .. digraph:: foo
7405
7406 "bar" -> "baz" -> "quux";
7407
7408 New in version 1.0: All three directives support an alt option that
7409 determines the image's alternate text for HTML output. If not given,
7410 the alternate text defaults to the graphviz code.
7411
7412 New in version 1.1: All three directives support an inline flag that
7413 controls paragraph breaks in the output. When set, the graph is
7414 inserted into the current paragraph. If the flag is not given, para‐
7415 graph breaks are introduced before and after the image (the default).
7416
7417 New in version 1.1: All three directives support a caption option that
7418 can be used to give a caption to the diagram. Naturally, diagrams
7419 marked as "inline" cannot have a caption.
7420
7421 There are also these new config values:
7422
7423 graphviz_dot
7424 The command name with which to invoke dot. The default is
7425 'dot'; you may need to set this to a full path if dot is not in
7426 the executable search path.
7427
7428 Since this setting is not portable from system to system, it is
7429 normally not useful to set it in conf.py; rather, giving it on
7430 the sphinx-build command line via the -D option should be
7431 preferable, like this:
7432
7433 sphinx-build -b html -D graphviz_dot=C:\graphviz\bin\dot.exe . _build/html
7434
7435 graphviz_dot_args
7436 Additional command-line arguments to give to dot, as a list.
7437 The default is an empty list. This is the right place to set
7438 global graph, node or edge attributes via dot's -G, -N and -E
7439 options.
7440
7441 graphviz_output_format
7442 The output format for Graphviz when building HTML files. This
7443 must be either 'png' or 'svg'; the default is 'png'.
7444
7445 New in version 1.0: Previously, output always was PNG.
7446
7447 sphinx.ext.inheritance_diagram -- Include inheritance diagrams
7448 New in version 0.6.
7449
7450 This extension allows you to include inheritance diagrams, rendered via
7451 the Graphviz extension.
7452
7453 It adds this directive:
7454
7455 .. inheritance-diagram::
7456 This directive has one or more arguments, each giving a module
7457 or class name. Class names can be unqualified; in that case
7458 they are taken to exist in the currently described module (see
7459 py:module).
7460
7461 For each given class, and each class in each given module, the
7462 base classes are determined. Then, from all classes and their
7463 base classes, a graph is generated which is then rendered via
7464 the graphviz extension to a directed graph.
7465
7466 This directive supports an option called parts that, if given,
7467 must be an integer, advising the directive to remove that many
7468 parts of module names from the displayed names. (For example,
7469 if all your class names start with lib., you can give :parts: 1
7470 to remove that prefix from the displayed node names.)
7471
7472 It also supports a private-bases flag option; if given, private
7473 base classes (those whose name starts with _) will be included.
7474
7475 Changed in version 1.1: Added private-bases option; previously,
7476 all bases were always included.
7477
7478 New config values are:
7479
7480 inheritance_graph_attrs
7481 A dictionary of graphviz graph attributes for inheritance dia‐
7482 grams.
7483
7484 For example:
7485
7486 inheritance_graph_attrs = dict(rankdir="LR", size='"6.0, 8.0"',
7487 fontsize=14, ratio='compress')
7488
7489 inheritance_node_attrs
7490 A dictionary of graphviz node attributes for inheritance dia‐
7491 grams.
7492
7493 For example:
7494
7495 inheritance_node_attrs = dict(shape='ellipse', fontsize=14, height=0.75,
7496 color='dodgerblue1', style='filled')
7497
7498 inheritance_edge_attrs
7499 A dictionary of graphviz edge attributes for inheritance dia‐
7500 grams.
7501
7502 sphinx.ext.refcounting -- Keep track of reference counting behavior
7503 Todo
7504 Write this section.
7505
7506 sphinx.ext.ifconfig -- Include content based on configuration
7507 This extension is quite simple, and features only one directive:
7508
7509 .. ifconfig::
7510 Include content of the directive only if the Python expression
7511 given as an argument is True, evaluated in the namespace of the
7512 project's configuration (that is, all registered variables from
7513 conf.py are available).
7514
7515 For example, one could write
7516
7517 .. ifconfig:: releaselevel in ('alpha', 'beta', 'rc')
7518
7519 This stuff is only included in the built docs for unstable versions.
7520
7521 To make a custom config value known to Sphinx, use add_con‐
7522 fig_value() in the setup function in conf.py, e.g.:
7523
7524 def setup(app):
7525 app.add_config_value('releaselevel', '', True)
7526
7527 The second argument is the default value, the third should
7528 always be True for such values (it selects if Sphinx re-reads
7529 the documents if the value changes).
7530
7531 sphinx.ext.coverage -- Collect doc coverage stats
7532 This extension features one additional builder, the CoverageBuilder.
7533
7534 class sphinx.ext.coverage.CoverageBuilder
7535 To use this builder, activate the coverage extension in your
7536 configuration file and give -b coverage on the command line.
7537
7538 Todo
7539 Write this section.
7540
7541 Several new configuration values can be used to specify what the
7542 builder should check:
7543
7544 coverage_ignore_modules
7545
7546 coverage_ignore_functions
7547
7548 coverage_ignore_classes
7549
7550 coverage_c_path
7551
7552 coverage_c_regexes
7553
7554 coverage_ignore_c_items
7555
7556 coverage_write_headline
7557 Set to False to not write headlines.
7558
7559 New in version 1.1.
7560
7561 coverage_skip_undoc_in_source
7562 Skip objects that are not documented in the source with a doc‐
7563 string. False by default.
7564
7565 New in version 1.1.
7566
7567 sphinx.ext.todo -- Support for todo items
7568 Module author: Daniel Bültmann
7569
7570 New in version 0.5.
7571
7572 There are two additional directives when using this extension:
7573
7574 .. todo::
7575 Use this directive like, for example, note.
7576
7577 It will only show up in the output if todo_include_todos is
7578 true.
7579
7580 .. todolist::
7581 This directive is replaced by a list of all todo directives in
7582 the whole documentation, if todo_include_todos is true.
7583
7584 There is also an additional config value:
7585
7586 todo_include_todos
7587 If this is True, todo and todolist produce output, else they
7588 produce nothing. The default is False.
7589
7590 sphinx.ext.extlinks -- Markup to shorten external links
7591 Module author: Georg Brandl
7592
7593 New in version 1.0.
7594
7595 This extension is meant to help with the common pattern of having many
7596 external links that point to URLs on one and the same site, e.g. links
7597 to bug trackers, version control web interfaces, or simply subpages in
7598 other websites. It does so by providing aliases to base URLs, so that
7599 you only need to give the subpage name when creating a link.
7600
7601 Let's assume that you want to include many links to issues at the
7602 Sphinx tracker, at http://bitbucket.org/birkenfeld/sphinx/issue/num.
7603 Typing this URL again and again is tedious, so you can use extlinks to
7604 avoid repeating yourself.
7605
7606 The extension adds one new config value:
7607
7608 extlinks
7609 This config value must be a dictionary of external sites, map‐
7610 ping unique short alias names to a base URL and a prefix. For
7611 example, to create an alias for the above mentioned issues, you
7612 would add
7613
7614 extlinks = {'issue': ('https://bitbucket.org/birkenfeld/sphinx/issue/%s',
7615 'issue ')}
7616
7617 Now, you can use the alias name as a new role, e.g.
7618 :issue:`123`. This then inserts a link to
7619 https://bitbucket.org/birkenfeld/sphinx/issue/123. As you can
7620 see, the target given in the role is substituted in the base URL
7621 in the place of %s.
7622
7623 The link caption depends on the second item in the tuple, the
7624 prefix:
7625
7626 · If the prefix is None, the link caption is the full URL.
7627
7628 · If the prefix is the empty string, the link caption is the
7629 partial URL given in the role content (123 in this case.)
7630
7631 · If the prefix is a non-empty string, the link caption is the
7632 partial URL, prepended by the prefix -- in the above example,
7633 the link caption would be issue 123.
7634
7635 You can also use the usual "explicit title" syntax supported by
7636 other roles that generate links, i.e. :issue:`this issue <123>`.
7637 In this case, the prefix is not relevant.
7638
7639 NOTE:
7640 Since links are generated from the role in the reading stage, they
7641 appear as ordinary links to e.g. the linkcheck builder.
7642
7643 sphinx.ext.viewcode -- Add links to highlighted source code
7644 Module author: Georg Brandl
7645
7646 New in version 1.0.
7647
7648 This extension looks at your Python object descriptions (.. class::, ..
7649 function:: etc.) and tries to find the source files where the objects
7650 are contained. When found, a separate HTML page will be output for
7651 each module with a highlighted version of the source code, and a link
7652 will be added to all object descriptions that leads to the source code
7653 of the described object. A link back from the source to the descrip‐
7654 tion will also be inserted.
7655
7656 There are currently no configuration values for this extension; you
7657 just need to add 'sphinx.ext.viewcode' to your extensions value for it
7658 to work.
7659
7660 sphinx.ext.oldcmarkup -- Compatibility extension for old C markup
7661 Module author: Georg Brandl
7662
7663 New in version 1.0.
7664
7665 This extension is a transition helper for projects that used the old
7666 (pre-domain) C markup, i.e. the directives like cfunction and roles
7667 like cfunc. Since the introduction of domains, they must be called by
7668 their fully-qualified name (c:function and c:func, respectively) or,
7669 with the default domain set to c, by their new name (function and
7670 func). (See c-domain for the details.)
7671
7672 If you activate this extension, it will register the old names, and you
7673 can use them like before Sphinx 1.0. The directives are:
7674
7675 · cfunction
7676
7677 · cmember
7678
7679 · cmacro
7680
7681 · ctype
7682
7683 · cvar
7684
7685 The roles are:
7686
7687 · cdata
7688
7689 · cfunc
7690
7691 · cmacro
7692
7693 · ctype
7694
7695 However, it is advised to migrate to the new markup -- this extension
7696 is a compatibility convenience and will disappear in a future version
7697 of Sphinx.
7698
7699 Third-party extensions
7700 You can find several extensions contributed by users in the Sphinx Con‐
7701 trib repository. It is open for anyone who wants to maintain an exten‐
7702 sion publicly; just send a short message asking for write permissions.
7703
7704 There are also several extensions hosted elsewhere. The Wiki at Bit‐
7705 Bucket maintains a list of those.
7706
7707 If you write an extension that you think others will find useful or you
7708 think should be included as a part of Sphinx, please write to the
7709 project mailing list (join here).
7710
7711 Where to put your own extensions?
7712 Extensions local to a project should be put within the project's direc‐
7713 tory structure. Set Python's module search path, sys.path, accordingly
7714 so that Sphinx can find them. E.g., if your extension foo.py lies in
7715 the exts subdirectory of the project root, put into conf.py:
7716
7717 import sys, os
7718
7719 sys.path.append(os.path.abspath('exts'))
7720
7721 extensions = ['foo']
7722
7723 You can also install extensions anywhere else on sys.path, e.g. in the
7724 site-packages directory.
7725
7727 New in version 1.1.
7728
7729 Sphinx provides a Python API to easily integrate Sphinx documentation
7730 into your web application. To learn more read the websupportquick‐
7731 start.
7732
7733 Web Support Quick Start
7734 Building Documentation Data
7735 To make use of the web support package in your application you'll need
7736 to build the data it uses. This data includes pickle files represent‐
7737 ing documents, search indices, and node data that is used to track
7738 where comments and other things are in a document. To do this you will
7739 need to create an instance of the WebSupport class and call its build()
7740 method:
7741
7742 from sphinx.websupport import WebSupport
7743
7744 support = WebSupport(srcdir='/path/to/rst/sources/',
7745 builddir='/path/to/build/outdir',
7746 search='xapian')
7747
7748 support.build()
7749
7750 This will read reStructuredText sources from srcdir and place the nec‐
7751 essary data in builddir. The builddir will contain two sub-directo‐
7752 ries: one named "data" that contains all the data needed to display
7753 documents, search through documents, and add comments to documents.
7754 The other directory will be called "static" and contains static files
7755 that should be served from "/static".
7756
7757 NOTE:
7758 If you wish to serve static files from a path other than "/static",
7759 you can do so by providing the staticdir keyword argument when cre‐
7760 ating the WebSupport object.
7761
7762 Integrating Sphinx Documents Into Your Webapp
7763 Now that the data is built, it's time to do something useful with it.
7764 Start off by creating a WebSupport object for your application:
7765
7766 from sphinx.websupport import WebSupport
7767
7768 support = WebSupport(datadir='/path/to/the/data',
7769 search='xapian')
7770
7771 You'll only need one of these for each set of documentation you will be
7772 working with. You can then call it's get_document() method to access
7773 individual documents:
7774
7775 contents = support.get_document('contents')
7776
7777 This will return a dictionary containing the following items:
7778
7779 · body: The main body of the document as HTML
7780
7781 · sidebar: The sidebar of the document as HTML
7782
7783 · relbar: A div containing links to related documents
7784
7785 · title: The title of the document
7786
7787 · css: Links to css files used by Sphinx
7788
7789 · js: Javascript containing comment options
7790
7791 This dict can then be used as context for templates. The goal is to be
7792 easy to integrate with your existing templating system. An example
7793 using Jinja2 is:
7794
7795 {%- extends "layout.html" %}
7796
7797 {%- block title %}
7798 {{ document.title }}
7799 {%- endblock %}
7800
7801 {% block css %}
7802 {{ super() }}
7803 {{ document.css|safe }}
7804 <link rel="stylesheet" href="/static/websupport-custom.css" type="text/css">
7805 {% endblock %}
7806
7807 {%- block js %}
7808 {{ super() }}
7809 {{ document.js|safe }}
7810 {%- endblock %}
7811
7812 {%- block relbar %}
7813 {{ document.relbar|safe }}
7814 {%- endblock %}
7815
7816 {%- block body %}
7817 {{ document.body|safe }}
7818 {%- endblock %}
7819
7820 {%- block sidebar %}
7821 {{ document.sidebar|safe }}
7822 {%- endblock %}
7823
7824 Authentication
7825 To use certain features such as voting, it must be possible to authen‐
7826 ticate users. The details of the authentication are left to your
7827 application. Once a user has been authenticated you can pass the
7828 user's details to certain WebSupport methods using the username and
7829 moderator keyword arguments. The web support package will store the
7830 username with comments and votes. The only caveat is that if you allow
7831 users to change their username you must update the websupport package's
7832 data:
7833
7834 support.update_username(old_username, new_username)
7835
7836 username should be a unique string which identifies a user, and modera‐
7837 tor should be a boolean representing whether the user has moderation
7838 privilieges. The default value for moderator is False.
7839
7840 An example Flask function that checks whether a user is logged in and
7841 then retrieves a document is:
7842
7843 from sphinx.websupport.errors import *
7844
7845 @app.route('/<path:docname>')
7846 def doc(docname):
7847 username = g.user.name if g.user else ''
7848 moderator = g.user.moderator if g.user else False
7849 try:
7850 document = support.get_document(docname, username, moderator)
7851 except DocumentNotFoundError:
7852 abort(404)
7853 return render_template('doc.html', document=document)
7854
7855 The first thing to notice is that the docname is just the request path.
7856 This makes accessing the correct document easy from a single view. If
7857 the user is authenticated, then the username and moderation status are
7858 passed along with the docname to get_document(). The web support pack‐
7859 age will then add this data to the COMMENT_OPTIONS that are used in the
7860 template.
7861
7862 NOTE:
7863 This only works works if your documentation is served from your doc‐
7864 ument root. If it is served from another directory, you will need to
7865 prefix the url route with that directory, and give the docroot key‐
7866 word argument when creating the web support object:
7867
7868 support = WebSupport(..., docroot='docs')
7869
7870 @app.route('/docs/<path:docname>')
7871
7872 Performing Searches
7873 To use the search form built-in to the Sphinx sidebar, create a func‐
7874 tion to handle requests to the url 'search' relative to the documenta‐
7875 tion root. The user's search query will be in the GET parameters, with
7876 the key q. Then use the get_search_results() method to retrieve search
7877 results. In Flask that would be like this:
7878
7879 @app.route('/search')
7880 def search():
7881 q = request.args.get('q')
7882 document = support.get_search_results(q)
7883 return render_template('doc.html', document=document)
7884
7885 Note that we used the same template to render our search results as we
7886 did to render our documents. That's because get_search_results()
7887 returns a context dict in the same format that get_document() does.
7888
7889 Comments & Proposals
7890 Now that this is done it's time to define the functions that handle the
7891 AJAX calls from the script. You will need three functions. The first
7892 function is used to add a new comment, and will call the web support
7893 method add_comment():
7894
7895 @app.route('/docs/add_comment', methods=['POST'])
7896 def add_comment():
7897 parent_id = request.form.get('parent', '')
7898 node_id = request.form.get('node', '')
7899 text = request.form.get('text', '')
7900 proposal = request.form.get('proposal', '')
7901 username = g.user.name if g.user is not None else 'Anonymous'
7902 comment = support.add_comment(text, node_id='node_id',
7903 parent_id='parent_id',
7904 username=username, proposal=proposal)
7905 return jsonify(comment=comment)
7906
7907 You'll notice that both a parent_id and node_id are sent with the
7908 request. If the comment is being attached directly to a node, parent_id
7909 will be empty. If the comment is a child of another comment, then
7910 node_id will be empty. Then next function handles the retrieval of com‐
7911 ments for a specific node, and is aptly named get_data():
7912
7913 @app.route('/docs/get_comments')
7914 def get_comments():
7915 username = g.user.name if g.user else None
7916 moderator = g.user.moderator if g.user else False
7917 node_id = request.args.get('node', '')
7918 data = support.get_data(node_id, username, moderator)
7919 return jsonify(**data)
7920
7921 The final function that is needed will call process_vote(), and will
7922 handle user votes on comments:
7923
7924 @app.route('/docs/process_vote', methods=['POST'])
7925 def process_vote():
7926 if g.user is None:
7927 abort(401)
7928 comment_id = request.form.get('comment_id')
7929 value = request.form.get('value')
7930 if value is None or comment_id is None:
7931 abort(400)
7932 support.process_vote(comment_id, g.user.id, value)
7933 return "success"
7934
7935 Comment Moderation
7936 By default, all comments added through add_comment() are automatically
7937 displayed. If you wish to have some form of moderation, you can pass
7938 the displayed keyword argument:
7939
7940 comment = support.add_comment(text, node_id='node_id',
7941 parent_id='parent_id',
7942 username=username, proposal=proposal,
7943 displayed=False)
7944
7945 You can then create a new view to handle the moderation of comments.
7946 It will be called when a moderator decides a comment should be accepted
7947 and displayed:
7948
7949 @app.route('/docs/accept_comment', methods=['POST'])
7950 def accept_comment():
7951 moderator = g.user.moderator if g.user else False
7952 comment_id = request.form.get('id')
7953 support.accept_comment(comment_id, moderator=moderator)
7954 return 'OK'
7955
7956 Rejecting comments happens via comment deletion.
7957
7958 To perform a custom action (such as emailing a moderator) when a new
7959 comment is added but not displayed, you can pass callable to the Web‐
7960 Support class when instantiating your support object:
7961
7962 def moderation_callback(comment):
7963 """Do something..."""
7964
7965 support = WebSupport(..., moderation_callback=moderation_callback)
7966
7967 The moderation callback must take one argument, which will be the same
7968 comment dict that is returned by add_comment().
7969
7970 The WebSupport Class
7971 class sphinx.websupport.WebSupport
7972 The main API class for the web support package. All interac‐
7973 tions with the web support package should occur through this
7974 class.
7975
7976 The class takes the following keyword arguments:
7977
7978 srcdir The directory containing reStructuredText source files.
7979
7980 builddir
7981 The directory that build data and static files should be
7982 placed in. This should be used when creating a WebSup‐
7983 port object that will be used to build data.
7984
7985 datadir
7986 The directory that the web support data is in. This
7987 should be used when creating a WebSupport object that
7988 will be used to retrieve data.
7989
7990 search This may contain either a string (e.g. 'xapian') refer‐
7991 encing a built-in search adapter to use, or an instance
7992 of a subclass of BaseSearch.
7993
7994 storage
7995 This may contain either a string representing a database
7996 uri, or an instance of a subclass of StorageBackend. If
7997 this is not provided, a new sqlite database will be cre‐
7998 ated.
7999
8000 moderation_callback
8001 A callable to be called when a new comment is added that
8002 is not displayed. It must accept one argument: a dictio‐
8003 nary representing the comment that was added.
8004
8005 staticdir
8006 If static files are served from a location besides
8007 '/static', this should be a string with the name of that
8008 location (e.g. '/static_files').
8009
8010 docroot
8011 If the documentation is not served from the base path of
8012 a URL, this should be a string specifying that path (e.g.
8013 'docs').
8014
8015 Methods
8016 WebSupport.build()
8017 Build the documentation. Places the data into the outdir direc‐
8018 tory. Use it like this:
8019
8020 support = WebSupport(srcdir, builddir, search='xapian')
8021 support.build()
8022
8023 This will read reStructured text files from srcdir. Then it will
8024 build the pickles and search index, placing them into builddir.
8025 It will also save node data to the database.
8026
8027 WebSupport.get_document(docname, username='', moderator=False)
8028 Load and return a document from a pickle. The document will be a
8029 dict object which can be used to render a template:
8030
8031 support = WebSupport(datadir=datadir)
8032 support.get_document('index', username, moderator)
8033
8034 In most cases docname will be taken from the request path and
8035 passed directly to this function. In Flask, that would be some‐
8036 thing like this:
8037
8038 @app.route('/<path:docname>')
8039 def index(docname):
8040 username = g.user.name if g.user else ''
8041 moderator = g.user.moderator if g.user else False
8042 try:
8043 document = support.get_document(docname, username,
8044 moderator)
8045 except DocumentNotFoundError:
8046 abort(404)
8047 render_template('doc.html', document=document)
8048
8049 The document dict that is returned contains the following items
8050 to be used during template rendering.
8051
8052 · body: The main body of the document as HTML
8053
8054 · sidebar: The sidebar of the document as HTML
8055
8056 · relbar: A div containing links to related documents
8057
8058 · title: The title of the document
8059
8060 · css: Links to css files used by Sphinx
8061
8062 · script: Javascript containing comment options
8063
8064 This raises DocumentNotFoundError if a document matching docname
8065 is not found.
8066
8067 Parameters
8068 docname -- the name of the document to load.
8069
8070 WebSupport.get_data(node_id, username=None, moderator=False)
8071 Get the comments and source associated with node_id. If username
8072 is given vote information will be included with the returned
8073 comments. The default CommentBackend returns a dict with two
8074 keys, source, and comments. source is raw source of the node and
8075 is used as the starting point for proposals a user can add. com‐
8076 ments is a list of dicts that represent a comment, each having
8077 the following items:
8078
8079 ┌──────────────┬────────────────────────────┐
8080 │Key │ Contents │
8081 ├──────────────┼────────────────────────────┤
8082 │text │ The comment text. │
8083 ├──────────────┼────────────────────────────┤
8084 │username │ The username that was │
8085 │ │ stored with the comment. │
8086 ├──────────────┼────────────────────────────┤
8087 │id │ The comment's unique iden‐ │
8088 │ │ tifier. │
8089 ├──────────────┼────────────────────────────┤
8090 │rating │ The comment's current rat‐ │
8091 │ │ ing. │
8092 ├──────────────┼────────────────────────────┤
8093 │age │ The time in seconds since │
8094 │ │ the comment was added. │
8095 ├──────────────┼────────────────────────────┤
8096 │time │ A dict containing time │
8097 │ │ information. It contains │
8098 │ │ the following keys: year, │
8099 │ │ month, day, hour, minute, │
8100 │ │ second, iso, and delta. │
8101 │ │ iso is the time formatted │
8102 │ │ in ISO 8601 format. delta │
8103 │ │ is a printable form of how │
8104 │ │ old the comment is (e.g. │
8105 │ │ "3 hours ago"). │
8106 ├──────────────┼────────────────────────────┤
8107 │vote │ If user_id was given, this │
8108 │ │ will be an integer repre‐ │
8109 │ │ senting the vote. 1 for an │
8110 │ │ upvote, -1 for a downvote, │
8111 │ │ or 0 if unvoted. │
8112 ├──────────────┼────────────────────────────┤
8113 │node │ The id of the node that │
8114 │ │ the comment is attached │
8115 │ │ to. If the comment's par‐ │
8116 │ │ ent is another comment │
8117 │ │ rather than a node, this │
8118 │ │ will be null. │
8119 ├──────────────┼────────────────────────────┤
8120 │parent │ The id of the comment that │
8121 │ │ this comment is attached │
8122 │ │ to if it is not attached │
8123 │ │ to a node. │
8124 ├──────────────┼────────────────────────────┤
8125 │children │ A list of all children, in │
8126 │ │ this format. │
8127 ├──────────────┼────────────────────────────┤
8128 │proposal_diff │ An HTML representation of │
8129 │ │ the differences between │
8130 │ │ the the current source and │
8131 │ │ the user's proposed │
8132 │ │ source. │
8133 └──────────────┴────────────────────────────┘
8134
8135 Parameters
8136
8137 · node_id -- the id of the node to get comments for.
8138
8139 · username -- the username of the user viewing the com‐
8140 ments.
8141
8142 · moderator -- whether the user is a moderator.
8143
8144 WebSupport.add_comment(text, node_id='', parent_id='', displayed=True,
8145 username=None, time=None, proposal=None, moderator=False)
8146 Add a comment to a node or another comment. Returns the comment
8147 in the same format as get_comments(). If the comment is being
8148 attached to a node, pass in the node's id (as a string) with the
8149 node keyword argument:
8150
8151 comment = support.add_comment(text, node_id=node_id)
8152
8153 If the comment is the child of another comment, provide the par‐
8154 ent's id (as a string) with the parent keyword argument:
8155
8156 comment = support.add_comment(text, parent_id=parent_id)
8157
8158 If you would like to store a username with the comment, pass in
8159 the optional username keyword argument:
8160
8161 comment = support.add_comment(text, node=node_id,
8162 username=username)
8163
8164 Parameters
8165
8166 · parent_id -- the prefixed id of the comment's parent.
8167
8168 · text -- the text of the comment.
8169
8170 · displayed -- for moderation purposes
8171
8172 · username -- the username of the user making the com‐
8173 ment.
8174
8175 · time -- the time the comment was created, defaults to
8176 now.
8177
8178 WebSupport.process_vote(comment_id, username, value)
8179 Process a user's vote. The web support package relies on the API
8180 user to perform authentication. The API user will typically
8181 receive a comment_id and value from a form, and then make sure
8182 the user is authenticated. A unique username must be passed in,
8183 which will also be used to retrieve the user's past voting data.
8184 An example, once again in Flask:
8185
8186 @app.route('/docs/process_vote', methods=['POST'])
8187 def process_vote():
8188 if g.user is None:
8189 abort(401)
8190 comment_id = request.form.get('comment_id')
8191 value = request.form.get('value')
8192 if value is None or comment_id is None:
8193 abort(400)
8194 support.process_vote(comment_id, g.user.name, value)
8195 return "success"
8196
8197 Parameters
8198
8199 · comment_id -- the comment being voted on
8200
8201 · username -- the unique username of the user voting
8202
8203 · value -- 1 for an upvote, -1 for a downvote, 0 for an
8204 unvote.
8205
8206 WebSupport.get_search_results(q)
8207 Perform a search for the query q, and create a set of search
8208 results. Then render the search results as html and return a
8209 context dict like the one created by get_document():
8210
8211 document = support.get_search_results(q)
8212
8213 Parameters
8214 q -- the search query
8215
8216 Search Adapters
8217 To create a custom search adapter you will need to subclass the
8218 BaseSearch class. Then create an instance of the new class and pass
8219 that as the search keyword argument when you create the WebSupport
8220 object:
8221
8222 support = WebSupport(srcdir=srcdir,
8223 builddir=builddir,
8224 search=MySearch())
8225
8226 For more information about creating a custom search adapter, please see
8227 the documentation of the BaseSearch class below.
8228
8229 class sphinx.websupport.search.BaseSearch
8230 Defines an interface for search adapters.
8231
8232 BaseSearch Methods
8233 The following methods are defined in the BaseSearch class. Some
8234 methods do not need to be overridden, but some (add_document() and
8235 handle_query()) must be overridden in your subclass. For a working
8236 example, look at the built-in adapter for whoosh.
8237
8238 BaseSearch.init_indexing(changed=[])
8239 Called by the builder to initialize the search indexer. changed
8240 is a list of pagenames that will be reindexed. You may want to
8241 remove these from the search index before indexing begins.
8242
8243 Parameters
8244 changed -- a list of pagenames that will be re-indexed
8245
8246 BaseSearch.finish_indexing()
8247 Called by the builder when writing has been completed. Use this
8248 to perform any finalization or cleanup actions after indexing is
8249 complete.
8250
8251 BaseSearch.feed(pagename, title, doctree)
8252 Called by the builder to add a doctree to the index. Converts
8253 the doctree to text and passes it to add_document(). You proba‐
8254 bly won't want to override this unless you need access to the
8255 doctree. Override add_document() instead.
8256
8257 Parameters
8258
8259 · pagename -- the name of the page to be indexed
8260
8261 · title -- the title of the page to be indexed
8262
8263 · doctree -- is the docutils doctree representation of
8264 the page
8265
8266 BaseSearch.add_document(pagename, title, text)
8267 Called by feed() to add a document to the search index. This
8268 method should should do everything necessary to add a single
8269 document to the search index.
8270
8271 pagename is name of the page being indexed. It is the combina‐
8272 tion of the source files relative path and filename, minus the
8273 extension. For example, if the source file is
8274 "ext/builders.rst", the pagename would be "ext/builders". This
8275 will need to be returned with search results when processing a
8276 query.
8277
8278 Parameters
8279
8280 · pagename -- the name of the page being indexed
8281
8282 · title -- the page's title
8283
8284 · text -- the full text of the page
8285
8286 BaseSearch.query(q)
8287 Called by the web support api to get search results. This method
8288 compiles the regular expression to be used when extracting con‐
8289 text, then calls handle_query(). You won't want to override
8290 this unless you don't want to use the included extract_context()
8291 method. Override handle_query() instead.
8292
8293 Parameters
8294 q -- the search query string.
8295
8296 BaseSearch.handle_query(q)
8297 Called by query() to retrieve search results for a search query
8298 q. This should return an iterable containing tuples of the fol‐
8299 lowing format:
8300
8301 (<path>, <title>, <context>)
8302
8303 path and title are the same values that were passed to add_docu‐
8304 ment(), and context should be a short text snippet of the text
8305 surrounding the search query in the document.
8306
8307 The extract_context() method is provided as a simple way to cre‐
8308 ate the context.
8309
8310 Parameters
8311 q -- the search query
8312
8313 BaseSearch.extract_context(text, length=240)
8314 Extract the context for the search query from the document's
8315 full text.
8316
8317 Parameters
8318
8319 · text -- the full text of the document to create the
8320 context for
8321
8322 · length -- the length of the context snippet to return.
8323
8324 Storage Backends
8325 To create a custom storage backend you will need to subclass the Stor‐
8326 ageBackend class. Then create an instance of the new class and pass
8327 that as the storage keyword argument when you create the WebSupport
8328 object:
8329
8330 support = WebSupport(srcdir=srcdir,
8331 builddir=builddir,
8332 storage=MyStorage())
8333
8334 For more information about creating a custom storage backend, please
8335 see the documentation of the StorageBackend class below.
8336
8337 class sphinx.websupport.storage.StorageBackend
8338 Defines an interface for storage backends.
8339
8340 StorageBackend Methods
8341 StorageBackend.pre_build()
8342 Called immediately before the build process begins. Use this to
8343 prepare the StorageBackend for the addition of nodes.
8344
8345 StorageBackend.add_node(id, document, source)
8346 Add a node to the StorageBackend.
8347
8348 Parameters
8349
8350 · id -- a unique id for the comment.
8351
8352 · document -- the name of the document the node belongs
8353 to.
8354
8355 · source -- the source files name.
8356
8357 StorageBackend.post_build()
8358 Called after a build has completed. Use this to finalize the
8359 addition of nodes if needed.
8360
8361 StorageBackend.add_comment(text, displayed, username, time, proposal,
8362 node_id, parent_id, moderator)
8363 Called when a comment is being added.
8364
8365 Parameters
8366
8367 · text -- the text of the comment
8368
8369 · displayed -- whether the comment should be displayed
8370
8371 · username -- the name of the user adding the comment
8372
8373 · time -- a date object with the time the comment was
8374 added
8375
8376 · proposal -- the text of the proposal the user made
8377
8378 · node_id -- the id of the node that the comment is being
8379 added to
8380
8381 · parent_id -- the id of the comment's parent comment.
8382
8383 · moderator -- whether the user adding the comment is a
8384 moderator
8385
8386 StorageBackend.delete_comment(comment_id, username, moderator)
8387 Delete a comment.
8388
8389 Raises UserNotAuthorizedError if moderator is False and username
8390 doesn't match the username on the comment.
8391
8392 Parameters
8393
8394 · comment_id -- The id of the comment being deleted.
8395
8396 · username -- The username of the user requesting the
8397 deletion.
8398
8399 · moderator -- Whether the user is a moderator.
8400
8401 StorageBackend.get_data(node_id, username, moderator)
8402 Called to retrieve all data for a node. This should return a
8403 dict with two keys, source and comments as described by WebSup‐
8404 port's get_data() method.
8405
8406 Parameters
8407
8408 · node_id -- The id of the node to get data for.
8409
8410 · username -- The name of the user requesting the data.
8411
8412 · moderator -- Whether the requestor is a moderator.
8413
8414 StorageBackend.process_vote(comment_id, username, value)
8415 Process a vote that is being cast. value will be either -1, 0,
8416 or 1.
8417
8418 Parameters
8419
8420 · comment_id -- The id of the comment being voted on.
8421
8422 · username -- The username of the user casting the vote.
8423
8424 · value -- The value of the vote being cast.
8425
8426 StorageBackend.update_username(old_username, new_username)
8427 If a user is allowed to change their username this method should
8428 be called so that there is not stagnate data in the storage sys‐
8429 tem.
8430
8431 Parameters
8432
8433 · old_username -- The username being changed.
8434
8435 · new_username -- What the username is being changed to.
8436
8437 StorageBackend.accept_comment(comment_id)
8438 Called when a moderator accepts a comment. After the method is
8439 called the comment should be displayed to all users.
8440
8441 Parameters
8442 comment_id -- The id of the comment being accepted.
8443
8445 This is a list of Frequently Asked Questions about Sphinx. Feel free
8446 to suggest new entries!
8447
8448 How do I...
8449 ... create PDF files without LaTeX?
8450 You can use rst2pdf version 0.12 or greater which comes with
8451 built-in Sphinx integration. See the builders section for
8452 details.
8453
8454 ... get section numbers?
8455 They are automatic in LaTeX output; for HTML, give a :numbered:
8456 option to the toctree directive where you want to start number‐
8457 ing.
8458
8459 ... customize the look of the built HTML files?
8460 Use themes, see theming.
8461
8462 ... add global substitutions or includes?
8463 Add them in the rst_epilog config value.
8464
8465 ... display the whole TOC tree in the sidebar?
8466 Use the toctree callable in a custom layout template, probably
8467 in the sidebartoc block.
8468
8469 ... write my own extension?
8470 See the extension tutorial.
8471
8472 ... convert from my existing docs using MoinMoin markup?
8473 The easiest way is to convert to xhtml, then convert xhtml to
8474 reST. You'll still need to mark up classes and such, but the
8475 headings and code examples come through cleanly.
8476
8477 Using Sphinx with...
8478 Read the Docs
8479 http://readthedocs.org is a documentation hosting service based
8480 around Sphinx. They will host sphinx documentation, along with
8481 supporting a number of other features including version support,
8482 PDF generation, and more. The Getting Started guide is a good
8483 place to start.
8484
8485 Epydoc There's a third-party extension providing an api role which
8486 refers to Epydoc's API docs for a given identifier.
8487
8488 Doxygen
8489 Michael Jones is developing a reST/Sphinx bridge to doxygen
8490 called breathe.
8491
8492 SCons Glenn Hutchings has written a SCons build script to build Sphinx
8493 documentation; it is hosted here:
8494 https://bitbucket.org/zondo/sphinx-scons
8495
8496 PyPI Jannis Leidel wrote a setuptools command that automatically
8497 uploads Sphinx documentation to the PyPI package documentation
8498 area at http://packages.python.org/.
8499
8500 GitHub Pages
8501 Directories starting with underscores are ignored by default
8502 which breaks static files in Sphinx. GitHub's preprocessor can
8503 be disabled to support Sphinx HTML output properly.
8504
8505 MediaWiki
8506 See https://bitbucket.org/kevindunn/sphinx-wiki, a project by
8507 Kevin Dunn.
8508
8509 Google Analytics
8510 You can use a custom layout.html template, like this:
8511
8512 {% extends "!layout.html" %}
8513
8514 {%- block extrahead %}
8515 {{ super() }}
8516 <script type="text/javascript">
8517 var _gaq = _gaq || [];
8518 _gaq.push(['_setAccount', 'XXX account number XXX']);
8519 _gaq.push(['_trackPageview']);
8520 </script>
8521 {% endblock %}
8522
8523 {% block footer %}
8524 {{ super() }}
8525 <div class="footer">This page uses <a href="http://analytics.google.com/">
8526 Google Analytics</a> to collect statistics. You can disable it by blocking
8527 the JavaScript coming from www.google-analytics.com.
8528 <script type="text/javascript">
8529 (function() {
8530 var ga = document.createElement('script');
8531 ga.src = ('https:' == document.location.protocol ?
8532 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
8533 ga.setAttribute('async', 'true');
8534 document.documentElement.firstChild.appendChild(ga);
8535 })();
8536 </script>
8537 </div>
8538 {% endblock %}
8539
8540 Epub info
8541 The epub builder is currently in an experimental stage. It has only
8542 been tested with the Sphinx documentation itself. If you want to cre‐
8543 ate epubs, here are some notes:
8544
8545 · Split the text into several files. The longer the individual HTML
8546 files are, the longer it takes the ebook reader to render them. In
8547 extreme cases, the rendering can take up to one minute.
8548
8549 · Try to minimize the markup. This also pays in rendering time.
8550
8551 · For some readers you can use embedded or external fonts using the CSS
8552 @font-face directive. This is extremely useful for code listings
8553 which are often cut at the right margin. The default Courier font
8554 (or variant) is quite wide and you can only display up to 60 charac‐
8555 ters on a line. If you replace it with a narrower font, you can get
8556 more characters on a line. You may even use FontForge and create
8557 narrow variants of some free font. In my case I get up to 70 charac‐
8558 ters on a line.
8559
8560 You may have to experiment a little until you get reasonable results.
8561
8562 · Test the created epubs. You can use several alternatives. The ones I
8563 am aware of are Epubcheck, Calibre, FBreader (although it does not
8564 render the CSS), and Bookworm. For bookworm you can download the
8565 source from http://code.google.com/p/threepress/ and run your own
8566 local server.
8567
8568 · Large floating divs are not displayed properly. If they cover more
8569 than one page, the div is only shown on the first page. In that case
8570 you can copy the epub.css from the sphinx/themes/epub/static/ direc‐
8571 tory to your local _static/ directory and remove the float settings.
8572
8573 · Files that are inserted outside of the toctree directive must be man‐
8574 ually included. This sometimes applies to appendixes, e.g. the glos‐
8575 sary or the indices. You can add them with the epub_post_files
8576 option.
8577
8578 Texinfo info
8579 The Texinfo builder is currently in an experimental stage but has suc‐
8580 cessfully been used to build the documentation for both Sphinx and
8581 Python. The intended use of this builder is to generate Texinfo that
8582 is then processed into Info files.
8583
8584 There are two main programs for reading Info files, info and GNU Emacs.
8585 The info program has less features but is available in most Unix envi‐
8586 ronments and can be quickly accessed from the terminal. Emacs provides
8587 better font and color display and supports extensive customization (of
8588 course).
8589
8590 Displaying Links
8591 One noticeable problem you may encounter with the generated Info files
8592 is how references are displayed. If you read the source of an Info
8593 file, a reference to this section would look like:
8594
8595 * note Displaying Links: target-id
8596
8597 In the stand-alone reader, info, references are displayed just as they
8598 appear in the source. Emacs, on the other-hand, will by default
8599 replace \*note: with see and hide the target-id. For example:
8600 texinfo-links
8601
8602 The exact behavior of how Emacs displays references is dependent on the
8603 variable Info-hide-note-references. If set to the value of hide, Emacs
8604 will hide both the \*note: part and the target-id. This is generally
8605 the best way to view Sphinx-based documents since they often make fre‐
8606 quent use of links and do not take this limitation into account. How‐
8607 ever, changing this variable affects how all Info documents are dis‐
8608 played and most due take this behavior into account.
8609
8610 If you want Emacs to display Info files produced by Sphinx using the
8611 value hide for Info-hide-note-references and the default value for all
8612 other Info files, try adding the following Emacs Lisp code to your
8613 start-up file, ~/.emacs.d/init.el.
8614
8615 (defadvice info-insert-file-contents (after
8616 sphinx-info-insert-file-contents
8617 activate)
8618 "Hack to make `Info-hide-note-references' buffer-local and
8619 automatically set to `hide' iff it can be determined that this file
8620 was created from a Texinfo file generated by Docutils or Sphinx."
8621 (set (make-local-variable 'Info-hide-note-references)
8622 (default-value 'Info-hide-note-references))
8623 (save-excursion
8624 (save-restriction
8625 (widen) (goto-char (point-min))
8626 (when (re-search-forward
8627 "^Generated by \\(Sphinx\\|Docutils\\)"
8628 (save-excursion (search-forward "\x1f" nil t)) t)
8629 (set (make-local-variable 'Info-hide-note-references)
8630 'hide)))))
8631
8632 Notes
8633 The following notes may be helpful if you want to create Texinfo files:
8634
8635 · Each section corresponds to a different node in the Info file.
8636
8637 · Colons (:) cannot be properly escaped in menu entries and xrefs.
8638 They will be replaced with semicolons (;).
8639
8640 · In the HTML and Tex output, the word see is automatically inserted
8641 before all xrefs.
8642
8643 · Links to external Info files can be created using the somewhat offi‐
8644 cial URI scheme info. For example:
8645
8646 info:Texinfo#makeinfo_options
8647
8648 which produces:
8649 info:Texinfo#makeinfo_options
8650
8651 · Inline markup appears as follows in Info:
8652
8653 · strong -- *strong*
8654
8655 · emphasis -- _emphasis_
8656
8657 · literal -- `literal'
8658
8659 It is possible to change this behavior using the Texinfo command
8660 @definfoenclose. For example, to make inline markup more closely
8661 resemble reST, add the following to your conf.py:
8662
8663 texinfo_elements = {'preamble': """\
8664 @definfoenclose strong,**,**
8665 @definfoenclose emph,*,*
8666 @definfoenclose code,`@w{}`,`@w{}`
8667 """}
8668
8670 builder
8671 A class (inheriting from Builder) that takes parsed documents
8672 and performs an action on them. Normally, builders translate
8673 the documents to an output format, but it is also possible to
8674 use the builder builders that e.g. check for broken links in the
8675 documentation, or build coverage information.
8676
8677 See builders for an overview over Sphinx' built-in builders.
8678
8679 configuration directory
8680 The directory containing conf.py. By default, this is the same
8681 as the source directory, but can be set differently with the -c
8682 command-line option.
8683
8684 directive
8685 A reStructuredText markup element that allows marking a block of
8686 content with special meaning. Directives are supplied not only
8687 by docutils, but Sphinx and custom extensions can add their own.
8688 The basic directive syntax looks like this:
8689
8690 .. directivename:: argument ...
8691 :option: value
8692
8693 Content of the directive.
8694
8695 See directives for more information.
8696
8697 document name
8698 Since reST source files can have different extensions (some peo‐
8699 ple like .txt, some like .rst -- the extension can be configured
8700 with source_suffix) and different OSes have different path sepa‐
8701 rators, Sphinx abstracts them: document names are always rela‐
8702 tive to the source directory, the extension is stripped, and
8703 path separators are converted to slashes. All values, parame‐
8704 ters and such referring to "documents" expect such document
8705 names.
8706
8707 Examples for document names are index, library/zipfile, or ref‐
8708 erence/datamodel/types. Note that there is no leading or trail‐
8709 ing slash.
8710
8711 domain A domain is a collection of markup (reStructuredText directives
8712 and roles) to describe and link to objects belonging together,
8713 e.g. elements of a programming language. Directive and role
8714 names in a domain have names like domain:name, e.g. py:function.
8715
8716 Having domains means that there are no naming problems when one
8717 set of documentation wants to refer to e.g. C++ and Python
8718 classes. It also means that extensions that support the docu‐
8719 mentation of whole new languages are much easier to write. For
8720 more information about domains, see the chapter domains.
8721
8722 environment
8723 A structure where information about all documents under the root
8724 is saved, and used for cross-referencing. The environment is
8725 pickled after the parsing stage, so that successive runs only
8726 need to read and parse new and changed documents.
8727
8728 master document
8729 The document that contains the root toctree directive.
8730
8731 object The basic building block of Sphinx documentation. Every "object
8732 directive" (e.g. function or object) creates such a block; and
8733 most objects can be cross-referenced to.
8734
8735 role A reStructuredText markup element that allows marking a piece of
8736 text. Like directives, roles are extensible. The basic syntax
8737 looks like this: :rolename:`content`. See inlinemarkup for
8738 details.
8739
8740 source directory
8741 The directory which, including its subdirectories, contains all
8742 source files for one Sphinx project.
8743
8745 Release 1.1.3 (Mar 10, 2012)
8746 · PR#40: Fix safe_repr function to decode bytestrings with non-ASCII
8747 characters correctly.
8748
8749 · PR#37: Allow configuring sphinx-apidoc via SPHINX_APIDOC_OPTIONS.
8750
8751 · PR#34: Restore Python 2.4 compatibility.
8752
8753 · PR#36: Make the "bibliography to TOC" fix in LaTeX output specific to
8754 the document class.
8755
8756 · #695: When the highlight language "python" is specified explicitly,
8757 do not try to parse the code to recognize non-Python snippets.
8758
8759 · #859: Fix exception under certain circumstances when not finding
8760 appropriate objects to link to.
8761
8762 · #860: Do not crash when encountering invalid doctest examples, just
8763 emit a warning.
8764
8765 · #864: Fix crash with some settings of modindex_common_prefix.
8766
8767 · #862: Fix handling of -D and -A options on Python 3.
8768
8769 · #851: Recognize and warn about circular toctrees, instead of running
8770 into recursion errors.
8771
8772 · #853: Restore compatibility with docutils trunk.
8773
8774 · #852: Fix HtmlHelp index entry links again.
8775
8776 · #854: Fix inheritance_diagram raising attribute errors on builtins.
8777
8778 · #832: Fix crashes when putting comments or lone terms in a glossary.
8779
8780 · #834, #818: Fix HTML help language/encoding mapping for all Sphinx
8781 supported languages.
8782
8783 · #844: Fix crashes when dealing with Unicode output in doctest exten‐
8784 sion.
8785
8786 · #831: Provide --project flag in setup_command as advertised.
8787
8788 · #875: Fix reading config files under Python 3.
8789
8790 · #876: Fix quickstart test under Python 3.
8791
8792 · #870: Fix spurious KeyErrors when removing documents.
8793
8794 · #892: Fix single-HTML builder misbehaving with the master document in
8795 a subdirectory.
8796
8797 · #873: Fix assertion errors with empty only directives.
8798
8799 · #816: Fix encoding issues in the Qt help builder.
8800
8801 Release 1.1.2 (Nov 1, 2011) -- 1.1.1 is a silly version number anyway!
8802 · #809: Include custom fixers in the source distribution.
8803
8804 Release 1.1.1 (Nov 1, 2011)
8805 · #791: Fix QtHelp, DevHelp and HtmlHelp index entry links.
8806
8807 · #792: Include "sphinx-apidoc" in the source distribution.
8808
8809 · #797: Don't crash on a misformatted glossary.
8810
8811 · #801: Make intersphinx work properly without SSL support.
8812
8813 · #805: Make the Sphinx.add_index_to_domain method work correctly.
8814
8815 · #780: Fix Python 2.5 compatibility.
8816
8817 Release 1.1 (Oct 9, 2011)
8818 Incompatible changes
8819 · The py:module directive doesn't output its platform option value any‐
8820 more. (It was the only thing that the directive did output, and
8821 therefore quite inconsistent.)
8822
8823 · Removed support for old dependency versions; requirements are now:
8824
8825 · Pygments >= 1.2
8826
8827 · Docutils >= 0.7
8828
8829 · Jinja2 >= 2.3
8830
8831 Features added
8832 · Added Python 3.x support.
8833
8834 · New builders and subsystems:
8835
8836 · Added a Texinfo builder.
8837
8838 · Added i18n support for content, a gettext builder and related util‐
8839 ities.
8840
8841 · Added the websupport library and builder.
8842
8843 · #98: Added a sphinx-apidoc script that autogenerates a hierarchy of
8844 source files containing autodoc directives to document modules and
8845 packages.
8846
8847 · #273: Add an API for adding full-text search support for languages
8848 other than English. Add support for Japanese.
8849
8850 · Markup:
8851
8852 · #138: Added an index role, to make inline index entries.
8853
8854 · #454: Added more index markup capabilities: marking see/seealso
8855 entries, and main entries for a given key.
8856
8857 · #460: Allowed limiting the depth of section numbers for HTML using
8858 the toctree's numbered option.
8859
8860 · #586: Implemented improved glossary markup which allows multiple
8861 terms per definition.
8862
8863 · #478: Added py:decorator directive to describe decorators.
8864
8865 · C++ domain now supports array definitions.
8866
8867 · C++ domain now supports doc fields (:param x: inside directives).
8868
8869 · Section headings in only directives are now correctly handled.
8870
8871 · Added emphasize-lines option to source code directives.
8872
8873 · #678: C++ domain now supports superclasses.
8874
8875 · HTML builder:
8876
8877 · Added pyramid theme.
8878
8879 · #559: html_add_permalinks is now a string giving the text to dis‐
8880 play in permalinks.
8881
8882 · #259: HTML table rows now have even/odd CSS classes to enable
8883 "Zebra styling".
8884
8885 · #554: Add theme option sidebarwidth to the basic theme.
8886
8887 · Other builders:
8888
8889 · #516: Added new value of the latex_show_urls option to show the
8890 URLs in footnotes.
8891
8892 · #209: Added text_newlines and text_sectionchars config values.
8893
8894 · Added man_show_urls config value.
8895
8896 · #472: linkcheck builder: Check links in parallel, use HTTP HEAD
8897 requests and allow configuring the timeout. New config values:
8898 linkcheck_timeout and linkcheck_workers.
8899
8900 · #521: Added linkcheck_ignore config value.
8901
8902 · #28: Support row/colspans in tables in the LaTeX builder.
8903
8904 · Configuration and extensibility:
8905
8906 · #537: Added nitpick_ignore.
8907
8908 · #306: Added env-get-outdated event.
8909
8910 · Application.add_stylesheet() now accepts full URIs.
8911
8912 · Autodoc:
8913
8914 · #564: Add autodoc_docstring_signature. When enabled (the default),
8915 autodoc retrieves the signature from the first line of the doc‐
8916 string, if it is found there.
8917
8918 · #176: Provide private-members option for autodoc directives.
8919
8920 · #520: Provide special-members option for autodoc directives.
8921
8922 · #431: Doc comments for attributes can now be given on the same line
8923 as the assignment.
8924
8925 · #437: autodoc now shows values of class data attributes.
8926
8927 · autodoc now supports documenting the signatures of functools.par‐
8928 tial objects.
8929
8930 · Other extensions:
8931
8932 · Added the sphinx.ext.mathjax extension.
8933
8934 · #443: Allow referencing external graphviz files.
8935
8936 · Added inline option to graphviz directives, and fixed the default
8937 (block-style) in LaTeX output.
8938
8939 · #590: Added caption option to graphviz directives.
8940
8941 · #553: Added testcleanup blocks in the doctest extension.
8942
8943 · #594: trim_doctest_flags now also removes <BLANKLINE> indicators.
8944
8945 · #367: Added automatic exclusion of hidden members in inheritance
8946 diagrams, and an option to selectively enable it.
8947
8948 · Added pngmath_add_tooltips.
8949
8950 · The math extension displaymath directives now support name in addi‐
8951 tion to label for giving the equation label, for compatibility with
8952 Docutils.
8953
8954 · New locales:
8955
8956 · #221: Added Swedish locale.
8957
8958 · #526: Added Iranian locale.
8959
8960 · #694: Added Latvian locale.
8961
8962 · Added Nepali locale.
8963
8964 · #714: Added Korean locale.
8965
8966 · #766: Added Estonian locale.
8967
8968 · Bugs fixed:
8969
8970 · #778: Fix "hide search matches" link on pages linked by search.
8971
8972 · Fix the source positions referenced by the "viewcode" extension.
8973
8974 Release 1.0.8 (Sep 23, 2011)
8975 · #627: Fix tracebacks for AttributeErrors in autosummary generation.
8976
8977 · Fix the abbr role when the abbreviation has newlines in it.
8978
8979 · #727: Fix the links to search results with custom object types.
8980
8981 · #648: Fix line numbers reported in warnings about undefined refer‐
8982 ences.
8983
8984 · #696, #666: Fix C++ array definitions and template arguments that are
8985 not type names.
8986
8987 · #633: Allow footnotes in section headers in LaTeX output.
8988
8989 · #616: Allow keywords to be linked via intersphinx.
8990
8991 · #613: Allow Unicode characters in production list token names.
8992
8993 · #720: Add dummy visitors for graphviz nodes for text and man.
8994
8995 · #704: Fix image file duplication bug.
8996
8997 · #677: Fix parsing of multiple signatures in C++ domain.
8998
8999 · #637: Ignore Emacs lock files when looking for source files.
9000
9001 · #544: Allow .pyw extension for importable modules in autodoc.
9002
9003 · #700: Use $(MAKE) in quickstart-generated Makefiles.
9004
9005 · #734: Make sidebar search box width consistent in browsers.
9006
9007 · #644: Fix spacing of centered figures in HTML output.
9008
9009 · #767: Safely encode SphinxError messages when printing them to
9010 sys.stderr.
9011
9012 · #611: Fix LaTeX output error with a document with no sections but a
9013 link target.
9014
9015 · Correctly treat built-in method descriptors as methods in autodoc.
9016
9017 · #706: Stop monkeypatching the Python textwrap module.
9018
9019 · #657: viewcode now works correctly with source files that have
9020 non-ASCII encoding.
9021
9022 · #669: Respect the noindex flag option in py:module directives.
9023
9024 · #675: Fix IndexErrors when including nonexisting lines with literal‐
9025 include.
9026
9027 · #676: Respect custom function/method parameter separator strings.
9028
9029 · #682: Fix JS incompatibility with jQuery >= 1.5.
9030
9031 · #693: Fix double encoding done when writing HTMLHelp .hhk files.
9032
9033 · #647: Do not apply SmartyPants in parsed-literal blocks.
9034
9035 · C++ domain now supports array definitions.
9036
9037 Release 1.0.7 (Jan 15, 2011)
9038 · #347: Fix wrong generation of directives of static methods in auto‐
9039 summary.
9040
9041 · #599: Import PIL as from PIL import Image.
9042
9043 · #558: Fix longtables with captions in LaTeX output.
9044
9045 · Make token references work as hyperlinks again in LaTeX output.
9046
9047 · #572: Show warnings by default when reference labels cannot be found.
9048
9049 · #536: Include line number when complaining about missing reference
9050 targets in nitpicky mode.
9051
9052 · #590: Fix inline display of graphviz diagrams in LaTeX output.
9053
9054 · #589: Build using app.build() in setup command.
9055
9056 · Fix a bug in the inheritance diagram exception that caused base
9057 classes to be skipped if one of them is a builtin.
9058
9059 · Fix general index links for C++ domain objects.
9060
9061 · #332: Make admonition boundaries in LaTeX output visible.
9062
9063 · #573: Fix KeyErrors occurring on rebuild after removing a file.
9064
9065 · Fix a traceback when removing files with globbed toctrees.
9066
9067 · If an autodoc object cannot be imported, always re-read the document
9068 containing the directive on next build.
9069
9070 · If an autodoc object cannot be imported, show the full traceback of
9071 the import error.
9072
9073 · Fix a bug where the removal of download files and images wasn't
9074 noticed.
9075
9076 · #571: Implement ~ cross-reference prefix for the C domain.
9077
9078 · Fix regression of LaTeX output with the fix of #556.
9079
9080 · #568: Fix lookup of class attribute documentation on descriptors so
9081 that comment documentation now works.
9082
9083 · Fix traceback with only directives preceded by targets.
9084
9085 · Fix tracebacks occurring for duplicate C++ domain objects.
9086
9087 · Fix JavaScript domain links to objects with $ in their name.
9088
9089 Release 1.0.6 (Jan 04, 2011)
9090 · #581: Fix traceback in Python domain for empty cross-reference tar‐
9091 gets.
9092
9093 · #283: Fix literal block display issues on Chrome browsers.
9094
9095 · #383, #148: Support sorting a limited range of accented characters in
9096 the general index and the glossary.
9097
9098 · #570: Try decoding -D and -A command-line arguments with the locale's
9099 preferred encoding.
9100
9101 · #528: Observe locale_dirs when looking for the JS translations file.
9102
9103 · #574: Add special code for better support of Japanese documents in
9104 the LaTeX builder.
9105
9106 · Regression of #77: If there is only one parameter given with :param:
9107 markup, the bullet list is now suppressed again.
9108
9109 · #556: Fix missing paragraph breaks in LaTeX output in certain situa‐
9110 tions.
9111
9112 · #567: Emit the autodoc-process-docstring event even for objects with‐
9113 out a docstring so that it can add content.
9114
9115 · #565: In the LaTeX builder, not only literal blocks require different
9116 table handling, but also quite a few other list-like block elements.
9117
9118 · #515: Fix tracebacks in the viewcode extension for Python objects
9119 that do not have a valid signature.
9120
9121 · Fix strange reportings of line numbers for warnings generated from
9122 autodoc-included docstrings, due to different behavior depending on
9123 docutils version.
9124
9125 · Several fixes to the C++ domain.
9126
9127 Release 1.0.5 (Nov 12, 2010)
9128 · #557: Add CSS styles required by docutils 0.7 for aligned images and
9129 figures.
9130
9131 · In the Makefile generated by LaTeX output, do not delete pdf files on
9132 clean; they might be required images.
9133
9134 · #535: Fix LaTeX output generated for line blocks.
9135
9136 · #544: Allow .pyw as a source file extension.
9137
9138 Release 1.0.4 (Sep 17, 2010)
9139 · #524: Open intersphinx inventories in binary mode on Windows, since
9140 version 2 contains zlib-compressed data.
9141
9142 · #513: Allow giving non-local URIs for JavaScript files, e.g. in the
9143 JSMath extension.
9144
9145 · #512: Fix traceback when intersphinx_mapping is empty.
9146
9147 Release 1.0.3 (Aug 23, 2010)
9148 · #495: Fix internal vs. external link distinction for links coming
9149 from a docutils table-of-contents.
9150
9151 · #494: Fix the maxdepth option for the toctree() template callable
9152 when used with collapse=True.
9153
9154 · #507: Fix crash parsing Python argument lists containing brackets in
9155 string literals.
9156
9157 · #501: Fix regression when building LaTeX docs with figures that don't
9158 have captions.
9159
9160 · #510: Fix inheritance diagrams for classes that are not picklable.
9161
9162 · #497: Introduce separate background color for the sidebar collapse
9163 button, making it easier to see.
9164
9165 · #502, #503, #496: Fix small layout bugs in several builtin themes.
9166
9167 Release 1.0.2 (Aug 14, 2010)
9168 · #490: Fix cross-references to objects of types added by the
9169 add_object_type() API function.
9170
9171 · Fix handling of doc field types for different directive types.
9172
9173 · Allow breaking long signatures, continuing with backlash-escaped new‐
9174 lines.
9175
9176 · Fix unwanted styling of C domain references (because of a namespace
9177 clash with Pygments styles).
9178
9179 · Allow references to PEPs and RFCs with explicit anchors.
9180
9181 · #471: Fix LaTeX references to figures.
9182
9183 · #482: When doing a non-exact search, match only the given type of
9184 object.
9185
9186 · #481: Apply non-exact search for Python reference targets with .name
9187 for modules too.
9188
9189 · #484: Fix crash when duplicating a parameter in an info field list.
9190
9191 · #487: Fix setting the default role to one provided by the oldcmarkup
9192 extension.
9193
9194 · #488: Fix crash when json-py is installed, which provides a json mod‐
9195 ule but is incompatible to simplejson.
9196
9197 · #480: Fix handling of target naming in intersphinx.
9198
9199 · #486: Fix removal of ! for all cross-reference roles.
9200
9201 Release 1.0.1 (Jul 27, 2010)
9202 · #470: Fix generated target names for reST domain objects; they are
9203 not in the same namespace.
9204
9205 · #266: Add Bengali language.
9206
9207 · #473: Fix a bug in parsing JavaScript object names.
9208
9209 · #474: Fix building with SingleHTMLBuilder when there is no toctree.
9210
9211 · Fix display names for objects linked to by intersphinx with explicit
9212 targets.
9213
9214 · Fix building with the JSON builder.
9215
9216 · Fix hyperrefs in object descriptions for LaTeX.
9217
9218 Release 1.0 (Jul 23, 2010)
9219 Incompatible changes
9220 · Support for domains has been added. A domain is a collection of
9221 directives and roles that all describe objects belonging together,
9222 e.g. elements of a programming language. A few builtin domains are
9223 provided:
9224
9225 · Python
9226
9227 · C
9228
9229 · C++
9230
9231 · JavaScript
9232
9233 · reStructuredText
9234
9235 · The old markup for defining and linking to C directives is now depre‐
9236 cated. It will not work anymore in future versions without activat‐
9237 ing the oldcmarkup extension; in Sphinx 1.0, it is activated by
9238 default.
9239
9240 · Removed support for old dependency versions; requirements are now:
9241
9242 · docutils >= 0.5
9243
9244 · Jinja2 >= 2.2
9245
9246 · Removed deprecated elements:
9247
9248 · exclude_dirs config value
9249
9250 · sphinx.builder module
9251
9252 Features added
9253 · General:
9254
9255 · Added a "nitpicky" mode that emits warnings for all missing refer‐
9256 ences. It is activated by the -n command-line switch or the nit‐
9257 picky config value.
9258
9259 · Added latexpdf target in quickstart Makefile.
9260
9261 · Markup:
9262
9263 · The menuselection and guilabel roles now support ampersand acceler‐
9264 ators.
9265
9266 · New more compact doc field syntax is now recognized: :param type
9267 name: description.
9268
9269 · Added tab-width option to literalinclude directive.
9270
9271 · Added titlesonly option to toctree directive.
9272
9273 · Added the prepend and append options to the literalinclude direc‐
9274 tive.
9275
9276 · #284: All docinfo metadata is now put into the document metadata,
9277 not just the author.
9278
9279 · The ref role can now also reference tables by caption.
9280
9281 · The include directive now supports absolute paths, which are inter‐
9282 preted as relative to the source directory.
9283
9284 · In the Python domain, references like :func:`.name` now look for
9285 matching names with any prefix if no direct match is found.
9286
9287 · Configuration:
9288
9289 · Added rst_prolog config value.
9290
9291 · Added html_secnumber_suffix config value to control section number‐
9292 ing format.
9293
9294 · Added html_compact_lists config value to control docutils' compact
9295 lists feature.
9296
9297 · The html_sidebars config value can now contain patterns as keys,
9298 and the values can be lists that explicitly select which sidebar
9299 templates should be rendered. That means that the builtin sidebar
9300 contents can be included only selectively.
9301
9302 · html_static_path can now contain single file entries.
9303
9304 · The new universal config value exclude_patterns makes the old
9305 unused_docs, exclude_trees and exclude_dirnames obsolete.
9306
9307 · Added html_output_encoding config value.
9308
9309 · Added the latex_docclass config value and made the "twoside" docu‐
9310 mentclass option overridable by "oneside".
9311
9312 · Added the trim_doctest_flags config value, which is true by
9313 default.
9314
9315 · Added html_show_copyright config value.
9316
9317 · Added latex_show_pagerefs and latex_show_urls config values.
9318
9319 · The behavior of html_file_suffix changed slightly: the empty string
9320 now means "no suffix" instead of "default suffix", use None for
9321 "default suffix".
9322
9323 · New builders:
9324
9325 · Added a builder for the Epub format.
9326
9327 · Added a builder for manual pages.
9328
9329 · Added a single-file HTML builder.
9330
9331 · HTML output:
9332
9333 · Inline roles now get a CSS class with their name, allowing styles
9334 to customize their appearance. Domain-specific roles get two
9335 classes, domain and domain-rolename.
9336
9337 · References now get the class internal if they are internal to the
9338 whole project, as opposed to internal to the current page.
9339
9340 · External references can be styled differently with the new exter‐
9341 nalrefs theme option for the default theme.
9342
9343 · In the default theme, the sidebar can experimentally now be made
9344 collapsible using the new collapsiblesidebar theme option.
9345
9346 · #129: Toctrees are now wrapped in a div tag with class toc‐
9347 tree-wrapper in HTML output.
9348
9349 · The toctree callable in templates now has a maxdepth keyword argu‐
9350 ment to control the depth of the generated tree.
9351
9352 · The toctree callable in templates now accepts a titles_only keyword
9353 argument.
9354
9355 · Added htmltitle block in layout template.
9356
9357 · In the JavaScript search, allow searching for object names includ‐
9358 ing the module name, like sys.argv.
9359
9360 · Added new theme haiku, inspired by the Haiku OS user guide.
9361
9362 · Added new theme nature.
9363
9364 · Added new theme agogo, created by Andi Albrecht.
9365
9366 · Added new theme scrolls, created by Armin Ronacher.
9367
9368 · #193: Added a visitedlinkcolor theme option to the default theme.
9369
9370 · #322: Improved responsiveness of the search page by loading the
9371 search index asynchronously.
9372
9373 · Extension API:
9374
9375 · Added html-collect-pages.
9376
9377 · Added needs_sphinx config value and require_sphinx() application
9378 API method.
9379
9380 · #200: Added add_stylesheet() application API method.
9381
9382 · Extensions:
9383
9384 · Added the viewcode extension.
9385
9386 · Added the extlinks extension.
9387
9388 · Added support for source ordering of members in autodoc, with
9389 autodoc_member_order = 'bysource'.
9390
9391 · Added autodoc_default_flags config value, which can be used to
9392 select default flags for all autodoc directives.
9393
9394 · Added a way for intersphinx to refer to named labels in other
9395 projects, and to specify the project you want to link to.
9396
9397 · #280: Autodoc can now document instance attributes assigned in
9398 __init__ methods.
9399
9400 · Many improvements and fixes to the autosummary extension, thanks to
9401 Pauli Virtanen.
9402
9403 · #309: The graphviz extension can now output SVG instead of PNG
9404 images, controlled by the graphviz_output_format config value.
9405
9406 · Added alt option to graphviz extension directives.
9407
9408 · Added exclude argument to autodoc.between().
9409
9410 · Translations:
9411
9412 · Added Croatian translation, thanks to Bojan Mihelač.
9413
9414 · Added Turkish translation, thanks to Firat Ozgul.
9415
9416 · Added Catalan translation, thanks to Pau Fernández.
9417
9418 · Added simplified Chinese translation.
9419
9420 · Added Danish translation, thanks to Hjorth Larsen.
9421
9422 · Added Lithuanian translation, thanks to Dalius Dobravolskas.
9423
9424 · Bugs fixed:
9425
9426 · #445: Fix links to result pages when using the search function of
9427 HTML built with the dirhtml builder.
9428
9429 · #444: In templates, properly re-escape values treated with the
9430 "striptags" Jinja filter.
9431
9432 Release 0.6.7 (Jun 05, 2010)
9433 · #440: Remove usage of a Python >= 2.5 API in the literalinclude
9434 directive.
9435
9436 · Fix a bug that prevented some references being generated in the LaTeX
9437 builder.
9438
9439 · #428: Add some missing CSS styles for standard docutils classes.
9440
9441 · #432: Fix UnicodeErrors while building LaTeX in translated locale.
9442
9443 Release 0.6.6 (May 25, 2010)
9444 · Handle raw nodes in the text writer.
9445
9446 · Fix a problem the Qt help project generated by the qthelp builder
9447 that would lead to no content being displayed in the Qt Assistant.
9448
9449 · #393: Fix the usage of Unicode characters in mathematic formulas when
9450 using the pngmath extension.
9451
9452 · #404: Make \and work properly in the author field of the latex_docu‐
9453 ments setting.
9454
9455 · #409: Make the highlight_language config value work properly in the
9456 LaTeX builder.
9457
9458 · #418: Allow relocation of the translation JavaScript files to the
9459 system directory on Unix systems.
9460
9461 · #414: Fix handling of Windows newlines in files included with the
9462 literalinclude directive.
9463
9464 · #377: Fix crash in linkcheck builder.
9465
9466 · #387: Fix the display of search results in dirhtml output.
9467
9468 · #376: In autodoc, fix display of parameter defaults containing back‐
9469 slashes.
9470
9471 · #370: Fix handling of complex list item labels in LaTeX output.
9472
9473 · #374: Make the doctest_path config value of the doctest extension
9474 actually work.
9475
9476 · Fix the handling of multiple toctrees when creating the global TOC
9477 for the toctree() template function.
9478
9479 · Fix the handling of hidden toctrees when creating the global TOC for
9480 the toctree() template function.
9481
9482 · Fix the handling of nested lists in the text writer.
9483
9484 · #362: In autodoc, check for the existence of __self__ on function
9485 objects before accessing it.
9486
9487 · #353: Strip leading and trailing whitespace when extracting search
9488 words in the search function.
9489
9490 Release 0.6.5 (Mar 01, 2010)
9491 · In autodoc, fix the omission of some module members explicitly docu‐
9492 mented using documentation comments.
9493
9494 · #345: Fix cropping of sidebar scroll bar with stickysidebar option of
9495 the default theme.
9496
9497 · #341: Always generate UNIX newlines in the quickstart Makefile.
9498
9499 · #338: Fix running with -C under Windows.
9500
9501 · In autodoc, allow customizing the signature of an object where the
9502 built-in mechanism fails.
9503
9504 · #331: Fix output for enumerated lists with start values in LaTeX.
9505
9506 · Make the start-after and end-before options to the literalinclude
9507 directive work correctly if not used together.
9508
9509 · #321: Fix link generation in the LaTeX builder.
9510
9511 Release 0.6.4 (Jan 12, 2010)
9512 · Improve the handling of non-Unicode strings in the configuration.
9513
9514 · #316: Catch OSErrors occurring when calling graphviz with arguments
9515 it doesn't understand.
9516
9517 · Restore compatibility with Pygments >= 1.2.
9518
9519 · #295: Fix escaping of hyperref targets in LaTeX output.
9520
9521 · #302: Fix links generated by the :doc: role for LaTeX output.
9522
9523 · #286: collect todo nodes after the whole document has been read; this
9524 allows placing substitution references in todo items.
9525
9526 · #294: do not ignore an explicit today config value in a LaTeX build.
9527
9528 · The alt text of inheritance diagrams is now much cleaner.
9529
9530 · Ignore images in section titles when generating link captions.
9531
9532 · #310: support exception messages in the testoutput blocks of the
9533 doctest extension.
9534
9535 · #293: line blocks are styled properly in HTML output.
9536
9537 · #285: make the locale_dirs config value work again.
9538
9539 · #303: html_context values given on the command line via -A should not
9540 override other values given in conf.py.
9541
9542 · Fix a bug preventing incremental rebuilds for the dirhtml builder.
9543
9544 · #299: Fix the mangling of quotes in some literal blocks.
9545
9546 · #292: Fix path to the search index for the dirhtml builder.
9547
9548 · Fix a Jython compatibility issue: make the dependence on the parser
9549 module optional.
9550
9551 · #238: In autodoc, catch all errors that occur on module import, not
9552 just ImportError.
9553
9554 · Fix the handling of non-data, but non-method descriptors in autodoc.
9555
9556 · When copying file times, ignore OSErrors raised by os.utime().
9557
9558 Release 0.6.3 (Sep 03, 2009)
9559 · Properly add C module filenames as dependencies in autodoc.
9560
9561 · #253: Ignore graphviz directives without content instead of raising
9562 an unhandled exception.
9563
9564 · #241: Fix a crash building LaTeX output for documents that contain a
9565 todolist directive.
9566
9567 · #252: Make it easier to change the build dir in the Makefiles gener‐
9568 ated by quickstart.
9569
9570 · #220: Fix CSS so that displaymath really is centered.
9571
9572 · #222: Allow the "Footnotes" header to be translated.
9573
9574 · #225: Don't add whitespace in generated HTML after inline tags.
9575
9576 · #227: Make literalinclude work when the document's path name contains
9577 non-ASCII characters.
9578
9579 · #229: Fix autodoc failures with members that raise errors on
9580 getattr().
9581
9582 · #205: When copying files, don't copy full stat info, only modifica‐
9583 tion times.
9584
9585 · #232: Support non-ASCII metadata in Qt help builder.
9586
9587 · Properly format bullet lists nested in definition lists for LaTeX.
9588
9589 · Section titles are now allowed inside only directives.
9590
9591 · #201: Make centered directive work in LaTeX output.
9592
9593 · #206: Refuse to overwrite an existing master document in
9594 sphinx-quickstart.
9595
9596 · #208: Use MS-sanctioned locale settings, determined by the language
9597 config option, in the HTML help builder.
9598
9599 · #210: Fix nesting of HTML tags for displayed math from pngmath exten‐
9600 sion.
9601
9602 · #213: Fix centering of images in LaTeX output.
9603
9604 · #211: Fix compatibility with docutils 0.5.
9605
9606 Release 0.6.2 (Jun 16, 2009)
9607 · #130: Fix obscure IndexError in doctest extension.
9608
9609 · #167: Make glossary sorting case-independent.
9610
9611 · #196: Add a warning if an extension module doesn't have a setup()
9612 function.
9613
9614 · #158: Allow '..' in template names, and absolute template paths;
9615 Jinja 2 by default disables both.
9616
9617 · When highlighting Python code, ignore extra indentation before trying
9618 to parse it as Python.
9619
9620 · #191: Don't escape the tilde in URIs in LaTeX.
9621
9622 · Don't consider contents of source comments for the search index.
9623
9624 · Set the default encoding to utf-8-sig to handle files with a UTF-8
9625 BOM correctly.
9626
9627 · #178: apply add_function_parentheses config value to C functions as
9628 promised.
9629
9630 · #173: Respect the docutils title directive.
9631
9632 · #172: The obj role now links to modules as promised.
9633
9634 · #19: Tables now can have a "longtable" class, in order to get cor‐
9635 rectly broken into pages in LaTeX output.
9636
9637 · Look for Sphinx message catalogs in the system default path before
9638 trying sphinx/locale.
9639
9640 · Fix the search for methods via "classname.methodname".
9641
9642 · #155: Fix Python 2.4 compatibility: exceptions are old-style classes
9643 there.
9644
9645 · #150: Fix display of the "sphinxdoc" theme on Internet Explorer ver‐
9646 sions 6 and 7.
9647
9648 · #146: Don't fail to generate LaTeX when the user has an active .docu‐
9649 tils configuration.
9650
9651 · #29: Don't generate visible "-{-}" in option lists in LaTeX.
9652
9653 · Fix cross-reference roles when put into substitutions.
9654
9655 · Don't put image "alt" text into table-of-contents entries.
9656
9657 · In the LaTeX writer, do not raise an exception on too many section
9658 levels, just use the "subparagraph" level for all of them.
9659
9660 · #145: Fix autodoc problem with automatic members that refuse to be
9661 getattr()'d from their parent.
9662
9663 · If specific filenames to build are given on the command line, check
9664 that they are within the source directory.
9665
9666 · Fix autodoc crash for objects without a __name__.
9667
9668 · Fix intersphinx for installations without urllib2.HTTPSHandler.
9669
9670 · #134: Fix pending_xref leftover nodes when using the todolist direc‐
9671 tive from the todo extension.
9672
9673 Release 0.6.1 (Mar 26, 2009)
9674 · #135: Fix problems with LaTeX output and the graphviz extension.
9675
9676 · #132: Include the autosummary "module" template in the distribution.
9677
9678 Release 0.6 (Mar 24, 2009)
9679 New features added
9680 · Incompatible changes:
9681
9682 · Templating now requires the Jinja2 library, which is an enhanced
9683 version of the old Jinja1 engine. Since the syntax and semantic is
9684 largely the same, very few fixes should be necessary in custom tem‐
9685 plates.
9686
9687 · The "document" div tag has been moved out of the layout.html tem‐
9688 plate's "document" block, because the closing tag was already out‐
9689 side. If you overwrite this block, you need to remove your "docu‐
9690 ment" div tag as well.
9691
9692 · The autodoc_skip_member event now also gets to decide whether to
9693 skip members whose name starts with underscores. Previously, these
9694 members were always automatically skipped. Therefore, if you han‐
9695 dle this event, add something like this to your event handler to
9696 restore the old behavior:
9697
9698 if name.startswith('_'):
9699 return True
9700
9701 · Theming support, see the new section in the documentation.
9702
9703 · Markup:
9704
9705 · Due to popular demand, added a :doc: role which directly links to
9706 another document without the need of creating a label to which a
9707 :ref: could link to.
9708
9709 · #4: Added a :download: role that marks a non-document file for
9710 inclusion into the HTML output and links to it.
9711
9712 · Added an only directive that can selectively include text based on
9713 enabled "tags". Tags can be given on the command line. Also, the
9714 current builder output format (e.g. "html" or "latex") is always a
9715 defined tag.
9716
9717 · #10: Added HTML section numbers, enabled by giving a :numbered:
9718 flag to the toctree directive.
9719
9720 · #114: Added an abbr role to markup abbreviations and acronyms.
9721
9722 · The literalinclude directive now supports several more options, to
9723 include only parts of a file.
9724
9725 · The toctree directive now supports a :hidden: flag, which will pre‐
9726 vent links from being generated in place of the directive -- this
9727 allows you to define your document structure, but place the links
9728 yourself.
9729
9730 · #123: The glossary directive now supports a :sorted: flag that
9731 sorts glossary entries alphabetically.
9732
9733 · Paths to images, literal include files and download files can now
9734 be absolute (like /images/foo.png). They are treated as relative
9735 to the top source directory.
9736
9737 · #52: There is now a hlist directive, creating a compact list by
9738 placing distributing items into multiple columns.
9739
9740 · #77: If a description environment with info field list only con‐
9741 tains one :param: entry, no bullet list is generated.
9742
9743 · #6: Don't generate redundant <ul> for top-level TOC tree items,
9744 which leads to a visual separation of TOC entries.
9745
9746 · #23: Added a classmethod directive along with method and stat‐
9747 icmethod.
9748
9749 · Scaled images now get a link to the unscaled version.
9750
9751 · SVG images are now supported in HTML (via <object> and <embed>
9752 tags).
9753
9754 · Added a toctree callable to the templates, and the ability to
9755 include external links in toctrees. The 'collapse' keyword argument
9756 indicates whether or not to only display subitems of the current
9757 page. (Defaults to True.)
9758
9759 · Configuration:
9760
9761 · The new config value rst_epilog can contain reST that is appended
9762 to each source file that is read. This is the right place for
9763 global substitutions.
9764
9765 · The new html_add_permalinks config value can be used to switch off
9766 the generated "paragraph sign" permalinks for each heading and def‐
9767 inition environment.
9768
9769 · The new html_show_sourcelink config value can be used to switch off
9770 the links to the reST sources in the sidebar.
9771
9772 · The default value for htmlhelp_basename is now the project title,
9773 cleaned up as a filename.
9774
9775 · The new modindex_common_prefix config value can be used to ignore
9776 certain package names for module index sorting.
9777
9778 · The new trim_footnote_reference_space config value mirrors the
9779 docutils config value of the same name and removes the space before
9780 a footnote reference that is necessary for reST to recognize the
9781 reference.
9782
9783 · The new latex_additional_files config value can be used to copy
9784 files (that Sphinx doesn't copy automatically, e.g. if they are
9785 referenced in custom LaTeX added in latex_elements) to the build
9786 directory.
9787
9788 · Builders:
9789
9790 · The HTML builder now stores a small file named .buildinfo in its
9791 output directory. It stores a hash of config values that can be
9792 used to determine if a full rebuild needs to be done (e.g. after
9793 changing html_theme).
9794
9795 · New builder for Qt help collections, by Antonio Valentino.
9796
9797 · The new DirectoryHTMLBuilder (short name dirhtml) creates a sepa‐
9798 rate directory for every page, and places the page there in a file
9799 called index.html. Therefore, page URLs and links don't need to
9800 contain .html.
9801
9802 · The new html_link_suffix config value can be used to select the
9803 suffix of generated links between HTML files.
9804
9805 · #96: The LaTeX builder now supports figures wrapped by text, when
9806 using the figwidth option and right/left alignment.
9807
9808 · New translations:
9809
9810 · Italian by Sandro Dentella.
9811
9812 · Ukrainian by Petro Sasnyk.
9813
9814 · Finnish by Jukka Inkeri.
9815
9816 · Russian by Alexander Smishlajev.
9817
9818 · Extensions and API:
9819
9820 · New graphviz extension to embed graphviz graphs.
9821
9822 · New inheritance_diagram extension to embed... inheritance diagrams!
9823
9824 · New autosummary extension that generates summaries of modules and
9825 automatic documentation of modules.
9826
9827 · Autodoc now has a reusable Python API, which can be used to create
9828 custom types of objects to auto-document (e.g. Zope interfaces).
9829 See also Sphinx.add_autodocumenter().
9830
9831 · Autodoc now handles documented attributes.
9832
9833 · Autodoc now handles inner classes and their methods.
9834
9835 · Autodoc can document classes as functions now if explicitly marked
9836 with autofunction.
9837
9838 · Autodoc can now exclude single members from documentation via the
9839 exclude-members option.
9840
9841 · Autodoc can now order members either alphabetically (like previ‐
9842 ously) or by member type; configurable either with the config value
9843 autodoc_member_order or a member-order option per directive.
9844
9845 · The function Sphinx.add_directive() now also supports docutils
9846 0.5-style directive classes. If they inherit from sphinx.util.com‐
9847 pat.Directive, they also work with docutils 0.4.
9848
9849 · There is now a Sphinx.add_lexer() method to be able to use custom
9850 Pygments lexers easily.
9851
9852 · There is now Sphinx.add_generic_role() to mirror the docutils' own
9853 function.
9854
9855 · Other changes:
9856
9857 · Config overrides for single dict keys can now be given on the com‐
9858 mand line.
9859
9860 · There is now a doctest_global_setup config value that can be used
9861 to give setup code for all doctests in the documentation.
9862
9863 · Source links in HTML are now generated with rel="nofollow".
9864
9865 · Quickstart can now generate a Windows make.bat file.
9866
9867 · #62: There is now a -w option for sphinx-build that writes warnings
9868 to a file, in addition to stderr.
9869
9870 · There is now a -W option for sphinx-build that turns warnings into
9871 errors.
9872
9873 Release 0.5.2 (Mar 24, 2009)
9874 · Properly escape | in LaTeX output.
9875
9876 · #71: If a decoding error occurs in source files, print a warning and
9877 replace the characters by "?".
9878
9879 · Fix a problem in the HTML search if the index takes too long to load.
9880
9881 · Don't output system messages while resolving, because they would stay
9882 in the doctrees even if keep_warnings is false.
9883
9884 · #82: Determine the correct path for dependencies noted by docutils.
9885 This fixes behavior where a source with dependent files was always
9886 reported as changed.
9887
9888 · Recognize toctree directives that are not on section toplevel, but
9889 within block items, such as tables.
9890
9891 · Use a new RFC base URL, since rfc.org seems down.
9892
9893 · Fix a crash in the todolist directive when no todo items are defined.
9894
9895 · Don't call LaTeX or dvipng over and over again if it was not found
9896 once, and use text-only latex as a substitute in that case.
9897
9898 · Fix problems with footnotes in the LaTeX output.
9899
9900 · Prevent double hyphens becoming en-dashes in literal code in the
9901 LaTeX output.
9902
9903 · Open literalinclude files in universal newline mode to allow arbi‐
9904 trary newline conventions.
9905
9906 · Actually make the -Q option work.
9907
9908 · #86: Fix explicit document titles in toctrees.
9909
9910 · #81: Write environment and search index in a manner that is safe from
9911 exceptions that occur during dumping.
9912
9913 · #80: Fix UnicodeErrors when a locale is set with setlocale().
9914
9915 Release 0.5.1 (Dec 15, 2008)
9916 · #67: Output warnings about failed doctests in the doctest extension
9917 even when running in quiet mode.
9918
9919 · #72: In pngmath, make it possible to give a full path to LaTeX and
9920 dvipng on Windows. For that to work, the pngmath_latex and png‐
9921 math_dvipng options are no longer split into command and additional
9922 arguments; use pngmath_latex_args and pngmath_dvipng_args to give
9923 additional arguments.
9924
9925 · Don't crash on failing doctests with non-ASCII characters.
9926
9927 · Don't crash on writing status messages and warnings containing unen‐
9928 codable characters.
9929
9930 · Warn if a doctest extension block doesn't contain any code.
9931
9932 · Fix the handling of :param: and :type: doc fields when they contain
9933 markup (especially cross-referencing roles).
9934
9935 · #65: Fix storage of depth information for PNGs generated by the png‐
9936 math extension.
9937
9938 · Fix autodoc crash when automethod is used outside a class context.
9939
9940 · #68: Fix LaTeX writer output for images with specified height.
9941
9942 · #60: Fix wrong generated image path when including images in sources
9943 in subdirectories.
9944
9945 · Fix the JavaScript search when html_copy_source is off.
9946
9947 · Fix an indentation problem in autodoc when documenting classes with
9948 the option autoclass_content = "both" set.
9949
9950 · Don't crash on empty index entries, only emit a warning.
9951
9952 · Fix a typo in the search JavaScript code, leading to unusable search
9953 function in some setups.
9954
9955 Release 0.5 (Nov 23, 2008) -- Birthday release!
9956 New features added
9957 · Markup features:
9958
9959 · Citations are now global: all citation defined in any file can be
9960 referenced from any file. Citations are collected in a bibliogra‐
9961 phy for LaTeX output.
9962
9963 · Footnotes are now properly handled in the LaTeX builder: they
9964 appear at the location of the footnote reference in text, not at
9965 the end of a section. Thanks to Andrew McNamara for the initial
9966 patch.
9967
9968 · "System Message" warnings are now automatically removed from the
9969 built documentation, and only written to stderr. If you want the
9970 old behavior, set the new config value keep_warnings to True.
9971
9972 · Glossary entries are now automatically added to the index.
9973
9974 · Figures with captions can now be referred to like section titles,
9975 using the :ref: role without an explicit link text.
9976
9977 · Added cmember role for consistency.
9978
9979 · Lists enumerated by letters or roman numerals are now handled like
9980 in standard reST.
9981
9982 · The seealso directive can now also be given arguments, as a short
9983 form.
9984
9985 · You can now document several programs and their options with the
9986 new program directive.
9987
9988 · HTML output and templates:
9989
9990 · Incompatible change: The "root" relation link (top left in the rel‐
9991 bar) now points to the master_doc by default, no longer to a docu‐
9992 ment called "index". The old behavior, while useful in some situa‐
9993 tions, was somewhat unexpected. Override the "rootrellink" block
9994 in the template to customize where it refers to.
9995
9996 · The JavaScript search now searches for objects before searching in
9997 the full text.
9998
9999 · TOC tree entries now have CSS classes that make it possible to
10000 style them depending on their depth.
10001
10002 · Highlighted code blocks now have CSS classes that make it possible
10003 to style them depending on their language.
10004
10005 · HTML <meta> tags via the docutils meta directive are now supported.
10006
10007 · SerializingHTMLBuilder was added as new abstract builder that can
10008 be subclassed to serialize build HTML in a specific format. The
10009 PickleHTMLBuilder is a concrete subclass of it that uses pickle as
10010 serialization implementation.
10011
10012 · JSONHTMLBuilder was added as another SerializingHTMLBuilder sub‐
10013 class that dumps the generated HTML into JSON files for further
10014 processing.
10015
10016 · The rellinks block in the layout template is now called linktags to
10017 avoid confusion with the relbar links.
10018
10019 · The HTML builders have two additional attributes now that can be
10020 used to disable the anchor-link creation after headlines and defi‐
10021 nition links.
10022
10023 · Only generate a module index if there are some modules in the docu‐
10024 mentation.
10025
10026 · New and changed config values:
10027
10028 · Added support for internationalization in generated text with the
10029 language and locale_dirs config values. Many thanks to language
10030 contributors:
10031
10032 · Horst Gutmann -- German
10033
10034 · Pavel Kosina -- Czech
10035
10036 · David Larlet -- French
10037
10038 · Michał Kandulski -- Polish
10039
10040 · Yasushi Masuda -- Japanese
10041
10042 · Guillem Borrell -- Spanish
10043
10044 · Luc Saffre and Peter Bertels -- Dutch
10045
10046 · Fred Lin -- Traditional Chinese
10047
10048 · Roger Demetrescu -- Brazilian Portuguese
10049
10050 · Rok Garbas -- Slovenian
10051
10052 · The new config value highlight_language set a global default for
10053 highlighting. When 'python3' is selected, console output blocks
10054 are recognized like for 'python'.
10055
10056 · Exposed Pygments' lexer guessing as a highlight "language" guess.
10057
10058 · The new config value latex_elements allows to override all LaTeX
10059 snippets that Sphinx puts into the generated .tex file by default.
10060
10061 · Added exclude_dirnames config value that can be used to exclude
10062 e.g. CVS directories from source file search.
10063
10064 · Added source_encoding config value to select input encoding.
10065
10066 · Extensions:
10067
10068 · The new extensions sphinx.ext.jsmath and sphinx.ext.pngmath provide
10069 math support for both HTML and LaTeX builders.
10070
10071 · The new extension sphinx.ext.intersphinx half-automatically creates
10072 links to Sphinx documentation of Python objects in other projects.
10073
10074 · The new extension sphinx.ext.todo allows the insertion of "To do"
10075 directives whose visibility in the output can be toggled. It also
10076 adds a directive to compile a list of all todo items.
10077
10078 · sphinx.ext.autodoc has a new event autodoc-process-signature that
10079 allows tuning function signature introspection.
10080
10081 · sphinx.ext.autodoc has a new event autodoc-skip-member that allows
10082 tuning which members are included in the generated content.
10083
10084 · Respect __all__ when autodocumenting module members.
10085
10086 · The automodule directive now supports the synopsis, deprecated and
10087 platform options.
10088
10089 · Extension API:
10090
10091 · Sphinx.add_node() now takes optional visitor methods for the HTML,
10092 LaTeX and text translators; this prevents having to manually patch
10093 the classes.
10094
10095 · Added Sphinx.add_javascript() that adds scripts to load in the
10096 default HTML template.
10097
10098 · Added new events: source-read, env-updated, env-purge-doc, miss‐
10099 ing-reference, build-finished.
10100
10101 · Other changes:
10102
10103 · Added a command-line switch -Q: it will suppress warnings.
10104
10105 · Added a command-line switch -A: it can be used to supply additional
10106 values into the HTML templates.
10107
10108 · Added a command-line switch -C: if it is given, no configuration
10109 file conf.py is required.
10110
10111 · Added a distutils command build_sphinx: When Sphinx is installed,
10112 you can call python setup.py build_sphinx for projects that have
10113 Sphinx documentation, which will build the docs and place them in
10114 the standard distutils build directory.
10115
10116 · In quickstart, if the selected root path already contains a Sphinx
10117 project, complain and abort.
10118
10119 Bugs fixed
10120 · #51: Escape configuration values placed in HTML templates.
10121
10122 · #44: Fix small problems in HTML help index generation.
10123
10124 · Fix LaTeX output for line blocks in tables.
10125
10126 · #38: Fix "illegal unit" error when using pixel image widths/heights.
10127
10128 · Support table captions in LaTeX output.
10129
10130 · #39: Work around a bug in Jinja that caused "<generator ...>" to be
10131 emitted in HTML output.
10132
10133 · Fix a problem with module links not being generated in LaTeX output.
10134
10135 · Fix the handling of images in different directories.
10136
10137 · #29: Support option lists in the text writer. Make sure that dashes
10138 introducing long option names are not contracted to en-dashes.
10139
10140 · Support the "scale" option for images in HTML output.
10141
10142 · #25: Properly escape quotes in HTML help attribute values.
10143
10144 · Fix LaTeX build for some description environments with :noindex:.
10145
10146 · #24: Don't crash on uncommon casing of role names (like :Class:).
10147
10148 · Only output ANSI colors on color terminals.
10149
10150 · Update to newest fncychap.sty, to fix problems with non-ASCII charac‐
10151 ters at the start of chapter titles.
10152
10153 · Fix a problem with index generation in LaTeX output, caused by hyper‐
10154 ref not being included last.
10155
10156 · Don't disregard return annotations for functions without any parame‐
10157 ters.
10158
10159 · Don't throw away labels for code blocks.
10160
10161 Release 0.4.3 (Oct 8, 2008)
10162 · Fix a bug in autodoc with directly given autodoc members.
10163
10164 · Fix a bug in autodoc that would import a module twice, once as "mod‐
10165 ule", once as "module.".
10166
10167 · Fix a bug in the HTML writer that created duplicate id attributes for
10168 section titles with docutils 0.5.
10169
10170 · Properly call super() in overridden blocks in templates.
10171
10172 · Add a fix when using XeTeX.
10173
10174 · Unify handling of LaTeX escaping.
10175
10176 · Rebuild everything when the extensions config value changes.
10177
10178 · Don't try to remove a nonexisting static directory.
10179
10180 · Fix an indentation problem in production lists.
10181
10182 · Fix encoding handling for literal include files: literalinclude now
10183 has an encoding option that defaults to UTF-8.
10184
10185 · Fix the handling of non-ASCII characters entered in quickstart.
10186
10187 · Fix a crash with nonexisting image URIs.
10188
10189 Release 0.4.2 (Jul 29, 2008)
10190 · Fix rendering of the samp role in HTML.
10191
10192 · Fix a bug with LaTeX links to headings leading to a wrong page.
10193
10194 · Reread documents with globbed toctrees when source files are added or
10195 removed.
10196
10197 · Add a missing parameter to PickleHTMLBuilder.handle_page().
10198
10199 · Put inheritance info always on its own line.
10200
10201 · Don't automatically enclose code with whitespace in it in quotes;
10202 only do this for the samp role.
10203
10204 · autodoc now emits a more precise error message when a module can't be
10205 imported or an attribute can't be found.
10206
10207 · The JavaScript search now uses the correct file name suffix when
10208 referring to found items.
10209
10210 · The automodule directive now accepts the inherited-members and
10211 show-inheritance options again.
10212
10213 · You can now rebuild the docs normally after relocating the source
10214 and/or doctree directory.
10215
10216 Release 0.4.1 (Jul 5, 2008)
10217 · Added sub-/superscript node handling to TextBuilder.
10218
10219 · Label names in references are now case-insensitive, since reST label
10220 names are always lowercased.
10221
10222 · Fix linkcheck builder crash for malformed URLs.
10223
10224 · Add compatibility for admonitions and docutils 0.5.
10225
10226 · Remove the silly restriction on "rubric" in the LaTeX writer: you can
10227 now write arbitrary "rubric" directives, and only those with a title
10228 of "Footnotes" will be ignored.
10229
10230 · Copy the HTML logo to the output _static directory.
10231
10232 · Fix LaTeX code for modules with underscores in names and platforms.
10233
10234 · Fix a crash with nonlocal image URIs.
10235
10236 · Allow the usage of :noindex: in automodule directives, as documented.
10237
10238 · Fix the delete() docstring processor function in autodoc.
10239
10240 · Fix warning message for nonexisting images.
10241
10242 · Fix JavaScript search in Internet Explorer.
10243
10244 Release 0.4 (Jun 23, 2008)
10245 New features added
10246 · tocdepth can be given as a file-wide metadata entry, and specifies
10247 the maximum depth of a TOC of this file.
10248
10249 · The new config value default_role can be used to select the default
10250 role for all documents.
10251
10252 · Sphinx now interprets field lists with fields like :param foo: in
10253 description units.
10254
10255 · The new staticmethod directive can be used to mark methods as static
10256 methods.
10257
10258 · HTML output:
10259
10260 · The "previous" and "next" links have a more logical structure, so
10261 that by following "next" links you can traverse the entire TOC
10262 tree.
10263
10264 · The new event html-page-context can be used to include custom val‐
10265 ues into the context used when rendering an HTML template.
10266
10267 · Document metadata is now in the default template context, under the
10268 name metadata.
10269
10270 · The new config value html_favicon can be used to set a favicon for
10271 the HTML output. Thanks to Sebastian Wiesner.
10272
10273 · The new config value html_use_index can be used to switch index
10274 generation in HTML documents off.
10275
10276 · The new config value html_split_index can be used to create sepa‐
10277 rate index pages for each letter, to be used when the complete
10278 index is too large for one page.
10279
10280 · The new config value html_short_title can be used to set a shorter
10281 title for the documentation which is then used in the navigation
10282 bar.
10283
10284 · The new config value html_show_sphinx can be used to control
10285 whether a link to Sphinx is added to the HTML footer.
10286
10287 · The new config value html_file_suffix can be used to set the HTML
10288 file suffix to e.g. .xhtml.
10289
10290 · The directories in the html_static_path can now contain subdirecto‐
10291 ries.
10292
10293 · The module index now isn't collapsed if the number of submodules is
10294 larger than the number of toplevel modules.
10295
10296 · The image directive now supports specifying the extension as .*,
10297 which makes the builder select the one that matches best. Thanks to
10298 Sebastian Wiesner.
10299
10300 · The new config value exclude_trees can be used to exclude whole sub‐
10301 trees from the search for source files.
10302
10303 · Defaults for configuration values can now be callables, which allows
10304 dynamic defaults.
10305
10306 · The new TextBuilder creates plain-text output.
10307
10308 · Python 3-style signatures, giving a return annotation via ->, are now
10309 supported.
10310
10311 · Extensions:
10312
10313 · The autodoc extension now offers a much more flexible way to manip‐
10314 ulate docstrings before including them into the output, via the new
10315 autodoc-process-docstring event.
10316
10317 · The autodoc extension accepts signatures for functions, methods and
10318 classes now that override the signature got via introspection from
10319 Python code.
10320
10321 · The autodoc extension now offers a show-inheritance option for
10322 autoclass that inserts a list of bases after the signature.
10323
10324 · The autodoc directives now support the noindex flag option.
10325
10326 Bugs fixed
10327 · Correctly report the source location for docstrings included with
10328 autodoc.
10329
10330 · Fix the LaTeX output of description units with multiple signatures.
10331
10332 · Handle the figure directive in LaTeX output.
10333
10334 · Handle raw admonitions in LaTeX output.
10335
10336 · Fix determination of the title in HTML help output.
10337
10338 · Handle project names containing spaces.
10339
10340 · Don't write SSI-like comments in HTML output.
10341
10342 · Rename the "sidebar" class to "sphinxsidebar" in order to stay dif‐
10343 ferent from reST sidebars.
10344
10345 · Use a binary TOC in HTML help generation to fix issues links without
10346 explicit anchors.
10347
10348 · Fix behavior of references to functions/methods with an explicit
10349 title.
10350
10351 · Support citation, subscript and superscript nodes in LaTeX writer.
10352
10353 · Provide the standard "class" directive as "cssclass"; else it is
10354 shadowed by the Sphinx-defined directive.
10355
10356 · Fix the handling of explicit module names given to autoclass direc‐
10357 tives. They now show up with the correct module name in the gener‐
10358 ated docs.
10359
10360 · Enable autodoc to process Unicode docstrings.
10361
10362 · The LaTeX writer now translates line blocks with \raggedright, which
10363 plays nicer with tables.
10364
10365 · Fix bug with directories in the HTML builder static path.
10366
10367 Release 0.3 (May 6, 2008)
10368 New features added
10369 · The toctree directive now supports a glob option that allows
10370 glob-style entries in the content.
10371
10372 · If the pygments_style config value contains a dot it's treated as the
10373 import path of a custom Pygments style class.
10374
10375 · A new config value, exclude_dirs, can be used to exclude whole direc‐
10376 tories from the search for source files.
10377
10378 · The configuration directory (containing conf.py) can now be set inde‐
10379 pendently from the source directory. For that, a new command-line
10380 option -c has been added.
10381
10382 · A new directive tabularcolumns can be used to give a tabular column
10383 specification for LaTeX output. Tables now use the tabulary package.
10384 Literal blocks can now be placed in tables, with several caveats.
10385
10386 · A new config value, latex_use_parts, can be used to enable parts in
10387 LaTeX documents.
10388
10389 · Autodoc now skips inherited members for classes, unless you give the
10390 new inherited-members option.
10391
10392 · A new config value, autoclass_content, selects if the docstring of
10393 the class' __init__ method is added to the directive's body.
10394
10395 · Support for C++ class names (in the style Class::Function) in C func‐
10396 tion descriptions.
10397
10398 · Support for a toctree_only item in items for the latex_documents con‐
10399 fig value. This only includes the documents referenced by TOC trees
10400 in the output, not the rest of the file containing the directive.
10401
10402 Bugs fixed
10403 · sphinx.htmlwriter: Correctly write the TOC file for any structure of
10404 the master document. Also encode non-ASCII characters as entities in
10405 TOC and index file. Remove two remaining instances of hard-coded
10406 "documentation".
10407
10408 · sphinx.ext.autodoc: descriptors are detected properly now.
10409
10410 · sphinx.latexwriter: implement all reST admonitions, not just note and
10411 warning.
10412
10413 · Lots of little fixes to the LaTeX output and style.
10414
10415 · Fix OpenSearch template and make template URL absolute. The
10416 html_use_opensearch config value now must give the base URL.
10417
10418 · Some unused files are now stripped from the HTML help file build.
10419
10420 Release 0.2 (Apr 27, 2008)
10421 Incompatible changes
10422 · Jinja, the template engine used for the default HTML templates, is
10423 now no longer shipped with Sphinx. If it is not installed automati‐
10424 cally for you (it is now listed as a dependency in setup.py), install
10425 it manually from PyPI. This will also be needed if you're using
10426 Sphinx from a SVN checkout; in that case please also remove the
10427 sphinx/jinja directory that may be left over from old revisions.
10428
10429 · The clumsy handling of the index.html template was removed. The con‐
10430 fig value html_index is gone, and html_additional_pages should be
10431 used instead. If you need it, the old index.html template is still
10432 there, called defindex.html, and you can port your html_index tem‐
10433 plate, using Jinja inheritance, by changing your template:
10434
10435 {% extends "defindex.html" %}
10436 {% block tables %}
10437 ... old html_index template content ...
10438 {% endblock %}
10439
10440 and putting 'index': name of your template in html_additional_pages.
10441
10442 · In the layout template, redundant blocks were removed; you should use
10443 Jinja's standard {{ super() }} mechanism instead, as explained in the
10444 (newly written) templating docs.
10445
10446 New features added
10447 · Extension API (Application object):
10448
10449 · Support a new method, add_crossref_type. It works like
10450 add_description_unit but the directive will only create a target
10451 and no output.
10452
10453 · Support a new method, add_transform. It takes a standard docutils
10454 Transform subclass which is then applied by Sphinx' reader on pars‐
10455 ing reST document trees.
10456
10457 · Add support for other template engines than Jinja, by adding an
10458 abstraction called a "template bridge". This class handles render‐
10459 ing of templates and can be changed using the new configuration
10460 value "template_bridge".
10461
10462 · The config file itself can be an extension (if it provides a set‐
10463 up() function).
10464
10465 · Markup:
10466
10467 · New directive, currentmodule. It can be used to indicate the mod‐
10468 ule name of the following documented things without creating index
10469 entries.
10470
10471 · Allow giving a different title to documents in the toctree.
10472
10473 · Allow giving multiple options in a cmdoption directive.
10474
10475 · Fix display of class members without explicit class name given.
10476
10477 · Templates (HTML output):
10478
10479 · index.html renamed to defindex.html, see above.
10480
10481 · There's a new config value, html_title, that controls the overall
10482 "title" of the set of Sphinx docs. It is used instead everywhere
10483 instead of "Projectname vX.Y documentation" now.
10484
10485 · All references to "documentation" in the templates have been
10486 removed, so that it is now easier to use Sphinx for non-documenta‐
10487 tion documents with the default templates.
10488
10489 · Templates now have an XHTML doctype, to be consistent with docu‐
10490 tils' HTML output.
10491
10492 · You can now create an OpenSearch description file with the
10493 html_use_opensearch config value.
10494
10495 · You can now quickly include a logo in the sidebar, using the
10496 html_logo config value.
10497
10498 · There are new blocks in the sidebar, so that you can easily insert
10499 content into the sidebar.
10500
10501 · LaTeX output:
10502
10503 · The sphinx.sty package was cleaned of unused stuff.
10504
10505 · You can include a logo in the title page with the latex_logo config
10506 value.
10507
10508 · You can define the link colors and a border and background color
10509 for verbatim environments.
10510
10511 Thanks to Jacob Kaplan-Moss, Talin, Jeroen Ruigrok van der Werven and
10512 Sebastian Wiesner for suggestions.
10513
10514 Bugs fixed
10515 · sphinx.ext.autodoc: Don't check __module__ for explicitly given mem‐
10516 bers. Remove "self" in class constructor argument list.
10517
10518 · sphinx.htmlwriter: Don't use os.path for joining image HREFs.
10519
10520 · sphinx.htmlwriter: Don't use SmartyPants for HTML attribute values.
10521
10522 · sphinx.latexwriter: Implement option lists. Also, some other changes
10523 were made to sphinx.sty in order to enhance compatibility and remove
10524 old unused stuff. Thanks to Gael Varoquaux for that!
10525
10526 · sphinx.roles: Fix referencing glossary terms with explicit targets.
10527
10528 · sphinx.environment: Don't swallow TOC entries when resolving sub‐
10529 trees.
10530
10531 · sphinx.quickstart: Create a sensible default latex_documents setting.
10532
10533 · sphinx.builder, sphinx.environment: Gracefully handle some user error
10534 cases.
10535
10536 · sphinx.util: Follow symbolic links when searching for documents.
10537
10538 Release 0.1.61950 (Mar 26, 2008)
10539 · sphinx.quickstart: Fix format string for Makefile.
10540
10541 Release 0.1.61945 (Mar 26, 2008)
10542 · sphinx.htmlwriter, sphinx.latexwriter: Support the .. image:: direc‐
10543 tive by copying image files to the output directory.
10544
10545 · sphinx.builder: Consistently name "special" HTML output directories
10546 with a leading underscore; this means _sources and _static.
10547
10548 · sphinx.environment: Take dependent files into account when collecting
10549 the set of outdated sources.
10550
10551 · sphinx.directives: Record files included with .. literalinclude:: as
10552 dependencies.
10553
10554 · sphinx.ext.autodoc: Record files from which docstrings are included
10555 as dependencies.
10556
10557 · sphinx.builder: Rebuild all HTML files in case of a template change.
10558
10559 · sphinx.builder: Handle unavailability of TOC relations (previous/
10560 next chapter) more gracefully in the HTML builder.
10561
10562 · sphinx.latexwriter: Include fncychap.sty which doesn't seem to be
10563 very common in TeX distributions. Add a clean target in the latex
10564 Makefile. Really pass the correct paper and size options to the
10565 LaTeX document class.
10566
10567 · setup: On Python 2.4, don't egg-depend on docutils if a docutils is
10568 already installed -- else it will be overwritten.
10569
10570 Release 0.1.61843 (Mar 24, 2008)
10571 · sphinx.quickstart: Really don't create a makefile if the user doesn't
10572 want one.
10573
10574 · setup: Don't install scripts twice, via setuptools entry points and
10575 distutils scripts. Only install via entry points.
10576
10577 · sphinx.builder: Don't recognize the HTML builder's copied source
10578 files (under _sources) as input files if the source suffix is .txt.
10579
10580 · sphinx.highlighting: Generate correct markup for LaTeX Verbatim envi‐
10581 ronment escapes even if Pygments is not installed.
10582
10583 · sphinx.builder: The WebHTMLBuilder is now called PickleHTMLBuilder.
10584
10585 · sphinx.htmlwriter: Make parsed-literal blocks work as expected, not
10586 highlighting them via Pygments.
10587
10588 · sphinx.environment: Don't error out on reading an empty source file.
10589
10590 Release 0.1.61798 (Mar 23, 2008)
10591 · sphinx: Work with docutils SVN snapshots as well as 0.4.
10592
10593 · sphinx.ext.doctest: Make the group in which doctest blocks are placed
10594 selectable, and default to 'default'.
10595
10596 · sphinx.ext.doctest: Replace <BLANKLINE> in doctest blocks by real
10597 blank lines for presentation output, and remove doctest options given
10598 inline.
10599
10600 · sphinx.environment: Move doctest_blocks out of block_quotes to sup‐
10601 port indented doctest blocks.
10602
10603 · sphinx.ext.autodoc: Render .. automodule:: docstrings in a section
10604 node, so that module docstrings can contain proper sectioning.
10605
10606 · sphinx.ext.autodoc: Use the module's encoding for decoding doc‐
10607 strings, rather than requiring ASCII.
10608
10609 Release 0.1.61611 (Mar 21, 2008)
10610 · First public release.
10611
10613 This is an (incomplete) alphabetic list of projects that use Sphinx or
10614 are experimenting with using it for their documentation. If you like
10615 to be included, please mail to the Google group.
10616
10617 I've grouped the list into sections to make it easier to find interest‐
10618 ing examples.
10619
10620 Documentation using the default theme
10621 · APSW: http://apidoc.apsw.googlecode.com/hg/index.html
10622
10623 · ASE: https://wiki.fysik.dtu.dk/ase/
10624
10625 · boostmpi: http://documen.tician.de/boostmpi/
10626
10627 · Calibre: http://calibre-ebook.com/user_manual/
10628
10629 · CodePy: http://documen.tician.de/codepy/
10630
10631 · Cython: http://docs.cython.org/
10632
10633 · C\C++ Python language binding project:
10634 http://language-binding.net/index.html
10635
10636 · Cormoran: http://cormoran.nhopkg.org/docs/
10637
10638 · Director: http://packages.python.org/director/
10639
10640 · Dirigible: http://www.projectdirigible.com/documentation/
10641
10642 · Elemental:
10643 http://elemental.googlecode.com/hg/doc/build/html/index.html
10644
10645 · F2py: http://f2py.sourceforge.net/docs/
10646
10647 · GeoDjango: http://geodjango.org/docs/
10648
10649 · Genomedata:
10650 http://noble.gs.washington.edu/proj/genomedata/doc/1.2.2/genomedata.html
10651
10652 · gevent: http://www.gevent.org/
10653
10654 · Google Wave API:
10655 http://wave-robot-python-client.googlecode.com/svn/trunk/pydocs/index.html
10656
10657 · GSL Shell: http://www.nongnu.org/gsl-shell/
10658
10659 · Heapkeeper: http://heapkeeper.org/
10660
10661 · Hands-on Python Tutorial:
10662 http://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/
10663
10664 · Hedge: http://documen.tician.de/hedge/
10665
10666 · Kaa: http://doc.freevo.org/api/kaa/
10667
10668 · Leo: http://webpages.charter.net/edreamleo/front.html
10669
10670 · Lino: http://lino.saffre-rumma.net/
10671
10672 · MeshPy: http://documen.tician.de/meshpy/
10673
10674 · mpmath: http://mpmath.googlecode.com/svn/trunk/doc/build/index.html
10675
10676 · OpenEXR: http://excamera.com/articles/26/doc/index.html
10677
10678 · OpenGDA: http://www.opengda.org/gdadoc/html/
10679
10680 · openWNS: http://docs.openwns.org/
10681
10682 · Paste: http://pythonpaste.org/script/
10683
10684 · Paver: http://paver.github.com/paver/
10685
10686 · Pyccuracy: https://github.com/heynemann/pyccuracy/wiki/
10687
10688 · PyCuda: http://documen.tician.de/pycuda/
10689
10690 · Pyevolve: http://pyevolve.sourceforge.net/
10691
10692 · Pylo: http://documen.tician.de/pylo/
10693
10694 · PyMQI: http://packages.python.org/pymqi/
10695
10696 · PyPubSub: http://pubsub.sourceforge.net/
10697
10698 · pyrticle: http://documen.tician.de/pyrticle/
10699
10700 · Python: http://docs.python.org/
10701
10702 · python-apt: http://apt.alioth.debian.org/python-apt-doc/
10703
10704 · PyUblas: http://documen.tician.de/pyublas/
10705
10706 · Quex: http://quex.sourceforge.net/doc/html/main.html
10707
10708 · Scapy: http://www.secdev.org/projects/scapy/doc/
10709
10710 · Segway:
10711 http://noble.gs.washington.edu/proj/segway/doc/1.1.0/segway.html
10712
10713 · SimPy: http://simpy.sourceforge.net/SimPyDocs/index.html
10714
10715 · SymPy: http://docs.sympy.org/
10716
10717 · WTForms: http://wtforms.simplecodes.com/docs/
10718
10719 · z3c: http://docs.carduner.net/z3c-tutorial/
10720
10721 Documentation using a customized version of the default theme
10722 · Advanced Generic Widgets:
10723 http://xoomer.virgilio.it/infinity77/AGW_Docs/index.html
10724
10725 · Bazaar: http://doc.bazaar.canonical.com/en/
10726
10727 · Chaco: http://code.enthought.com/projects/chaco/docs/html/
10728
10729 · Djagios: http://djagios.org/
10730
10731 · GetFEM++: http://home.gna.org/getfem/
10732
10733 · GPAW: https://wiki.fysik.dtu.dk/gpaw/
10734
10735 · Grok: http://grok.zope.org/doc/current/
10736
10737 · IFM: http://fluffybunny.memebot.com/ifm-docs/index.html
10738
10739 · LEPL: http://www.acooke.org/lepl/
10740
10741 · Mayavi:
10742 http://code.enthought.com/projects/mayavi/docs/development/html/mayavi
10743
10744 · NOC: http://redmine.nocproject.org/projects/noc
10745
10746 · NumPy: http://docs.scipy.org/doc/numpy/reference/
10747
10748 · Peach^3: http://peach3.nl/doc/latest/userdoc/
10749
10750 · PyLit: http://pylit.berlios.de/
10751
10752 · Sage: http://sagemath.org/doc/
10753
10754 · SciPy: http://docs.scipy.org/doc/scipy/reference/
10755
10756 · simuPOP:
10757 http://simupop.sourceforge.net/manual_release/build/userGuide.html
10758
10759 · Sprox: http://sprox.org/
10760
10761 · TurboGears: http://turbogears.org/2.0/docs/
10762
10763 · Zentyal: http://doc.zentyal.org/
10764
10765 · Zope: http://docs.zope.org/zope2/index.html
10766
10767 · zc.async: http://packages.python.org/zc.async/1.5.0/
10768
10769 Documentation using the sphinxdoc theme
10770 · Fityk: http://fityk.nieto.pl/
10771
10772 · MapServer: http://mapserver.org/
10773
10774 · Matplotlib: http://matplotlib.sourceforge.net/
10775
10776 · Music21: http://mit.edu/music21/doc/html/contents.html
10777
10778 · MyHDL: http://www.myhdl.org/doc/0.6/
10779
10780 · NetworkX: http://networkx.lanl.gov/
10781
10782 · Pweave: http://mpastell.com/pweave/
10783
10784 · Pyre: http://docs.danse.us/pyre/sphinx/
10785
10786 · Pysparse: http://pysparse.sourceforge.net/
10787
10788 · PyTango:
10789 http://www.tango-controls.org/static/PyTango/latest/doc/html/index.html
10790
10791 · Reteisi: http://www.reteisi.org/contents.html
10792
10793 · Satchmo: http://www.satchmoproject.com/docs/dev/
10794
10795 · Sphinx: http://sphinx.pocoo.org/
10796
10797 · Sqlkit: http://sqlkit.argolinux.org/
10798
10799 · Tau:
10800 http://www.tango-controls.org/static/tau/latest/doc/html/index.html
10801
10802 · Total Open Station: http://tops.berlios.de/
10803
10804 · WebFaction: http://docs.webfaction.com/
10805
10806 Documentation using another builtin theme
10807 · C/C++ Development with Eclipse: http://eclipsebook.in/ (agogo)
10808
10809 · Distribute: http://packages.python.org/distribute/ (nature)
10810
10811 · Jinja: http://jinja.pocoo.org/ (scrolls)
10812
10813 · jsFiddle: http://doc.jsfiddle.net/ (nature)
10814
10815 · pip: http://pip.openplans.org/ (nature)
10816
10817 · Programmieren mit PyGTK und Glade (German):
10818 http://www.florian-diesch.de/doc/python-und-glade/online/ (agogo)
10819
10820 · Spring Python:
10821 http://springpython.webfactional.com/current/sphinx/index.html
10822 (nature)
10823
10824 · sqlparse:
10825 http://python-sqlparse.googlecode.com/svn/docs/api/index.html (agogo)
10826
10827 · Sylli: http://sylli.sourceforge.net/ (nature)
10828
10829 · libLAS: http://liblas.org/ (nature)
10830
10831 Documentation using a custom theme/integrated in a site
10832 · Blender: http://www.blender.org/documentation/250PythonDoc/
10833
10834 · Blinker: http://discorporate.us/projects/Blinker/docs/
10835
10836 · Classy: classy: http://classy.pocoo.org/
10837
10838 · Django: http://docs.djangoproject.com/
10839
10840 · e-cidadania: http://e-cidadania.readthedocs.org/en/latest/
10841
10842 · Flask: http://flask.pocoo.org/docs/
10843
10844 · Flask-OpenID: http://packages.python.org/Flask-OpenID/
10845
10846 · Gameduino: http://excamera.com/sphinx/gameduino/
10847
10848 · GeoServer: http://docs.geoserver.org/
10849
10850 · Glashammer: http://glashammer.org/
10851
10852 · MirrorBrain: http://mirrorbrain.org/docs/
10853
10854 · nose: http://somethingaboutorange.com/mrl/projects/nose/
10855
10856 · ObjectListView: http://objectlistview.sourceforge.net/python
10857
10858 · Open ERP: http://doc.openerp.com/
10859
10860 · OpenLayers: http://docs.openlayers.org/
10861
10862 · PyEphem: http://rhodesmill.org/pyephem/
10863
10864 · German Plone 4.0 user manual:
10865 http://www.hasecke.com/plone-benutzerhandbuch/4.0/
10866
10867 · Pylons: http://pylonshq.com/docs/en/0.9.7/
10868
10869 · PyMOTW: http://www.doughellmann.com/PyMOTW/
10870
10871 · pypol: http://pypol.altervista.org/ (celery)
10872
10873 · qooxdoo: http://manual.qooxdoo.org/current
10874
10875 · Roundup: http://www.roundup-tracker.org/
10876
10877 · Selenium: http://seleniumhq.org/docs/
10878
10879 · Self: http://selflanguage.org/
10880
10881 · Tablib: http://tablib.org/
10882
10883 · SQLAlchemy: http://www.sqlalchemy.org/docs/
10884
10885 · tinyTiM: http://tinytim.sourceforge.net/docs/2.0/
10886
10887 · tipfy: http://www.tipfy.org/docs/
10888
10889 · Werkzeug: http://werkzeug.pocoo.org/docs/
10890
10891 · WFront: http://discorporate.us/projects/WFront/
10892
10893 Homepages and other non-documentation sites
10894 · Applied Mathematics at the Stellenbosch University:
10895 http://dip.sun.ac.za/
10896
10897 · A personal page: http://www.dehlia.in/
10898
10899 · Benoit Boissinot: http://bboissin.appspot.com/
10900
10901 · lunarsite: http://lunaryorn.de/
10902
10903 · Red Hot Chili Python: http://redhotchilipython.com/
10904
10905 · The Wine Cellar Book: http://www.thewinecellarbook.com/doc/en/
10906
10907 · VOR: http://www.vor-cycling.be/
10908
10909 Books produced using Sphinx
10910 · "The repoze.bfg Web Application Framework":
10911 http://www.amazon.com/repoze-bfg-Web-Application-Framework-Version/dp/0615345379
10912
10913 · A Theoretical Physics Reference book: http://theoretical-physics.net/
10914
10915 · "Simple and Steady Way of Learning for Software Engineering" (in Ja‐
10916 panese): http://www.amazon.co.jp/dp/477414259X/
10917
10918 · "Expert Python Programming" (Japanese translation):
10919 http://www.amazon.co.jp/dp/4048686291/
10920
10921 · "Pomodoro Technique Illustrated" (Japanese translation):
10922 http://www.amazon.co.jp/dp/4048689525/
10923
10924 · genindex
10925
10926 · modindex
10927
10928 · search
10929
10930 · glossary
10931
10933 Georg Brandl
10934
10936 2007-2011, Georg Brandl
10937
10938
10939
10940
109411.1.3 November 05, 2016 SPHINX-ALL(1)