···
1
+
<chapter xmlns="http://docbook.org/ns/docbook"
2
+
xmlns:xlink="http://www.w3.org/1999/xlink"
3
+
xmlns:xi="http://www.w3.org/2001/XInclude"
5
+
xml:id="sec-writing-documentation">
7
+
<title>Writing NixOS Documentation</title>
10
+
As NixOS grows, so too does the need for a catalogue and explanation
11
+
of its extensive functionality. Collecting pertinent information
12
+
from disparate sources and presenting it in an accessible style
13
+
would be a worthy contribution to the project.
17
+
<title>Building the Manual</title>
19
+
The DocBook sources of the <xref linkend="book-nixos-manual"/> are in the
20
+
<link xlink:href="https://github.com/NixOS/nixpkgs/tree/master/nixos/doc/manual"><filename>nixos/doc/manual</filename></link>
21
+
subdirectory of the Nixpkgs repository. If you make modifications to
22
+
the manual, it's important to build it before committing. You can do
25
+
<screen>nix-build nixos/release.nix -A manual.x86_64-linux</screen>
29
+
When this command successfully finishes, it will tell you where the
30
+
manual got generated. The HTML will be accessible through the
31
+
<filename>result</filename> symlink at
32
+
<filename>./result/share/doc/nixos/index.html</filename>.
37
+
<title>Editing DocBook XML</title>
40
+
For general information on how to write in DocBook, see
41
+
<link xlink:href="http://www.docbook.org/tdg5/en/html/docbook.html">
42
+
DocBook 5: The Definitive Guide</link>.
46
+
Emacs nXML Mode is very helpful for editing DocBook XML because it
47
+
validates the document as you write, and precisely locates
48
+
errors. To use it, see <xref linkend="sec-emacs-docbook-xml"/>.
52
+
<link xlink:href="http://pandoc.org">Pandoc</link> can generate
53
+
DocBook XML from a multitude of formats, which makes a good starting
56
+
<example xml:id="ex-pandoc-xml-conv">
57
+
<title>Pandoc invocation to convert GitHub-Flavoured MarkDown to DocBook 5 XML</title>
58
+
<screen>pandoc -f markdown_github -t docbook5 docs.md -o my-section.md</screen>
61
+
Pandoc can also quickly convert a single
62
+
<filename>section.xml</filename> to HTML, which is helpful when
67
+
Sometimes writing valid DocBook is simply too difficult. In this
68
+
case, submit your documentation updates in a <link
69
+
xlink:href="https://github.com/NixOS/nixpkgs/issues/new">GitHub
70
+
Issue</link> and someone will handle the conversion to XML for you.
75
+
<title>Creating a Topic</title>
78
+
You can use an existing topic as a basis for the new topic or create a topic from scratch.
82
+
Keep the following guidelines in mind when you create and add a topic:
86
+
The NixOS <link xlink:href="http://www.docbook.org/tdg5/en/html/book.html"><tag>book</tag></link>
87
+
element is in <filename>nixos/doc/manual/manual.xml</filename>.
89
+
<link xlink:href="http://www.docbook.org/tdg5/en/html/book.html"><tag>part</tag>s</link>
90
+
which are in subdirectories.
94
+
Store the topic file in the same directory as the <tag>part</tag>
95
+
to which it belongs. If your topic is about configuring a NixOS
96
+
module, then the XML file can be stored alongside the module
97
+
definition <filename>nix</filename> file.
101
+
If you include multiple words in the file name, separate the words
102
+
with a dash. For example: <filename>ipv6-config.xml</filename>.
106
+
Make sure that the <tag>xml:id</tag> value is unique. You can use
107
+
abbreviations if the ID is too long. For example:
108
+
<varname>nixos-config</varname>.
112
+
Determine whether your topic is a chapter or a section. If you are
113
+
unsure, open an existing topic file and check whether the main
114
+
element is chapter or section.
123
+
<title>Adding a Topic to the Book</title>
126
+
Open the parent XML file and add an <varname>xi:include</varname>
127
+
element to the list of chapters with the file name of the topic that
128
+
you created. If you created a <tag>section</tag>, you add the file to
129
+
the <tag>chapter</tag> file. If you created a <tag>chapter</tag>, you
130
+
add the file to the <tag>part</tag> file.
134
+
If the topic is about configuring a NixOS module, it can be
135
+
automatically included in the manual by using the
136
+
<varname>meta.doc</varname> attribute. See <xref
137
+
linkend="sec-meta-attributes"/> for an explanation.