1 | .. $Id: howto-configure.rst 1022 2012-07-16 01:24:17Z jemian $ |
---|
2 | |
---|
3 | ==================================================================== |
---|
4 | How to Create and Configure a Sphinx project to Document SPEC Macros |
---|
5 | ==================================================================== |
---|
6 | |
---|
7 | .. tip:: for more information on this topic, refer to the SPhinx tutorial: |
---|
8 | http://sphinx.pocoo.org/tutorial.html |
---|
9 | |
---|
10 | Decide which configuration |
---|
11 | ================================= |
---|
12 | |
---|
13 | **In-source** configuration or |
---|
14 | **Out-of-source** configuration? |
---|
15 | |
---|
16 | .. tip:: Most likely, you will want to keep the Sphinx documentation |
---|
17 | files in a separate directory from the SPEC macros. |
---|
18 | Then again, maybe not. |
---|
19 | |
---|
20 | |
---|
21 | .. index:: ! in-source configuration |
---|
22 | .. _in-source configuration: |
---|
23 | |
---|
24 | In-source configuration |
---|
25 | --------------------------------- |
---|
26 | |
---|
27 | An *in-source* configuration is where the Sphinx ``.rst`` |
---|
28 | files are in **the same directory** as the SPEC macro files. |
---|
29 | |
---|
30 | Here is a graphical example: --tba-- |
---|
31 | |
---|
32 | .. index:: ! out-of-source configuration |
---|
33 | |
---|
34 | Out-of-source configuration |
---|
35 | --------------------------------- |
---|
36 | |
---|
37 | An *out-of-source* configuration is where the Sphinx ``.rst`` |
---|
38 | files are in **a separate directory** from the SPEC macro files. |
---|
39 | |
---|
40 | Here is a graphical example: --tba-- |
---|
41 | |
---|
42 | Create the Sphinx documentation tree |
---|
43 | ===================================== |
---|
44 | |
---|
45 | .. sidebar:: Testing the installation |
---|
46 | |
---|
47 | These instructions are written to help you test |
---|
48 | if you have installed *specdomain* correctly. |
---|
49 | They use an *in-source* configuration. |
---|
50 | |
---|
51 | Make a new sandbox directory to try this out:: |
---|
52 | |
---|
53 | mkdir /tmp/sandbox |
---|
54 | cd /tmp/sandbox |
---|
55 | |
---|
56 | Create a Sphinx configuration in this directory by running ``sphinx-quickstart``: |
---|
57 | |
---|
58 | .. code-block:: text |
---|
59 | :linenos: |
---|
60 | |
---|
61 | jemian@como-ubuntu64:/tmp/sandbox$ sphinx-quickstart |
---|
62 | Welcome to the Sphinx 1.1.2 quickstart utility. |
---|
63 | |
---|
64 | Please enter values for the following settings (just press Enter to |
---|
65 | accept a default value, if one is given in brackets). |
---|
66 | |
---|
67 | Enter the root path for documentation. |
---|
68 | > Root path for the documentation [.]: |
---|
69 | |
---|
70 | You have two options for placing the build directory for Sphinx output. |
---|
71 | Either, you use a directory "_build" within the root path, or you separate |
---|
72 | "source" and "build" directories within the root path. |
---|
73 | > Separate source and build directories (y/N) [n]: |
---|
74 | |
---|
75 | Inside the root directory, two more directories will be created; "_templates" |
---|
76 | for custom HTML templates and "_static" for custom stylesheets and other static |
---|
77 | files. You can enter another prefix (such as ".") to replace the underscore. |
---|
78 | > Name prefix for templates and static dir [_]: |
---|
79 | |
---|
80 | The project name will occur in several places in the built documentation. |
---|
81 | > Project name: sandbox |
---|
82 | > Author name(s): sandy |
---|
83 | |
---|
84 | Sphinx has the notion of a "version" and a "release" for the |
---|
85 | software. Each version can have multiple releases. For example, for |
---|
86 | Python the version is something like 2.5 or 3.0, while the release is |
---|
87 | something like 2.5.1 or 3.0a1. If you don't need this dual structure, |
---|
88 | just set both to the same value. |
---|
89 | > Project version: test |
---|
90 | > Project release [test]: |
---|
91 | |
---|
92 | The file name suffix for source files. Commonly, this is either ".txt" |
---|
93 | or ".rst". Only files with this suffix are considered documents. |
---|
94 | > Source file suffix [.rst]: |
---|
95 | |
---|
96 | One document is special in that it is considered the top node of the |
---|
97 | "contents tree", that is, it is the root of the hierarchical structure |
---|
98 | of the documents. Normally, this is "index", but if your "index" |
---|
99 | document is a custom template, you can also set this to another filename. |
---|
100 | > Name of your master document (without suffix) [index]: |
---|
101 | |
---|
102 | Sphinx can also add configuration for epub output: |
---|
103 | > Do you want to use the epub builder (y/N) [n]: |
---|
104 | |
---|
105 | Please indicate if you want to use one of the following Sphinx extensions: |
---|
106 | > autodoc: automatically insert docstrings from modules (y/N) [n]: y |
---|
107 | > doctest: automatically test code snippets in doctest blocks (y/N) [n]: |
---|
108 | > intersphinx: link between Sphinx documentation of different projects (y/N) [n]: |
---|
109 | > todo: write "todo" entries that can be shown or hidden on build (y/N) [n]: |
---|
110 | > coverage: checks for documentation coverage (y/N) [n]: |
---|
111 | > pngmath: include math, rendered as PNG images (y/N) [n]: |
---|
112 | > mathjax: include math, rendered in the browser by MathJax (y/N) [n]: |
---|
113 | > ifconfig: conditional inclusion of content based on config values (y/N) [n]: |
---|
114 | > viewcode: include links to the source code of documented Python objects (y/N) [n]: y |
---|
115 | |
---|
116 | A Makefile and a Windows command file can be generated for you so that you |
---|
117 | only have to run e.g. `make html' instead of invoking sphinx-build |
---|
118 | directly. |
---|
119 | > Create Makefile? (Y/n) [y]: |
---|
120 | > Create Windows command file? (Y/n) [y]: |
---|
121 | |
---|
122 | Creating file ./conf.py. |
---|
123 | Creating file ./index.rst. |
---|
124 | Creating file ./Makefile. |
---|
125 | Creating file ./make.bat. |
---|
126 | |
---|
127 | Finished: An initial directory structure has been created. |
---|
128 | |
---|
129 | You should now populate your master file ./index.rst and create other documentation |
---|
130 | source files. Use the Makefile to build the docs, like so: |
---|
131 | make builder |
---|
132 | where "builder" is one of the supported builders, e.g. html, latex or linkcheck. |
---|
133 | |
---|
134 | jemian@como-ubuntu64:/tmp/sandbox$ |
---|
135 | |
---|
136 | |
---|
137 | Configure: Changes to ``conf.py`` |
---|
138 | ===================================== |
---|
139 | |
---|
140 | Edit the new file *conf.py* and add these two lines to the extensions list after line 28:: |
---|
141 | |
---|
142 | # this says ${PYTHONPATH)/sphinxcontrib/specdomain.py must be found |
---|
143 | extensions.append('sphinxcontrib.specdomain') |
---|
144 | |
---|
145 | If you wish, you can also change the *html_theme* from the |
---|
146 | *default* to *sphinxdoc* or *agogo* or one of the others. |
---|
147 | Check the Sphinx documentation for the choices. To change |
---|
148 | the theme, look on line 97 (or thereabouts) and change:: |
---|
149 | |
---|
150 | html_theme = 'default' |
---|
151 | |
---|
152 | to:: |
---|
153 | |
---|
154 | html_theme = 'sphinxdoc' |
---|