1 | .. $Id: howto-configure.rst 1028 2012-07-16 06:06:58Z 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: |
---|
31 | |
---|
32 | .. figure:: in-source.png |
---|
33 | :alt: example directory of an in-source configuration |
---|
34 | |
---|
35 | Example directory of an in-source configuration |
---|
36 | |
---|
37 | .. index:: ! out-of-source configuration |
---|
38 | |
---|
39 | Out-of-source configuration |
---|
40 | --------------------------------- |
---|
41 | |
---|
42 | An *out-of-source* configuration is where the Sphinx ``.rst`` |
---|
43 | files are in **a separate directory** from the SPEC macro files. |
---|
44 | |
---|
45 | Here is a graphical example: [#]_ |
---|
46 | |
---|
47 | .. figure:: out-of-source1.png |
---|
48 | :alt: example build directory of an out-of-source configuration |
---|
49 | |
---|
50 | Example build directory of an out-of-source configuration |
---|
51 | |
---|
52 | The source files are located in the *source* directory (child of the build directory): |
---|
53 | |
---|
54 | .. figure:: out-of-source2.png |
---|
55 | :alt: example *source* directory of an out-of-source configuration |
---|
56 | |
---|
57 | Example *source* directory of an out-of-source configuration |
---|
58 | |
---|
59 | |
---|
60 | .. caution:: FIXME: these are Python files and project directories. |
---|
61 | The figure *should* be shown with SPEC macro files out-of-source. |
---|
62 | |
---|
63 | |
---|
64 | |
---|
65 | Create the Sphinx documentation tree |
---|
66 | ===================================== |
---|
67 | |
---|
68 | .. sidebar:: Testing the installation |
---|
69 | |
---|
70 | These instructions are written to help you test |
---|
71 | if you have installed *specdomain* correctly. |
---|
72 | They use an *in-source* configuration. |
---|
73 | |
---|
74 | Make a new sandbox directory to try this out:: |
---|
75 | |
---|
76 | mkdir /tmp/sandbox |
---|
77 | cd /tmp/sandbox |
---|
78 | |
---|
79 | .. index:: sphinx-quickstart |
---|
80 | |
---|
81 | Create a Sphinx configuration in this directory by running:: |
---|
82 | |
---|
83 | sphinx-quickstart |
---|
84 | |
---|
85 | Here's the full session: |
---|
86 | |
---|
87 | .. code-block:: text |
---|
88 | :linenos: |
---|
89 | |
---|
90 | jemian@como-ubuntu64:/tmp/sandbox$ sphinx-quickstart |
---|
91 | Welcome to the Sphinx 1.1.2 quickstart utility. |
---|
92 | |
---|
93 | Please enter values for the following settings (just press Enter to |
---|
94 | accept a default value, if one is given in brackets). |
---|
95 | |
---|
96 | Enter the root path for documentation. |
---|
97 | > Root path for the documentation [.]: |
---|
98 | |
---|
99 | You have two options for placing the build directory for Sphinx output. |
---|
100 | Either, you use a directory "_build" within the root path, or you separate |
---|
101 | "source" and "build" directories within the root path. |
---|
102 | > Separate source and build directories (y/N) [n]: |
---|
103 | |
---|
104 | Inside the root directory, two more directories will be created; "_templates" |
---|
105 | for custom HTML templates and "_static" for custom stylesheets and other static |
---|
106 | files. You can enter another prefix (such as ".") to replace the underscore. |
---|
107 | > Name prefix for templates and static dir [_]: |
---|
108 | |
---|
109 | The project name will occur in several places in the built documentation. |
---|
110 | > Project name: sandbox |
---|
111 | > Author name(s): sandy |
---|
112 | |
---|
113 | Sphinx has the notion of a "version" and a "release" for the |
---|
114 | software. Each version can have multiple releases. For example, for |
---|
115 | Python the version is something like 2.5 or 3.0, while the release is |
---|
116 | something like 2.5.1 or 3.0a1. If you don't need this dual structure, |
---|
117 | just set both to the same value. |
---|
118 | > Project version: test |
---|
119 | > Project release [test]: |
---|
120 | |
---|
121 | The file name suffix for source files. Commonly, this is either ".txt" |
---|
122 | or ".rst". Only files with this suffix are considered documents. |
---|
123 | > Source file suffix [.rst]: |
---|
124 | |
---|
125 | One document is special in that it is considered the top node of the |
---|
126 | "contents tree", that is, it is the root of the hierarchical structure |
---|
127 | of the documents. Normally, this is "index", but if your "index" |
---|
128 | document is a custom template, you can also set this to another filename. |
---|
129 | > Name of your master document (without suffix) [index]: |
---|
130 | |
---|
131 | Sphinx can also add configuration for epub output: |
---|
132 | > Do you want to use the epub builder (y/N) [n]: |
---|
133 | |
---|
134 | Please indicate if you want to use one of the following Sphinx extensions: |
---|
135 | > autodoc: automatically insert docstrings from modules (y/N) [n]: y |
---|
136 | > doctest: automatically test code snippets in doctest blocks (y/N) [n]: |
---|
137 | > intersphinx: link between Sphinx documentation of different projects (y/N) [n]: |
---|
138 | > todo: write "todo" entries that can be shown or hidden on build (y/N) [n]: |
---|
139 | > coverage: checks for documentation coverage (y/N) [n]: |
---|
140 | > pngmath: include math, rendered as PNG images (y/N) [n]: |
---|
141 | > mathjax: include math, rendered in the browser by MathJax (y/N) [n]: |
---|
142 | > ifconfig: conditional inclusion of content based on config values (y/N) [n]: |
---|
143 | > viewcode: include links to the source code of documented Python objects (y/N) [n]: y |
---|
144 | |
---|
145 | A Makefile and a Windows command file can be generated for you so that you |
---|
146 | only have to run e.g. `make html' instead of invoking sphinx-build |
---|
147 | directly. |
---|
148 | > Create Makefile? (Y/n) [y]: |
---|
149 | > Create Windows command file? (Y/n) [y]: |
---|
150 | |
---|
151 | Creating file ./conf.py. |
---|
152 | Creating file ./index.rst. |
---|
153 | Creating file ./Makefile. |
---|
154 | Creating file ./make.bat. |
---|
155 | |
---|
156 | Finished: An initial directory structure has been created. |
---|
157 | |
---|
158 | You should now populate your master file ./index.rst and create other documentation |
---|
159 | source files. Use the Makefile to build the docs, like so: |
---|
160 | make builder |
---|
161 | where "builder" is one of the supported builders, e.g. html, latex or linkcheck. |
---|
162 | |
---|
163 | jemian@como-ubuntu64:/tmp/sandbox$ |
---|
164 | |
---|
165 | In case you missed them, these are the non-default answers supplied: |
---|
166 | |
---|
167 | ========================================================================================= =============== |
---|
168 | prompt response |
---|
169 | ========================================================================================= =============== |
---|
170 | ``> Project name:`` *sandbox* |
---|
171 | ``> Author name(s):`` *sandy* |
---|
172 | ``> Project version:`` *test* |
---|
173 | ``> autodoc: automatically insert docstrings from modules (y/N) [n]:`` *y* |
---|
174 | ``> viewcode: include links to the source code of documented Python objects (y/N) [n]:`` *y* |
---|
175 | ========================================================================================= =============== |
---|
176 | |
---|
177 | |
---|
178 | Configure: Changes to ``conf.py`` |
---|
179 | ===================================== |
---|
180 | |
---|
181 | Edit the new file *conf.py* and add these two lines to the extensions list after line 28:: |
---|
182 | |
---|
183 | # this says ${PYTHONPATH)/sphinxcontrib/specdomain.py must be found |
---|
184 | extensions.append('sphinxcontrib.specdomain') |
---|
185 | |
---|
186 | If you wish, you can also change the *html_theme* from the |
---|
187 | *default* to *sphinxdoc* or *agogo* or one of the others. |
---|
188 | Check the Sphinx documentation for the choices. To change |
---|
189 | the theme, look on line 97 (or thereabouts) and change:: |
---|
190 | |
---|
191 | html_theme = 'default' |
---|
192 | |
---|
193 | to:: |
---|
194 | |
---|
195 | html_theme = 'sphinxdoc' |
---|
196 | |
---|
197 | |
---|
198 | ---------------------------------- |
---|
199 | |
---|
200 | .. rubric:: Footnotes |
---|
201 | |
---|
202 | .. [#] The green check boxes correspond to the status of each item in the version control system. |
---|