1 .. _documentation-guide:
7 This guide provides details on how to contribute to the OpenDaylight
8 documentation. OpenDaylight currently uses a mix of AsciiDoc_ and
9 reStructuredText_ for documentation, although the `Documentation
10 Group`_ is generally trying to move toward using reStructuredText_ and
11 Sphinx_ to build it as it is widely-used to provide both HTML and pdf
12 documentation that can be easily versioned alongside the code. It also
13 offers similar syntax to Markdown which is familiar to large numbers of
16 reStructuredText-based Documentation
17 ====================================
19 When using reStructuredText, we try to follow the python documentation
20 style guide. See: https://docs.python.org/devguide/documenting.html
22 To build and review the reStructuredText documentation locally you must
23 have installed locally:
28 Which both should be available in most distribution's package managers.
30 Then simply run tox and open the html produced via your favorite web
35 git clone https://git.opendaylight.org/gerrit/docs
37 git submodule update --init
39 firefox docs/_build/html/index.html
41 .. note:: Make sure to run `tox -edocs` and not just `tox`. See `Make
42 sure you run tox -edocs`_
47 The directory structure for the reStructuredText documentation is
48 rooted in the ``docs`` directory inside the ``docs`` ``git``
51 Below that there are guides hosted directly in the ``docs`` ``git``
52 repository and there are guides hosted in remote ``git`` repositories.
53 Usually those are for project-specific information.
55 For example here is the directory layout on June, 28th 2016::
62 ├── getting-started-guide
64 │ ├── concepts_and_tools.rst
65 │ ├── experimental_features.rst
67 │ ├── installing_opendaylight.rst
68 │ ├── introduction.rst
69 │ ├── karaf_features.rst
70 │ ├── other_features.rst
72 │ └── who_should_use.rst
75 ├── opendaylight-with-openstack
78 │ ├── openstack-with-gbp.rst
79 │ ├── openstack-with-ovsdb.rst
80 │ └── openstack-with-vtn.rst
85 The ``getting-started-guide`` and ``opendaylight-with-openstack``
86 directories correspond to two guides hosted in the ``docs`` repository,
87 while the ``submodules/releng/builder`` directory houses documentation
88 for the `RelEng/Builder`_ project.
90 Inside each guide there is usually an ``index.rst`` file which then
91 includes other files using a ``toctree`` directive. For example::
96 getting-started-guide/index
97 opendaylight-with-openstack/index
98 submodules/releng/builder/docs/index
100 This creates a table of contents on that page where each heading of the
101 table of contents is the root of the files that are included.
103 .. note:: When including rst files using ``toctree`` omit the .rst at
104 the end of the file name.
106 Documentation Layout and Style
107 ------------------------------
109 As mentioned previously we try to follow the python documentation style guide
110 which defines a few types of sections::
112 # with overline, for parts
113 * with overline, for chapters
116 ^, for subsubsections
119 We try to follow the following structure based on that recommendation::
121 docs/index.rst -> entry point
122 docs/____-guide/index.rst -> part
123 docs/____-guide/<chapter>.rst -> chapter
125 In the ____-guide/index.rst we use the # with overline at the very top
126 of the file to determine that it is a part and then within each chapter
127 file we start the document with a section using * with overline to
128 denote that it's the chapter heading and then everything in the rest of
129 the chapter should use::
133 ^, for subsubsections
140 Make sure you've cloned submodules
141 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
143 If you see an error like this::
145 ./build-integration-robot-libdoc.sh: line 6: cd: submodules/integration/test/csit/libraries: No such file or directory
146 Resource file '*.robot' does not exist.
148 It means that you haven't pulled down the git submodule for the integration/test project. The fastest way to do that is::
150 git submodule update --init
152 In some cases, you might wind up with submodules which are somehow
153 out-of-sync and in that case, the easiest way to fix it is delete the
154 submodules directory and then re-clone the submodules::
156 rm -rf docs/submodules/
157 git submodule update --init
159 .. warning:: This will delete any local changes or information you made
160 in the submodules. This should only be the case if you
161 manually edited files in that directory.
163 Make sure you run tox -edocs
164 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
166 If you see an error like::
168 ERROR: docs: could not install deps [-rrequirements.txt]; v = InvocationError('/Users/ckd/git-reps/docs/.tox/docs/bin/pip install -rrequirements.txt (see /Users/ckd/git-reps/docs/.tox/docs/log/docs-1.log)', 1)
169 ERROR: docs-linkcheck: could not install deps [-rrequirements.txt]; v = InvocationError('/Users/ckd/git-reps/docs/.tox/docs-linkcheck/bin/pip install -rrequirements.txt (see /Users/ckd/git-reps/docs/.tox/docs-linkcheck/log/docs-linkcheck-1.log)', 1)
171 It usually means you ran `tox` and not `tox -edocs`, which will result
172 in running jobs inside submodules which aren't supported by the
173 environment defined by the `requirements.txt` file in the documentation
174 tox setup. Just run tox -edocs and it should be fine.
176 Clear your tox directory and try again
177 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
179 Sometimes, tox will not detect when your ``requirements.txt`` file has
180 changed and so will try to run things without the correct dependencies.
181 This usually manifests as ``No module named X`` errors or
182 an ``ExtensionError`` and can be fixed by deleting the ``.tox``
183 directory and building again::
188 AsciiDoc-based Documentation
189 ============================
191 Information on the AsciiDoc tools and build system can be found here:
192 https://wiki.opendaylight.org/view/Documentation/Tools
197 The AsciiDoc documentation is all located in the ``manuals`` directory
198 of the ``docs`` ``git`` repository. An example of the directory
199 structure on June 28th, 2016 can be seen here::
204 │ └── app_support.xml
211 ├── getting-started-guide
236 Each of the top-level directories under ``manuals`` is a whole guide by
237 itself and it contains a ``pom.xml`` file saying how to build it, a
238 ``src/main/asciidoc`` directory with AsciiDoc source files and a
239 ``src/main/resources`` directory containing images.
241 Migration from AsciiDoc to ReStructuredText
242 ===========================================
247 In theory, Pandoc_ can convert from DocBook to reStructuredText and we
248 produce DocBook as part of our build chain from AsciiDoctor. In
249 practice, for modest-sized migrations doing things by hand works fairly
255 Converting from AsciiDoc to reStructuredText is usually pretty
256 straightforward and involves looking up the basic syntax for what you
257 want to do by looking it up in the reStructuredText_ guide.
259 The differences are usually minor and fast to change.
261 Also, because of how fast Sphinx builds, and how fast it is to refresh
262 the HTML documentation rapid iteration is very easy.
264 Bold/Italics/Verbatim Formatting
265 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
267 This is mostly minor syntax issues. In AsciiDoc you do inline
268 formatting something like this::
270 *bold* _italic_ +verbatim+ `verbatim`
272 In reStructuredText, things are slightly different::
274 **bold** *italic* ``verbatim``
279 Image formats change from something like::
281 .OpenStack Architecture
282 image::vtn/OpenStackDeveloperGuide.png["OpenStack Architecture",width=500]
286 .. image:: images/dlux-default.png
288 A helpful regular expression for automating the replacements is something like::
290 search: ^( *)\.(.+)\n +image::(.+)\[(.+),width=(\d+)\]
291 replace: $1.. figure:: images/dlux/$3\n$1 :width: $5\n\n$1 $2
297 .. _AsciiDoc: http://www.methods.co.nz/asciidoc/
298 .. _Sphinx: http://www.sphinx-doc.org/en/stable/
299 .. _reStructuredText: http://www.sphinx-doc.org/en/stable/rest.html
300 .. _Documentation Group: https://wiki.opendaylight.org/view/Documentation/
301 .. _RelEng/Builder: https://wiki.opendaylight.org/view/RelEng/Builder
302 .. _Pandoc: http://pandoc.org/