1 =============================
2 SCons Documentation Toolchain
3 =============================
9 This text tries to give an overview of the current SCons documentation
10 toolchain. As a prospective doc editor, you should be able to quickly
11 understand the basic concepts (if not, please let the project know how
12 it falls short). It is also a reference for core developers and the
15 .. image:: images/overview.png
17 The diagram above roughly shows the steps that we currently need for
18 creating all the MAN pages, User manuals and reference documents. You
19 may think: "Geeez, that looks so complicated. Why can't they simply
20 convert XML files to PDF with Docbook, or use reST?" Please be patient,
21 and continue reading. Things will get a little clearer soon.
23 Our toolchain doesn't only produce HTML and PDF files that are nice
24 to look at, it also performs a lot of processing under the covers. We
25 try to have our documentation as consistent as possible to the current
26 behaviour of the source code, but this requires some extra steps.
28 So let's start right at the top...
33 SCons documentation is written in Docbook (the xml variant).
34 The toolchain is set up so that a writer has a restricted view of the
35 whole "document processing thingy". All you should need to be concerned
36 with is to edit existing text or write new sections and paragraphs.
37 Sometimes even a completely new chapter has to be added. The hope
38 is that you can fire up your XML editor of choice and type away.
40 XML is easy to get wrong, so you need to case about
41 validating the XML files
42 against our special "SCons Docbook DTD/XSD". You can run the
47 python bin/docs-validate.py
50 from the top source folder to validate. If you are able to use
51 an XML editor, many of the potential problems are avoided -
52 the most common error is not matching tag opening and closing
53 (for example ``<tag>foo<tag>`` is an easy typing error to make,
54 as is starting a ``<para>``, typing text, and not adding the
55 closing ``</para>``). XML editors make it much harder to make
56 those errors, which minor though they seem, will completely
57 break the document build.
59 Everything's looking okay, all validation passed? Good, then simply
60 commits your new work, and create a pull request on Github. That's it!
62 Additionally, you can create the single documents locally if you want
63 to get a feel for how the final result looks (and who doesn't?). Each of
64 the document folders (``design``, ``developer``, ``man``, ``python10``,
65 ``reference``, and ``user``) contains an ``SConstruct`` file along with
66 the actual XML files. You can call
70 python ../../scripts/scons.py
72 from within the directory, and have the MAN pages or HTML created...even
73 PDF, if you have a renderer installed (``fop``, ``xep`` or ``jw``).
78 Just a few more words about the validation step. We are using our
79 own DTD/XSD as a kind of hook, which only exists to link our own SCons
80 documentation tags into the normal Docbook XSD. For the output, we always
81 have an intermediary step (see diagram above), where we rewrite tags like
82 ``cvar`` into a block of Docbook formatting elements representing it.
84 The toolchain, and all the Python scripts supporting it, are based
85 on the prerequisite that all documents are valid against the SCons
86 Docbook XSD. This step guarantees that we can accept the pull request
87 of a user/writer with all his changes, and can create the documentation
88 for a new release of SCons without any problems at a later time.
94 We are using entities for special keywords like ``SCons`` that should
95 appear with the same formatting throughout the text. This allows a
96 single place to make styling changes if needed. These are kept in
97 a single file ``doc/scons.mod`` which gets included by the documents,
98 and can be used anywhere in the documentation files.
100 Additionally, for the definitions of the four special types available
101 in the SCons doctype - Tool, Builder, Construction Variable and Function -
102 a bunch of reference links in the form of entities are generated.
103 These entities can be used in the MAN page and the User manual.
104 Note that the four type tags themselves (``<tool>``, ``<builder>``,
105 ``<cvar>`` and ``<function>``) can only be used in documentation
106 sources in the ``SCons`` directory; the build will not scan for these
107 in the ``doc`` directory.
109 When you add an XML file in the ``SCons/Tools`` folder, e.g. for
110 a tool named ``foobar``, you can use the two entities
113 which prints the name of the Tool, and
116 which is a link to the description of the Tool
118 The link will be to the appropriate Appendix in the User Guide,
119 or to the proper section in the manpage.
121 In the case of Functions, there may be pairs of these, depending
122 on the value of the signature attribute: this attribute tells
123 whether only the global function form, or only the environment
124 method form, or both, exist. If all four exist you will get:
127 which prints the name of the global Function
130 which prints the name of the environment method
133 which is a link to the description of the global Function
136 which is a link to the description of the environment method
139 By calling the script
143 python bin/docs-update-generated.py
145 you can recreate the lists of entities (``*.mod``) in the ``generated``
146 folder. At the same time, this will generate the matching ``*.gen``
147 files, which list the full description of all the Builders, Tools,
148 Functions and CVars for the MAN page and the User Guide's appendix.
149 Thus, you want to regenerate when there's a change to
150 any of those four special elements, or an added or deleted element.
151 These generated files are left checked in so in the normal case you
152 can just rebuild the docs without having to first generate the entity
155 For more information about how to properly describe these elements,
156 refer to the start of the Python script ``bin/SConsDoc.py``. It explains
157 the available tags and the exact syntax in detail.
163 Normal Docbook (v4.5 style, as of this writing) in-document linking
164 is supported, as is linking to documents with a web address.
165 For any element in a document, you can include an ``id=name``
166 attribute to set an identifier, and write a link to that identifier.
167 Many of the section headings already have such identifiers,
168 and it is fine to add more, as long as they remain unique.
169 As noted in the previous section, for the special types,
170 entities are generated which contain links,
171 so you can just use those entities instead
172 of writing the link reference manually.
174 There is something to keep in mind about linking, however.
175 Cross-document links between the MAN page and the User Guide
176 do not work. But some text is shared between the two, which
177 allows the appearance of such linking, and this is where it
178 gets a little confusing. The text defined by the four special
179 types is generated into the ``*.gen`` files,
180 which get included both in the appropriate places in the MAN page,
181 and in the Appendix in the User Guide. Using entities within
182 this shared content is fine. Writing links in this shared
183 content to element identifiers defined elsewhere is not.
185 That sounds a little confusing so here is a real example:
186 an xml source file in ``SCons`` defines the ``SCANNERS``
187 construction variable by using ``<cvar name="SCANNERS"> ... </cvar>``.
188 This will generate the linking entity ``&cv-link-SCANNERS;``,
189 which can be used anywhere the ``doc/generated/variables.gen``
190 file is included (i.e. MAN page and User Guide for now)
191 to leave a link to this definition.
192 But the text written inside the ``SCANNERS`` definition
193 also wants to refer to the "Builder Objects" and "Scanner
194 Objects" sections in the MAN page, as this contains relevant
195 further description. This reference should not include an
196 XML link, even though the MAN page defines the two identifiers
197 ``scanner_objects`` and ``builder_objects``, because this
198 definition will *also* be included in the User Guide, which
199 has no such section names or identifiers. It is better here
200 to write it all in text, as in *See the manpage section
201 "Builder Objects"* than to leave a dangling reference in one
207 In the User Guide, we support automatically created examples. This
208 means that the output of the specified source files and SConstructs
209 is generated by running them with the current SCons version. We do this
210 to ensure that the output displayed in the manual is identical to what
211 you get when you run the example on the command-line, without having
212 to remember to manually update the example outputs all the time.
214 A short description about how these examples have to be defined can be
215 found at the start of the file ``bin/SConsExamples.py``. Call
219 python bin/docs-create-example-outputs.py
221 from the top level source folder, to run all examples through SCons.
223 Before this script starts to generate any output, it checks whether the
224 names of all defined examples are unique. Another important prerequisite
225 is that for every example all the single ``scons_output`` blocks need
226 to have a ``suffix`` attribute defined. These suffixes also have to be
227 unique, within each example.
229 All example output files (``*.xml``) get written to the folder
230 ``doc/generated/examples``, together with all files defined via the
231 ``scons_example_file`` tag. They are put under version control, in
232 part so that the version control system can show any unexpected
233 changes in the outputs after editing the docs:
236 git diff doc/generated/examples
238 Note that these output files are not actually needed for editing the
239 documents. When loading the User manual into an XML editor, you will
240 always see the example's definition. Only when you create some output,
241 the files from ``doc/generated/examples`` get XIncluded and all special
242 ``scons*`` tags are transformed into Docbook elements.
248 Documents are in the folders ``design``, ``developer``, ``man``,
249 ``python10``, ``reference``, and ``user``. Note that of these,
250 only ``man`` and ``user`` are actively maintained and some of
251 the others are vastly out of date. If submitting a github
252 Pull Request for a new SCons feature, you will only be required
253 to update the documentation that goes into the manpage and the
257 Prepared configuration sets for the validating WYSIWYG XML editors
258 XmlMind and Serna. You'll probably want to try the latter, because
259 the XXE config requires you to have a full version (costing a few
260 hundred bucks) and is therefore untested. For installing the Serna
261 config, simply copy the ``scons`` folder into the ``plugins``
262 directory of your installation. Likewise, the XXE files from the
263 ``xmlmind`` folder have to be copied into ``~/.xxe4/`` under Linux.
266 Entity lists and outputs of the UserGuide examples. They get generated
267 by the update scripts ``bin/docs-update-generated.py``
268 and ``bin/docs-create-example-outputs.py``.
271 Images for the ``overview.rst`` document.
274 The SCons Docbook schema (XSD), based on the Docbook v4.5 DTD/XSD.
277 XSLT transformation scripts for converting the special SCons
278 tags like ``scons_output`` to valid Docbook during document