blob: 3471ac1ec41657e7c26da7e3f88ef36846607db7 [file] [log] [blame]
Rich Bennettac93e0e2017-07-19 01:36:52 -04001.. This work is licensed under a Creative Commons Attribution 4.0 International License.
2
3.. _include-documentation:
4
5============================
6Including your Documentation
7============================
8
9.. contents::
10 :depth: 3
11 :local:
12
13In your project repository
14--------------------------
15
16Add your documentation to your repository in the folder structure and
Rich Bennett976bffd2017-08-15 07:56:32 -040017using templates as described above.
18When using a template, copy the directory in `doc/docs/templates/`,
19to your <repo>/docs/ directory in your repository.
20For instance if you want to document component-info, then your steps shall be
Rich Bennettac93e0e2017-07-19 01:36:52 -040021as follows:
22
23.. code-block:: bash
24
25 git clone ssh://<your_id>@gerrit.onap.org:29418/doc
Rich Bennett976bffd2017-08-15 07:56:32 -040026 cp -p doc/docs/templates/component-info <your_repo>/docs/component-info/
Rich Bennettac93e0e2017-07-19 01:36:52 -040027
28
Rich Bennett976bffd2017-08-15 07:56:32 -040029You should then add the relevant information to the template.
30When you are done writing, you can commit
Rich Bennettac93e0e2017-07-19 01:36:52 -040031the documentation to the your project repository.
Rich Bennett976bffd2017-08-15 07:56:32 -040032The sequence below shows basic git/gerrit steps,
33see `Developer Best Practices`_ for complete current information.
34
35.. _Developer Best Practices: https://wiki.onap.org/x/BZZk
Rich Bennettac93e0e2017-07-19 01:36:52 -040036
37.. code-block:: bash
38
39 git add .
40 git commit --signoff --all
41 git review
42
43In the ONAP doc Repository
44--------------------------
45
46To import project documents from project repositories, we use git submodules.
Rich Bennett976bffd2017-08-15 07:56:32 -040047Each ONAP project providing documentation, other than the doc project, is loaded under
48`doc/docs/submodules/` when needed for validating or publishing documentation.
49To describe the relationship between content files we use the `Sphinx toctree directive`.
Rich Bennettac93e0e2017-07-19 01:36:52 -040050
51The following diagram illustrates:
52 - all ONAP gerrit project repositories,
Rich Bennett976bffd2017-08-15 07:56:32 -040053 - the doc project repository including a master document index.rst,
54 - other document directories and/or RST files that organize sections and documents doc repository,
55 - the submodules directory where other project repositories and directories/files may be referenced,
56 - the templates directory with one example, a component-info template that may referenced in release orhigh level design documents, and
57 - another project repository example, `appc` that provides documentation source by copying and filling in an instance of the component-info template.
Rich Bennettac93e0e2017-07-19 01:36:52 -040058
59
60.. graphviz::
61
62
63 digraph docstructure {
64 size="8,12";
65 node [fontname = "helvetica"];
66 // Align gerrit repos and docs directories
67 {rank=same doc aaf aai appc repoelipse vnfsdk vvp}
Rich Bennett976bffd2017-08-15 07:56:32 -040068 {rank=same componentinfotemplate localappcdocs }
Rich Bennettac93e0e2017-07-19 01:36:52 -040069
70 //Show submodule linkage to docs directory
71 submodules -> localappcdocs [style=dotted];
72
73 //Illustrate Gerrit Repos and provide URL/Link for complete repo list
74 gerrit [label="gerrit.onap.org/r", href="https://gerrit.onap.org/r/#/admin/projects/" ];
75 gerrit -> doc;
76 gerrit -> aaf;
77 gerrit -> aai;
78 gerrit -> appc;
Rich Bennett976bffd2017-08-15 07:56:32 -040079 gerrit -> repoelipse; repoelipse [label=". . . ."];
Rich Bennettac93e0e2017-07-19 01:36:52 -040080 gerrit -> vnfsdk;
81 gerrit -> vvp;
82
Rich Bennett976bffd2017-08-15 07:56:32 -040083 //Show example of local appc instance of component info
84 appc -> localappcdocs; localappcdocs [label="docs"];
85 localappcdocs -> componentinfoinstance; componentinfoinstance [label="component-info"];
86 componentinfoinstance -> compinfoindexinstance; compinfoindexinstance [label="index.rst", shape=box];
87 componentinfoinstance -> compinofotherinstance; compinofotherinstance [label="... other sections", shape=box];
Rich Bennettac93e0e2017-07-19 01:36:52 -040088
89 //Show detail structure of a portion of doc/docs _images _static _templates multiple master documents omitted
90 doc -> docs;
91 docs -> confpy; confpy [label="conf.py",shape=box];
92 docs -> toplevelindex; toplevelindex [label="index.rst", shape=box];
93 docs -> release;
94 docs -> rsttemplates; rsttemplates [label="templates"];
95 docs -> indexdirelipse; indexdirelipse [label="...other\ndocuments"];
96 docs -> submodules
97
Rich Bennett976bffd2017-08-15 07:56:32 -040098 //Example Release document, section release notes, and reference to an instance of component-info
Rich Bennettac93e0e2017-07-19 01:36:52 -040099 release -> releasenotes; releasenotes [label="release-notes"];
100 releasenotes -> lowerlevelindex; lowerlevelindex [label="index.rst", shape=box];
Rich Bennett976bffd2017-08-15 07:56:32 -0400101 lowerlevelindex -> componentinfoinstance;
Rich Bennettac93e0e2017-07-19 01:36:52 -0400102
Rich Bennett976bffd2017-08-15 07:56:32 -0400103 //Example component-info template
104 rsttemplates -> componentinfotemplate; componentinfotemplate [label="component-info"];
105 componentinfotemplate -> compinfotmpindex; compinfotmpindex [label="index.rst", shape=box];
106 componentinfotemplate -> compinfotmpother; compinfotmpother [label="... other sections", shape=box];
Rich Bennettac93e0e2017-07-19 01:36:52 -0400107 }
108
109In the toctree
110++++++++++++++
111
112To include your project specific documentation in the composite documentation,
113first identify where your project documentation should be included.
Rich Bennett976bffd2017-08-15 07:56:32 -0400114Say your project provides component-info and should be referenced in the `doc/docs/release/release-info/index.rst toctree`, then:
Rich Bennettac93e0e2017-07-19 01:36:52 -0400115
116.. code-block:: bash
117
118 git clone ssh://<your_id>@gerrit.onap.org:29418/doc
119 vim doc/docs/release/release-notes/index.rst
120
121This opens the text editor. Identify where you want to add your release notes.
122If your release notes are to be added to the toctree, simply include the path to
123it, example:
124
125
126.. code-block:: bash
127
128 .. toctree::
129 :maxdepth: 1
130
Rich Bennett976bffd2017-08-15 07:56:32 -0400131 ../../submodules/<your_repo>/docs/component-info/index
Rich Bennettac93e0e2017-07-19 01:36:52 -0400132
133When finished, you can request a commit to the doc project repository.
Rich Bennett976bffd2017-08-15 07:56:32 -0400134Be sure to add the PTL of the docs project as a reviewer of the change you just
135pushed in gerrit.
Rich Bennettac93e0e2017-07-19 01:36:52 -0400136
137.. code-block:: bash
138
139 git add .
140 git commit --signoff --all
141 git review
142
143
144As a Hyperlink
145++++++++++++++
146
147It's pretty common to want to reference another location in the
148ONAP documentation and it's pretty easy to do with
149reStructuredText. This is a quick primer, more information is in the
150`Sphinx section on Cross-referencing arbitrary locations
151<http://www.sphinx-doc.org/en/stable/markup/inline.html#ref-role>`_.
152
153Within a single document, you can reference another section simply by::
154
155 This is a reference to `The title of a section`_
156
157Assuming that somewhere else in the same file there a is a section
158title something like::
159
160 The title of a section
161 ^^^^^^^^^^^^^^^^^^^^^^
162
163It's typically better to use ``:ref:`` syntax and labels to provide
164links as they work across files and are resilient to sections being
165renamed. First, you need to create a label something like::
166
167 .. _a-label:
168
169 The title of a section
170 ^^^^^^^^^^^^^^^^^^^^^^
171
172.. note:: The underscore (_) before the label is required.
173
174Then you can reference the section anywhere by simply doing::
175
176 This is a reference to :ref:`a-label`
177
178or::
179
180 This is a reference to :ref:`a section I really liked <a-label>`
181
182.. note:: When using ``:ref:``-style links, you don't need a trailing
183 underscore (_).
184
185Because the labels have to be unique, it usually makes sense to prefix
186the labels with the project name to help share the label space, e.g.,
187``sfc-user-guide`` instead of just ``user-guide``.
188
189
190'doc8' Validation
191-----------------
192It is recommended that all rst content is validated by `doc8 <https://pypi.python.org/pypi/doc8>`_ standards.
193To validate your rst files using doc8, install doc8.
194
195.. code-block:: bash
196
197 sudo pip install doc8
198
199doc8 can now be used to check the rst files. Execute as,
200
201.. code-block:: bash
202
203 doc8 --ignore D000,D001 <file>
204
205
206Testing: Build Documentation Locally
207------------------------------------
208
209Composite DOC documentation
210+++++++++++++++++++++++++++++++++
211To build the whole documentation under doc/, follow these steps:
212
213Install virtual environment.
214
215.. code-block:: bash
216
217 sudo pip install virtualenv
218 cd /local/repo/path/to/project
219
220Download the DOC repository.
221
222.. code-block:: bash
223
224 git clone http://gerrit.onap.org/r/doc
225
226Change directory to docs & install requirements.
227
228.. code-block:: bash
229
230 cd doc
231 sudo pip install -r etc/requirements.txt
232
233Update submodules, build documentation using tox & then open using any browser.
234
235.. code-block:: bash
236
237 cd doc
238 git submodule update --init
239 tox -edocs
240 firefox docs/_build/html/index.html
241
242.. note:: Make sure to run `tox -edocs` and not just `tox`.
243
244Individual project documentation
245++++++++++++++++++++++++++++++++
246To test how the documentation renders in HTML, follow these steps:
247
248Install virtual environment.
249
250.. code-block:: bash
251
252 sudo pip install virtualenv
253 cd /local/repo/path/to/project
254
255Download the doc repository.
256
257.. code-block:: bash
258
259 git clone http://gerrit.onap.org/r/doc
260
261Change directory to doc & install requirements.
262
263.. code-block:: bash
264
265 cd doc
266 sudo pip install -r etc/requirements.txt
267
268Move the conf.py file to your project folder where RST files have been kept:
269
270.. code-block:: bash
271
272 mv doc/docs/conf.py <path-to-your-folder>/
273
274Move the static files to your project folder:
275
276.. code-block:: bash
277
278 mv docs/_static/ <path-to-your-folder>/
279
280Build the documentation from within your project folder:
281
282.. code-block:: bash
283
284 sphinx-build -b html <path-to-your-folder> <path-to-output-folder>
285
286Your documentation shall be built as HTML inside the
287specified output folder directory.
288
289.. note:: Be sure to remove the `conf.py`, the static/ files and the output folder from the `<project>/docs/`. This is for testing only. Only commit the rst files and related content.
290
291
292Adding your project repository as a submodule
293---------------------------------------------
294
295Clone the doc repository and add your submodule using the commands below and where $reponame is your repository name.
296
297.. code-block:: bash
298
299 cd docs/submodules/
300 git submodule git https://gerrit.onap.org/r/$reponame
301 git submodule init $reponame/
302 git submodule update $reponame/
303 git add .
304 git review