Updated git submodules
[docs.git] / docs / documentation.rst
1 .. _documentation-guide:
2
3 ###################
4 Documentation Guide
5 ###################
6
7 This guide provides details on how to contribute to the OpenDaylight
8 documentation. OpenDaylight currently uses reStructuredText_ for
9 documentation and Sphinx_ to build it as it is widely-used to provide
10 both HTML and pdf documentation that can be easily versioned alongside
11 the code. It also offers similar syntax to Markdown which is familiar
12 to large numbers of people.
13
14 .. contents:: Contents
15    :depth: 2
16    :local:
17
18 Style Guide
19 ===========
20
21 This section serves two purposes:
22
23 #. A guide for those writing documentation to follow.
24 #. A guide for those reviewing documentation.
25
26 That being said, assuming that the content is usable, the bias should
27 be toward merging it rather than blocking on relatively minor edits.
28
29 Formatting Preferences
30 ----------------------
31
32 In general, the documentation team has focused on trying to make sure
33 that the instructions are comprehensible, but not being overly pedantic
34 about these things. Along those lines, while we would prefer the
35 following, generally they aren't a reason to -1 in and of themselves:
36
37 * No trailing whitespace
38 * Line wrapping at something reasonable, i.e., 72–100 characters
39
40 Key terms
41 ---------
42
43 * Functionality: something useful a project provides abstractly
44 * Feature: a Karaf feature that somebody could install
45 * Project: a project within OpenDaylight, projects ship features to
46   provide functionality
47 * OpenDaylight: this refers to the software we release, use this in
48   place of OpenDaylight controller, the OpenDaylight controller, not
49   ODL, not ODC
50
51   * Since there is a controller project within OpenDaylight, using
52     other terms is hard.
53
54 Common writing style mistakes
55 -----------------------------
56
57 * In per-project user documentation, you should never say *git clone*,
58   but should assume people have downloaded and installed the controller
59   per the getting started guide and start with ``feautre:install
60   <something>``
61 * Avoid statements which are true about part of OpenDaylight, but not
62   generally true.
63
64   * For example: "OpenDaylight is a NETCONF controller." It is, but
65     that is not all it is.
66
67 * In general, developer documentation should target external developers
68   to your project so should talk about what APIs you have and how they
69   could use them. It *should not* document how to contribute to your
70   project.
71
72 Grammar Preferences
73 ^^^^^^^^^^^^^^^^^^^
74
75 * Avoid contractions: use cannot instead of can't, it is instead of
76   it's, and the like.
77
78 Things to get right with spacing and capitalization
79 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
80
81 *Note that all of these apply when using them in text. If they are used
82 as part of URL, class name, or something similar, use the actual
83 capitalization and spacing.*
84
85 * ACL: not Acl or acl
86 * API: not api
87 * ARP: not Arp or arp
88 * datastore: not data store, Data Store, or DataStore (unless it's a
89   class/object name)
90 * IPsec, not IPSEC or ipsec
91 * IPv4 or IPv6: not Ipv4, Ipv6, ipv4, ipv6, IPV4, or IPV6
92 * Karaf: not karaf
93 * Linux: not LINUX or linux
94 * NETCONF: not Netconf or netconf
95 * Neutron: not neutron
96 * OSGi: not osgi or OSGI
97 * Open vSwitch: not OpenvSwitch, OpenVSwitch, or Open V Switch, etc.
98 * OpenDaylight: not Opendaylight, Open Daylight, or OpenDayLight, etc.
99
100   * also avoid abbreviations like ODL and ODC
101
102 * OpenFlow: not Openflow, Open Flow, openflow, etc.
103 * OpenStack: not Open Stack or Openstack
104 * QoS: not Qos, QOS, or qos
105 * RESTCONF: not Restconf or restconf
106 * RPC not Rpc or rpc
107 * URL not Url or url
108 * VM: not Vm or vm
109 * YANG: not Yang or yang
110
111 .. _docs-rst:
112
113 reStructuredText-based Documentation
114 ====================================
115
116 When using reStructuredText, we try to follow the python documentation
117 style guide. See: https://docs.python.org/devguide/documenting.html
118
119 The best reference for reStrucutedText syntax seems to be the Sphinx
120 Primer on reStructuredText_.
121
122 To build and review the reStructuredText documentation locally you must
123 have installed locally:
124
125 * python
126 * python-tox
127
128 Which both should be available in most distribution's package managers.
129
130 Then simply run tox and open the html produced via your favorite web
131 browser as follows:
132
133 .. code-block:: bash
134
135    git clone https://git.opendaylight.org/gerrit/docs
136    cd docs
137    git submodule update --init
138    tox -edocs
139    firefox docs/_build/html/index.html
140
141 .. note:: Make sure to run `tox -edocs` and not just `tox`. See `Make
142           sure you run tox -edocs`_
143
144 Directory Structure
145 -------------------
146
147 The directory structure for the reStructuredText documentation is
148 rooted in the ``docs`` directory inside the ``docs`` ``git``
149 repository.
150
151 Below that there are guides hosted directly in the ``docs`` ``git``
152 repository and there are guides hosted in remote ``git`` repositories.
153 Usually those are for project-specific information.
154
155 For example here is the directory layout on June, 28th 2016::
156
157    $ tree -L 2
158    .
159    ├── Makefile
160    ├── conf.py
161    ├── documentation.rst
162    ├── getting-started-guide
163    │   ├── api.rst
164    │   ├── concepts_and_tools.rst
165    │   ├── experimental_features.rst
166    │   ├── index.rst
167    │   ├── installing_opendaylight.rst
168    │   ├── introduction.rst
169    │   ├── karaf_features.rst
170    │   ├── other_features.rst
171    │   ├── overview.rst
172    │   └── who_should_use.rst
173    ├── index.rst
174    ├── make.bat
175    ├── opendaylight-with-openstack
176    │   ├── images
177    │   ├── index.rst
178    │   ├── openstack-with-gbp.rst
179    │   ├── openstack-with-ovsdb.rst
180    │   └── openstack-with-vtn.rst
181    └── submodules
182        └── releng
183            └── builder
184
185 The ``getting-started-guide`` and ``opendaylight-with-openstack``
186 directories correspond to two guides hosted in the ``docs`` repository,
187 while the ``submodules/releng/builder`` directory houses documentation
188 for the `RelEng/Builder`_ project.
189
190 Inside each guide there is usually an ``index.rst`` file which then
191 includes other files using a ``toctree`` directive. For example::
192
193    .. toctree::
194       :maxdepth: 1
195
196       getting-started-guide/index
197       opendaylight-with-openstack/index
198       submodules/releng/builder/docs/index
199
200 This creates a table of contents on that page where each heading of the
201 table of contents is the root of the files that are included.
202
203 .. note:: When including rst files using ``toctree`` omit the .rst at
204           the end of the file name.
205
206 Documentation Layout and Style
207 ------------------------------
208
209 As mentioned previously we try to follow the python documentation style
210 guide which defines a few types of sections::
211
212     # with overline, for parts
213     * with overline, for chapters
214     =, for sections
215     -, for subsections
216     ^, for subsubsections
217     ", for paragraphs
218
219 We try to follow the following structure based on that recommendation::
220
221     docs/index.rst                 -> entry point
222     docs/____-guide/index.rst      -> part
223     docs/____-guide/<chapter>.rst  -> chapter
224
225 In the ____-guide/index.rst we use the # with overline at the very top
226 of the file to determine that it is a part and then within each chapter
227 file we start the document with a section using * with overline to
228 denote that it's the chapter heading and then everything in the rest of
229 the chapter should use::
230
231     =, for sections
232     -, for subsections
233     ^, for subsubsections
234     ", for paragraphs
235
236 Referencing Sections
237 ^^^^^^^^^^^^^^^^^^^^
238
239 It's pretty common to want to reference another location in the
240 OpenDaylight documentation and it's pretty easy to do with
241 reStructuredText. This is a quick primer, more information is in the
242 `Sphinx section on Cross-referencing arbitrary locations
243 <http://www.sphinx-doc.org/en/stable/markup/inline.html#ref-role>`_.
244
245 Within a single document, you can reference another section simply by::
246
247    This is a reference to `The title of a section`_
248
249 Assuming that somewhere else in the same file there a is a section
250 title something like::
251
252    The title of a section
253    ^^^^^^^^^^^^^^^^^^^^^^
254
255 It's typically better to use ``:ref:`` syntax and labels to provide
256 links as they work across files and are resilient to sections being
257 renamed. First, you need to create a label something like::
258
259    .. _a-label:
260
261    The title of a section
262    ^^^^^^^^^^^^^^^^^^^^^^
263
264 .. note:: The underscore (_) before the label is required.
265
266 Then you can reference the section anywhere by simply doing::
267
268     This is a reference to :ref:`a-label`
269
270 or::
271
272     This is a reference to :ref:`a section I really liked <a-label>`
273
274 .. note:: When using ``:ref:``-style links, you don't need a trailing
275           underscore (_).
276
277 Because the labels have to be unique, it usually makes sense to prefix
278 the labels with the project name to help share the label space, e.g.,
279 ``sfc-user-guide`` instead of just ``user-guide``.
280
281
282 .. _docs-rst-troubleshooting:
283
284 Troubleshooting
285 ---------------
286
287 Nested formatting doesn't work
288 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
289
290 As stated in the reStructuredText_ guide, inline markup for bold,
291 italic, and fixed-width can't be nested. Further, it can't be mixed
292 with hyperlinks, so you can't have bold text link somewhere.
293
294 This is tracked in a `Docutils FAQ question
295 <http://docutils.sourceforge.net/FAQ.html#is-nested-inline-markup-possible>`_,
296 but there is no clear current plan to fix this.
297
298 Make sure you've cloned submodules
299 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
300
301 If you see an error like this::
302
303    ./build-integration-robot-libdoc.sh: line 6: cd: submodules/integration/test/csit/libraries: No such file or directory
304    Resource file '*.robot' does not exist.
305
306 It means that you haven't pulled down the git submodule for the
307 integration/test project. The fastest way to do that is::
308
309    git submodule update --init
310
311 In some cases, you might wind up with submodules which are somehow
312 out-of-sync and in that case, the easiest way to fix it is delete the
313 submodules directory and then re-clone the submodules::
314
315    rm -rf docs/submodules/
316    git submodule update --init
317
318 .. warning:: This will delete any local changes or information you made
319              in the submodules. This should only be the case if you
320              manually edited files in that directory.
321
322 Make sure you run tox -edocs
323 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
324
325 If you see an error like::
326
327    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)
328    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)
329
330 It usually means you ran `tox` and not `tox -edocs`, which will result
331 in running jobs inside submodules which aren't supported by the
332 environment defined by the `requirements.txt` file in the documentation
333 tox setup. Just run tox -edocs and it should be fine.
334
335 Clear your tox directory and try again
336 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
337
338 Sometimes, tox will not detect when your ``requirements.txt`` file has
339 changed and so will try to run things without the correct dependencies.
340 This usually manifests as ``No module named X`` errors or
341 an ``ExtensionError`` and can be fixed by deleting the ``.tox``
342 directory and building again::
343
344    rm -rf .tox
345    tox -edocs
346
347 Builds on Read the Docs
348 ^^^^^^^^^^^^^^^^^^^^^^^
349
350 It appears as though the Read the Docs builds don't automatically clear
351 the file structure between builds and clones. The result is that you
352 may have to clean up the state of old runs of the build script.
353
354 As an example, this patch:
355 https://git.opendaylight.org/gerrit/41679
356
357 Finally fixed the fact that our builds for failing because they were
358 taking too long by removing directories of generated javadoc that were
359 present from previous runs.
360
361 Project Documentation Requirements
362 ==================================
363
364 Submitting Documentation Outlines (M3)
365 --------------------------------------
366
367 #. Determine the features your project will have and which ones will be
368    ''user-facing''.
369
370    * In general, a feature is user-facing if it creates functionality that a
371      user would direction interact with.
372    * For example, ``odl-openflowplugin-flow-services-ui`` is likely
373      user-facing since it installs user-facing OpenFlow features, while
374      ``odl-openflowplugin-flow-services`` is not because it provides only
375      developer-facing features.
376
377 #. Determine pieces of documentation you need provide based on the features
378    your project will have and which ones will be user-facing.
379
380    * The kinds of required documentation can be found below in the
381      :ref:`requirements-for-projects` section.
382    * Note that you might need to create multiple different documents for the
383      same kind of documentation. For example, the controller project will
384      likely want to have a developer section for the config subsystem as well
385      as a for the MD-SAL.
386
387 #. Clone the docs repo: ``git clone https://git.opendaylight.org/gerrit/docs``
388 #. For each piece of documentation find the corresponding template in the docs repo.
389
390    * For user documentation: ``docs.git/docs/templates/template-user-guide.rst``
391    * For developer documentation: ``ddocs/templates/template-developer-guide.rst``
392    * For installation documentation (if any): ``docs/templates/template-install-guide.rst``
393
394    .. note:: You can find the rendered templates here:
395
396              .. toctree::
397                 :maxdepth: 1
398
399                 templates/template-user-guide
400                 templates/template-developer-guide
401                 templates/template-install-guide.rst
402
403
404 #. Copy the template into the appropriate directory for your project.
405
406    * For user documentation: ``docs.git/docs/user-guide/${feature-name}-user-guide.rst``
407    * For developer documentation: ``docs.git/docs/developer-guide/${feature-name}-developer-guide.rst``
408    * For installation documentation (if any): ``docs.git/docs/getting-started-guide/project-specific-guides/${project-name}.rst``
409
410    .. note:: These naming conventions aren't set in stone, but do help. If you
411              think there's a better name, use it and we'll give feedback on the
412              gerrit patch.
413
414 #. Edit the template to fill in the outline of what you will provide using the
415    suggestions in the template. If you feel like a section isn't needed, feel
416    free to omit it.
417
418 #. Link the template into the appropriate core rst file
419
420    * For user documentation: ``docs.git/docs/user-guide/index.rst``
421    * For developer documentation: ``docs.git/docs/developer-guide/index.rst``
422    * For installation documentation (if any): ``docs.git/docs/getting-started-guide/project-specific-guides/index.rst``
423    * In each file, it should be pretty clear what line you need to add. In
424      general if you have an rst file ``project-name.rst``, you include it by
425      adding a new line ``project-name`` without the ``.rst`` at the end.
426
427 #. Make sure the documentation project still builds.
428
429    * Run ``tox -edocs`` from the root of the cloned docs repo.
430
431      * After that, you should be able to find the HTML version of the
432        docs at ``docs.git/docs/_build/html/index.html``.
433      * See :ref:`docs-rst` for more details about building the docs.
434
435    * The :ref:`reStructuredText Troubleshooting <docs-rst-troubleshooting>`
436      section provides common errors and solutions.
437    * If you still have problems e-mail the documentation group at
438      documentation@lists.opendaylight.org
439
440 #. Commit and submit the patch
441
442    #. Commit using:
443
444       .. code-block:: bash
445
446          git add --all && git commit -sm "Documentation outline for ${project-shortname}"
447
448    #. Submit using:
449
450       .. code-block:: bash
451
452          git review
453
454       See the `Git-review Workflow <https://wiki.opendaylight.org/view/Git-review_Workflow>`_
455       page if you don't have git-review installed.
456
457 #. Wait for the patch to be merged or to get feedback
458
459    * If you get feedback, make the requested changes and resubmit the patch.
460    * When you resubmit the patch, it's helpful if you also post a +0 reply to
461      the gerrit saying what patch set you just submitted and what you fixed in
462      the patch set.
463    * The documentation team will also be creating (or asking projects to
464      create) small groups of 2-4 projects that will peer review each other's
465      documentation. Patches which have seen a few cycles of peer review will be
466      prioritized for review and merge by the documentation team.
467
468 Expected Output From Documentation Project
469 ------------------------------------------
470
471 The expected output is (at least) 3 PDFs and equivalent web-based documentation:
472
473 * User/Operator Guide
474 * Developer Guide
475 * Installation Guide
476
477 These guides will consist of "front matter" produced by the documentation group
478 and the per-project/per-feature documentation provided by the projects. Note
479 that this is intended to be who is responsible for the documentation and should
480 not be interpreted as preventing people not normally in the documentation group
481 from helping with "front matter" nor preventing people from the documentation
482 group from helping with per-project/per-feature documentation.
483
484 Boron Project Documentation Requirements
485 ----------------------------------------
486
487 .. _kinds-of-docs:
488
489 Kinds of Documentation
490 ^^^^^^^^^^^^^^^^^^^^^^
491
492 These are the expected kinds of documentation and target audiences for each kind.
493
494 * **User/Operator:** for people looking to use the feature w/o writing code
495
496   * Should include an overview of the project/feature
497   * Should include description of availbe configuration options and what they do
498
499 * **Developer:** for people looking to use the feature in code w/o modifying it
500
501   * Should include API documentation, e.g., enunciate for REST, Javadoc for
502     Java, ??? for RESTCONF/models
503
504 * **Contributor:** for people looking to extend or modify the feature's source
505   code
506
507   .. note:
508
509      should be documented on the wiki not in reStructuredText
510
511 * **Installation:** for people looking for instructions to install the feature
512   after they have downloaded the ODL release
513
514   .. note:
515
516      audience is the same as User/Operator docs
517
518   * For most projects, this will be just a list of top-level features and
519     options
520
521     * As an example, l2switch-switch as the top-level feature with the -rest
522       and -ui options
523     * We'd also like them to note if the options should be checkboxes (i.e.,
524       they can each be turned on/off independently) or a drop down (i.e., at
525       most one can be selected)
526     * What other top-level features in the release are incompatible with each
527       feature
528     * This will likely be presented as a table in the documentation and the
529       data will likely also be consumed by automated installers/configurators/downloaders
530
531   * For some projects, there is extra installation instructions (for external
532     components) and/or configuration
533
534     * In that case, there will be a (sub)section in the documentation
535       describing this process.
536
537 * **HowTo/Tutorial:** walk throughs and examples that are not general-purpose
538   documentation
539
540   * Generally, these should be done as a (sub)section of either user/operator
541     or developer documentation.
542   * If they are especially long or complex, they may belong on their own
543
544 * **Release Notes:**
545
546   * Release notes are required as part of each project's release review. They
547     must also be translated into reStructuredText for inclusion in the formal
548     documentation.
549
550 .. _requirements-for-projects:
551
552 Requirements for projects
553 ^^^^^^^^^^^^^^^^^^^^^^^^^
554
555 Projects MUST do the following
556
557 * Provide reStructuredText documentation including
558
559   * Developer documentation for every feature
560
561     * Most projects will want to logically nest the documentation for
562       individual features under a single project-wide chapter or section
563     * This can be provided as a single .rst file or multiple .rst files if
564       the features fall into different groups
565     * This should start with ~300 word overview of the project and include
566       references to any automatically-generated API documentation as well as
567       more general developer information (see
568       :ref:`kinds-of-docs`).
569
570   * User/Operator documentation for every every user-facing feature (if any)
571
572     * ''Note: This should be per-feature, not per-project. User's shouldn't have to know which project a feature came from.''
573     * Intimately related features, e.g., l2switch-switch, l2switch-switch-rest, and l2switch-switch-ui, can be documented as one noting the differences
574     * This can be provided as a single .rst file or multiple .rst files if the features fall into different groups
575
576   * Installation documentation
577
578     * Most projects will simply provide a list of user-facing features and
579       options. See :ref:`kinds-of-docs` above.
580
581   * Release Notes (both on the wiki and reStructuredText) as part of the release review.
582
583 * This documentation will be contributed to the docs repo (or possibly imported from the project's own repo with tooling that is under development)
584
585   * Projects MAY be ENCOURGAGED to instead provide this from their own repository if the tooling is developed
586   * Projects choosing to meet the requirement this way MUST provide a patch to docs repo to import the project's documentation
587
588 * Projects MUST cooperate with the documentation group on edits and enhancements to documentation
589
590   * Note that the documentation team will also be creating (or asking projects to create) small groups of 2-4 projects that will peer review each other's documentation. Patches which have seen a few cycles of peer review will be prioritized for review and merge by the documentation team.
591
592 Timeline for Deliverables from Projects
593 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
594
595 * **M3:** Documentation Started
596
597   * Identified the kinds of documentation that will be provided and for what
598     features
599
600     * Release Notes are not required until release reviews at **RC2**
601
602   * Created the appropriate .rst files in the docs repository (or their own
603     repository if the tooling is available)
604   * Have an outline for the expected documentation in those .rst files
605     including the relevant (sub)sections and a sentence or two explaining what
606     will go there
607
608     * Obviusly, providing actual documentation in the (sub)sections is
609       encouraged and meets this requirement
610
611   * Milestone readout should include
612
613     #. the list of kinds of documentation
614     #. the list of corresponding .rst files and their location, e.g., repo and
615        path
616     #. the list of commits creating those .rst files
617     #. the current word counts of those .rst files
618
619 * **M4:** Documentation Continues
620
621   * The readout at M4 should include the word counts of all .rst files with
622     links to commits
623   * The goal is to have draft documentation complete so that the documentation
624     group can comment on it.
625
626 * **M5:** Documentation Complete
627
628   * All (sub)sections in all .rst files have complete, readable, usable content.
629   * Ideally, there should have been some interaction with the documentation
630     group about any suggested edits and enhancements
631
632 * **RC2:** Release notes
633
634   * Projects must provide release notes as .rst pushed to integration (or
635     locally in the project's repository if the tooling is developed)
636
637
638 .. _Sphinx: http://www.sphinx-doc.org/en/stable/
639 .. _reStructuredText: http://www.sphinx-doc.org/en/stable/rest.html
640 .. _Documentation Group: https://wiki.opendaylight.org/view/Documentation/
641 .. _RelEng/Builder: https://wiki.opendaylight.org/view/RelEng/Builder
642 .. _Pandoc: http://pandoc.org/