···11+<chapter xmlns="http://docbook.org/ns/docbook"
22+ xmlns:xlink="http://www.w3.org/1999/xlink"
33+ xmlns:xi="http://www.w3.org/2001/XInclude"
44+ version="5.0"
55+ xml:id="sec-writing-documentation">
66+77+<title>Writing NixOS Documentation</title>
88+99+<para>
1010+ As NixOS grows, so too does the need for a catalogue and explanation
1111+ of its extensive functionality. Collecting pertinent information
1212+ from disparate sources and presenting it in an accessible style
1313+ would be a worthy contribution to the project.
1414+</para>
1515+1616+<section>
1717+<title>Building the Manual</title>
1818+<para>
1919+ The DocBook sources of the <xref linkend="book-nixos-manual"/> are in the
2020+ <link xlink:href="https://github.com/NixOS/nixpkgs/tree/master/nixos/doc/manual"><filename>nixos/doc/manual</filename></link>
2121+ subdirectory of the Nixpkgs repository. If you make modifications to
2222+ the manual, it's important to build it before committing. You can do
2323+ that as follows:
2424+2525+ <screen>nix-build nixos/release.nix -A manual.x86_64-linux</screen>
2626+</para>
2727+2828+<para>
2929+ When this command successfully finishes, it will tell you where the
3030+ manual got generated. The HTML will be accessible through the
3131+ <filename>result</filename> symlink at
3232+ <filename>./result/share/doc/nixos/index.html</filename>.
3333+</para>
3434+</section>
3535+3636+<section>
3737+<title>Editing DocBook XML</title>
3838+3939+<para>
4040+ For general information on how to write in DocBook, see
4141+ <link xlink:href="http://www.docbook.org/tdg5/en/html/docbook.html">
4242+ DocBook 5: The Definitive Guide</link>.
4343+</para>
4444+4545+<para>
4646+ Emacs nXML Mode is very helpful for editing DocBook XML because it
4747+ validates the document as you write, and precisely locates
4848+ errors. To use it, see <xref linkend="sec-emacs-docbook-xml"/>.
4949+</para>
5050+5151+<para>
5252+ <link xlink:href="http://pandoc.org">Pandoc</link> can generate
5353+ DocBook XML from a multitude of formats, which makes a good starting
5454+ point.
5555+5656+ <example xml:id="ex-pandoc-xml-conv">
5757+ <title>Pandoc invocation to convert GitHub-Flavoured MarkDown to DocBook 5 XML</title>
5858+ <screen>pandoc -f markdown_github -t docbook5 docs.md -o my-section.md</screen>
5959+ </example>
6060+6161+ Pandoc can also quickly convert a single
6262+ <filename>section.xml</filename> to HTML, which is helpful when
6363+ drafting.
6464+</para>
6565+6666+<para>
6767+ Sometimes writing valid DocBook is simply too difficult. In this
6868+ case, submit your documentation updates in a <link
6969+ xlink:href="https://github.com/NixOS/nixpkgs/issues/new">GitHub
7070+ Issue</link> and someone will handle the conversion to XML for you.
7171+</para>
7272+</section>
7373+7474+<section>
7575+<title>Creating a Topic</title>
7676+7777+<para>
7878+ You can use an existing topic as a basis for the new topic or create a topic from scratch.
7979+</para>
8080+8181+<para>
8282+Keep the following guidelines in mind when you create and add a topic:
8383+8484+<itemizedlist>
8585+ <listitem><para>
8686+ The NixOS <link xlink:href="http://www.docbook.org/tdg5/en/html/book.html"><tag>book</tag></link>
8787+ element is in <filename>nixos/doc/manual/manual.xml</filename>.
8888+ It includes several
8989+ <link xlink:href="http://www.docbook.org/tdg5/en/html/book.html"><tag>part</tag>s</link>
9090+ which are in subdirectories.
9191+ </para></listitem>
9292+9393+ <listitem><para>
9494+ Store the topic file in the same directory as the <tag>part</tag>
9595+ to which it belongs. If your topic is about configuring a NixOS
9696+ module, then the XML file can be stored alongside the module
9797+ definition <filename>nix</filename> file.
9898+ </para></listitem>
9999+100100+ <listitem><para>
101101+ If you include multiple words in the file name, separate the words
102102+ with a dash. For example: <filename>ipv6-config.xml</filename>.
103103+ </para></listitem>
104104+105105+ <listitem><para>
106106+ Make sure that the <tag>xml:id</tag> value is unique. You can use
107107+ abbreviations if the ID is too long. For example:
108108+ <varname>nixos-config</varname>.
109109+ </para></listitem>
110110+111111+ <listitem><para>
112112+ Determine whether your topic is a chapter or a section. If you are
113113+ unsure, open an existing topic file and check whether the main
114114+ element is chapter or section.
115115+ </para></listitem>
116116+117117+</itemizedlist>
118118+119119+</para>
120120+</section>
121121+122122+<section>
123123+<title>Adding a Topic to the Book</title>
124124+125125+<para>
126126+ Open the parent XML file and add an <varname>xi:include</varname>
127127+ element to the list of chapters with the file name of the topic that
128128+ you created. If you created a <tag>section</tag>, you add the file to
129129+ the <tag>chapter</tag> file. If you created a <tag>chapter</tag>, you
130130+ add the file to the <tag>part</tag> file.
131131+</para>
132132+133133+<para>
134134+ If the topic is about configuring a NixOS module, it can be
135135+ automatically included in the manual by using the
136136+ <varname>meta.doc</varname> attribute. See <xref
137137+ linkend="sec-meta-attributes"/> for an explanation.
138138+</para>
139139+140140+</section>
141141+142142+143143+144144+145145+146146+147147+</chapter>