git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #17622 from rvl/nixos-manual-writing-documentation

Add documentation about writing NixOS documentation

commitda5c0220aa42e8bde1664463d8b1d2bebc861714 authorJörg Thalheim <joerg@higgsboson.tk> dateSun 9 Oct 2016, 13:39 (10 years ago) parenta3ec0f14908d7b
3 files changed+201−3
nixos/doc/manual/development/development.xml+1 nixos/doc/manual/development/writing-documentation.xml+147 nixos/modules/services/editors/emacs.xml+53−3
nixos/doc/manual/development/development.xml+1
@@ -14,6 +14,7 @@ NixOS.</para>
1414<xi:include href="sources.xml" />
1515<xi:include href="writing-modules.xml" />
1616<xi:include href="building-parts.xml" />
17+<xi:include href="writing-documentation.xml" />
1718<xi:include href="building-nixos.xml" />
1819<xi:include href="nixos-tests.xml" />
1920<xi:include href="testing-installer.xml" />
nixos/doc/manual/development/writing-documentation.xmlnew file+147
@@ -0,0 +1,147 @@
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"
4+ version="5.0"
5+ xml:id="sec-writing-documentation">
6+
7+<title>Writing NixOS Documentation</title>
8+
9+<para>
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.
14+</para>
15+
16+<section>
17+<title>Building the Manual</title>
18+<para>
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
23+ that as follows:
24+
25+ <screen>nix-build nixos/release.nix -A manual.x86_64-linux</screen>
26+</para>
27+
28+<para>
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>.
33+</para>
34+</section>
35+
36+<section>
37+<title>Editing DocBook XML</title>
38+
39+<para>
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>.
43+</para>
44+
45+<para>
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"/>.
49+</para>
50+
51+<para>
52+ <link xlink:href="http://pandoc.org">Pandoc</link> can generate
53+ DocBook XML from a multitude of formats, which makes a good starting
54+ point.
55+
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>
59+ </example>
60+
61+ Pandoc can also quickly convert a single
62+ <filename>section.xml</filename> to HTML, which is helpful when
63+ drafting.
64+</para>
65+
66+<para>
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.
71+</para>
72+</section>
73+
74+<section>
75+<title>Creating a Topic</title>
76+
77+<para>
78+ You can use an existing topic as a basis for the new topic or create a topic from scratch.
79+</para>
80+
81+<para>
82+Keep the following guidelines in mind when you create and add a topic:
83+
84+<itemizedlist>
85+ <listitem><para>
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>.
88+ It includes several
89+ <link xlink:href="http://www.docbook.org/tdg5/en/html/book.html"><tag>part</tag>s</link>
90+ which are in subdirectories.
91+ </para></listitem>
92+
93+ <listitem><para>
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.
98+ </para></listitem>
99+
100+ <listitem><para>
101+ If you include multiple words in the file name, separate the words
102+ with a dash. For example: <filename>ipv6-config.xml</filename>.
103+ </para></listitem>
104+
105+ <listitem><para>
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>.
109+ </para></listitem>
110+
111+ <listitem><para>
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.
115+ </para></listitem>
116+
117+</itemizedlist>
118+
119+</para>
120+</section>
121+
122+<section>
123+<title>Adding a Topic to the Book</title>
124+
125+<para>
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.
131+</para>
132+
133+<para>
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.
138+</para>
139+
140+</section>
141+
142+
143+
144+
145+
146+
147+</chapter>
nixos/modules/services/editors/emacs.xml+53−3
@@ -43,9 +43,10 @@
4343 <title>Installing <application>Emacs</application></title>
4444
4545 <para>
46− Emacs can installed in the normal way for Nix (see <xref
47− linkend="sec-package-management" />). In addition, a NixOS
48− <emphasis>service</emphasis> can be enabled.
46+ Emacs can be installed in the normal way for Nix (see
47+ <xref linkend="sec-package-management" />).
48+ In addition, a NixOS <emphasis>service</emphasis>
49+ can be enabled.
4950 </para>
5051
5152 <section>
@@ -564,6 +565,55 @@ services.emacs.install = true;
564565 &lt;RET&gt; nixos-rebuild &lt;RET&gt;.</literal>
565566 </para>
566567 </section>
568+
569+ <section xml:id="sec-emacs-docbook-xml">
570+ <title>Editing DocBook 5 XML Documents</title>
571+ <para>
572+ Emacs includes <link
573+ xlink:href="https://www.gnu.org/software/emacs/manual/html_node/nxml-mode/Introduction.html">nXML</link>,
574+ a major-mode for validating and editing XML documents.
575+ When editing DocBook 5.0 documents, such as
576+ <link linkend="book-nixos-manual">this one</link>,
577+ nXML needs to be configured with the relevant schema, which is
578+ not included.
579+ </para>
580+
581+ <para>
582+ To install the DocBook 5.0 schemas, either add
583+ <varname>pkgs.docbook5</varname> to
584+ <varname>environment.systemPackages</varname> (<link
585+ linkend="sec-declarative-package-mgmt">NixOS</link>), or run
586+ <literal>nix-env -i pkgs.docbook5</literal>
587+ (<link linkend="sec-ad-hoc-packages">Nix</link>).
588+ </para>
589+
590+ <para>
591+ Then customize the variable <varname>rng-schema-locating-files</varname> to include <filename>~/.emacs.d/schemas.xml</filename> and put the following text into that file:
592+ <example xml:id="ex-emacs-docbook-xml">
593+ <title>nXML Schema Configuration (<filename>~/.emacs.d/schemas.xml</filename>)</title>
594+ <programlisting language="xml"><![CDATA[
595+<?xml version="1.0"?>
596+<!--
597+ To let emacs find this file, evaluate:
598+ (add-to-list 'rng-schema-locating-files "~/.emacs.d/schemas.xml")
599+-->
600+<locatingRules xmlns="http://thaiopensource.com/ns/locating-rules/1.0">
601+ <!--
602+ Use this variation if pkgs.docbook5 is added to environment.systemPackages
603+ -->
604+ <namespace ns="http://docbook.org/ns/docbook"
605+ uri="/run/current-system/sw/share/xml/docbook-5.0/rng/docbookxi.rnc"/>
606+ <!--
607+ Use this variation if installing schema with "nix-env -iA pkgs.docbook5".
608+ <namespace ns="http://docbook.org/ns/docbook"
609+ uri="../.nix-profile/share/xml/docbook-5.0/rng/docbookxi.rnc"/>
610+ -->
611+</locatingRules>
612+]]></programlisting>
613+ </example>
614+ </para>
615+
616+ </section>
567617</section>
568618
569619</chapter>