1 .. This work is licensed under a Creative Commons Attribution 4.0
2 .. International License. http://creativecommons.org/licenses/by/4.0
3 .. Copyright 2017 AT&T Intellectual Property. All rights reserved.
9 Some initial set up is required to connect a project with
10 the master document structure and enable automated publishing of
11 changes as summarized in the following diagram and description below
19 DA [label = "Doc Project\nAuthor/Committer", color=lightblue];
20 DR [label = "Doc Gerrit Repo" , color=pink];
21 PR [label = "Other Project\nGerrit Repo", color=pink ];
22 PA [label = "Other Project\nAuthor/Committer", color=lightblue];
24 PA -> DR [label = "Add project repo as\ngit submodule" ];
25 DR -> DA [label = "Review & Plan to\nIntegrate Content with\nTocTree Structure" ];
26 DR <-- DA [label = "Vote +2/Merge" ];
27 PA <-- DR [label = "Merge Notification" ];
28 PA -> PR [label = "Create in project repo\ntop level directory and index.rst" ];
29 PR -> DA [label = "Add as Reviewer" ];
30 PR <-- DA [label = "Approve and Integrate" ];
31 PA <-- PR [label = "Merge" ];
34 Setup project repositories(s)
35 -----------------------------
36 These steps are performed for each project repository that
37 provides documentation.
39 First let's set two variables that will be used in the subsequent steps.
40 Set *reponame* to the project repository you are setting up
41 just as it appears in the **Project Name** column of
42 the Gerrit projects page.
43 Set *lfid* to your Linux Foundation identity that you use to
44 login to gerrit or for git clone requests over ssh.
51 The next step is to add a directory in the doc project where your
52 project will be included as a submodule and at least one reference
53 from the doc project to the documentation index in your repository.
54 The following sequence will do this over ssh. Please note that the
55 reference to your project in *repolist.rst* should be considered
56 temporary and removed when you reference it from more appropriate
61 If your access network restricts ssh, you will need to use equivalent
62 git commands and HTTP Passwords as described `here <http://wiki.onap.org/x/X4AP>`_.
66 Don't replace ../ in *git submodule add* with any relative path on
67 your local file system. It refers to the location of your repository
72 git clone ssh://$lfid@gerrit.onap.org:29418/doc
74 mkdir -p `dirname docs/submodules/$reponame`
75 git submodule add ../$reponame docs/submodules/$reponame.git
76 git submodule init docs/submodules/$reponame.git
77 git submodule update docs/submodules/$reponame.git
79 echo " $reponame <../submodules/$reponame.git/docs/index>" >> docs/release/repolist.rst
86 Wait for the above change to be merged before any merge to the
87 project repository that you have just added as a submodule.
88 If the project repository added as submodule changes before the
89 doc project merge, git may not automatically update the submodule
90 reference on changes and/or the verify job will fail in the step below.
93 The last step is to create a docs directory in your repository with
94 an index.rst file. The following sequence will complete the minimum
95 required over ssh. As you have time to convert or add new content you
96 can update the index and add files under the docs folder.
99 If you have additional content, you can include it by editing the
100 index.rst file and/or adding other files before the git commit.
101 See `Templates and Examples`_ below and :ref:`converting-to-rst`
102 for more information.
107 git clone ssh://$lfid@gerrit.onap.org:29418/$reponame
110 echo ".. This work is licensed under a Creative Commons Attribution 4.0 International License.
112 TODO Add files to toctree and delete this header
113 ------------------------------------------------
124 The diagram below illustrates what is accomplished in the setup steps
125 above from the perspective of a file structure created for a local test,
126 a jenkins verify job, and/or published release documentation including:
128 - ONAP gerrit project repositories,
130 - doc project repository master document index.rst, templates,
131 configuration, and other documents
133 - submodules directory where other project repositories and
134 directories/files are referenced
136 - file structure: directories (ellipses), files(boxes)
138 - references: directory/files (solid edges), git submodule
139 (dotted edges), sphinx toctree (dashed edges)
144 digraph docstructure {
146 node [fontname = "helvetica"];
147 // Align gerrit repos and docs directories
148 {rank=same doc aaf aai reponame repoelipse vnfsdk vvp}
149 {rank=same confpy release templates masterindex submodules otherdocdocumentelipse}
150 {rank=same releasedocumentindex releaserepolist}
152 //Illustrate Gerrit Repos and provide URL/Link for complete repo list
153 gerrit [label="gerrit.onap.org/r", href="https://gerrit.onap.org/r/#/admin/projects/" ];
154 doc [href="https://gerrit.onap.org/r/gitweb?p=doc.git;a=tree"];
159 gerrit -> repoelipse;
160 repoelipse [label=". . . ."];
164 //Show example of local reponame instance of component info
165 reponame -> reponamedocsdir;
166 reponamesm -> reponamedocsdir;
167 reponamedocsdir [label="docs"];
168 reponamedocsdir -> repnamedocsdirindex;
169 repnamedocsdirindex [label="index.rst", shape=box];
171 //Show detail structure of a portion of doc/docs
174 confpy [label="conf.py",shape=box];
176 masterindex [label="Master\nindex.rst", shape=box];
179 docs -> otherdocdocumentelipse;
180 otherdocdocumentelipse [label="...other\ndocuments"];
183 masterindex -> releasedocumentindex [style=dashed, label="sphinx\ntoctree\nreference"];
185 //Show submodule linkage to docs directory
186 submodules -> reponamesm [style=dotted,label="git\nsubmodule\nreference"];
187 reponamesm [label="reponame.git"];
189 //Example Release document index that references component info provided in other project repo
190 release -> releasedocumentindex;
191 releasedocumentindex [label="index.rst", shape=box];
192 releasedocumentindex -> releaserepolist [style=dashed, label="sphinx\ntoctree\nreference"];
193 releaserepolist [label="repolist.rst", shape=box];
194 release -> releaserepolist;
195 releaserepolist -> repnamedocsdirindex [style=dashed, label="sphinx\ntoctree\nreference"];
199 Branches in the DOC Project
200 ---------------------------
202 The DOC project 'master' branch aggregates the 'latest' content
203 from all ONAP project repositories contributing documentation into a
204 single tree file structure as described in the previous section. This
205 branch is continuously integrated and deployed at Read The
206 Docs as the 'latest' ONAP Documentation by:
208 * Jenkins doc-verify-rtd and doc-merge-rtd jobs triggered whenever patches on
209 contributing repositories contain rst files at or below a top level
212 * Subscription in the DOC project to changes in submodule repositories.
213 These changes appear in the DOC project as commits with title
214 'Updated git submodules' when a change to a contributing project
215 repository is merged. No DOC project code review occurs, only a
216 submodule repository commit hash is updated to track the head of each
217 contributing master branch.
219 For each ONAP named release the DOC project creates a branch with the
220 release name. The timing of the release branch is determined by
221 work needed in the DOC project to prepare the release branch and the
222 amount of change unrelated to the release in the master branch.
223 For example contributing projects that create named release branches
224 early to begin work on the next release and/or contributing projects
225 to the master that are not yet part of the named release would result
226 in an earlier named release branch to cleanly separate work to stabilize
227 a release from other changes in the master branch.
229 A named release branch is integrated and deployed at Read The Docs
230 as the 'named release' by aggregating content from contributing
231 project repositories. A contributing project repository can
232 choose one of the following for the 'named release' branch:
234 * Remove the contributing project repository submodule and RST
235 references when not part of the named release.
237 * Provide a commit hash or tag for the contributing project master
238 branch to be used for the life of the release branch or until a
239 request is submitted to change the commit hash or tag.
241 * Provide the commit hash for the head of a named release branch
242 created in the contributing project repository. This option
243 may be appropriate if frequent changes are expected over the
244 life of the named release and work the same way as the continuous
245 integration and deployment described for the master branch.
247 The decision on option for each contributing project repository
248 can be made or changed before the final release is approved. The
249 amount of change and expected differences between master and a
250 named release branch for each repository should drive the choice of
256 GIT is a powerful tool allowing many actions, but without respecting some rules
257 the GIT structure can be quickly hard to maintain.
259 Here are some conventions about GIT branches:
261 - ALWAYS create a local branch to edit or create any file. This local branch
262 will be considered as a topic in Gerrit and allow contributors to
263 work at the same time on the same project.
265 - 1 feature = 1 branch. In the case of documentation, a new chapter
266 or page about a new code feature can be considered as a 'doc feature'
268 - 1 bug = 1 branch. In the case of documentation, a correction on an
269 existing sentence can be considered as a 'doc bug'
271 - the master branch is considered as "unstable", containing new features that
272 will converge to a stable situation for the release date.
274 The day of the release, the repository owner will create a new branch to
275 fix the code and documentation. This will represent the 'stable' code of the
276 release. In this context:
278 - NEVER push a new feature on a stable branch
280 - Only bug correction are authorized on a stable branch using
283 .. image:: git_branches.png
285 Creating Restructured Text
286 ==========================
288 Templates and Examples
289 ----------------------
290 Templates are available that capture the kinds of information
291 useful for different types of projects and provide some examples of
292 restructured text. We organize templates in the following way to:
294 - help authors understand relationships between documents
296 - keep the user audience context in mind when writing and
298 - tailor sections for different kinds of projects.
301 **Sections** Represent a certain type of content. A section
302 is **provided** in an project repository, to describe something about
303 the characteristics, use, capability, etc. of things in that repository.
304 A section may also be **referenced** from other sections and in
305 other repositories. For example, an API specification provided in a project
306 repository might be referenced to in a Platform API Reference Guide.
307 The notes in the beginning of each section template provide
308 additional detail about what is typically covered and where
309 there may be references to the section.
311 **Collections** Are a set of sections that are typically provided
312 for a particular type of project, repository, guide, reference manual, etc.
313 For example, a collection for a platform component, an SDK, etc.
315 You can: browse the template *collections* and *sections* below;
316 show source to look at the Restructured Text and Sphinx directives used;
317 copy the source either from a browser window or by downloading the
318 file in raw form from
319 the `gerrit doc repository <https://gerrit.onap.org/r/gitweb?p=doc.git;a=tree;f=docs/templates;/>`_ and
320 then add them to your repository docs folder and index.rst.
330 ../../../templates/sections/*
340 ../../../templates/collections/*
344 In addition to these simple templates and examples
345 there are many open source projects (e.g. Open Daylight, Open Stack)
346 that are using Sphinx and Readthedocs where you may find examples
347 to start with. Working with project teams we will continue to enhance
348 templates here and capture frequently asked questions on the developer
349 wiki question topic `documentation <https://wiki.onap.org/questions/topics/16384055/documentation>`_.
353 - decide what is relevant content
355 - determine the best way to create/maintain it in the CI/CD process and
357 - work with the documentation team to reference content from the
358 master index and guides.
360 Consider options including filling in a template, identifying existing
361 content that can be used as is or easily converted, and use of Sphinx
362 directives/extensions to automatically generate restructured text
363 from other source you already have.
367 It's pretty common to want to reference another location in the
368 ONAP documentation and it's pretty easy to do with
369 reStructuredText. This is a quick primer, more information is in the
370 `Sphinx section on Cross-referencing arbitrary locations
371 <http://www.sphinx-doc.org/en/stable/markup/inline.html#ref-role>`_.
373 Within a single document, you can reference another section simply by::
375 This is a reference to `The title of a section`_
377 Assuming that somewhere else in the same file there a is a section
378 title something like::
380 The title of a section
381 ^^^^^^^^^^^^^^^^^^^^^^
383 It's typically better to use ``:ref:`` syntax and labels to provide
384 links as they work across files and are resilient to sections being
385 renamed. First, you need to create a label something like::
389 The title of a section
390 ^^^^^^^^^^^^^^^^^^^^^^
392 .. note:: The underscore (_) before the label is required.
394 Then you can reference the section anywhere by simply doing::
396 This is a reference to :ref:`a-label`
400 This is a reference to :ref:`a section I really liked <a-label>`
402 .. note:: When using ``:ref:``-style links, you don't need a trailing
405 Because the labels have to be unique, it usually makes sense to prefix
406 the labels with the project name to help share the label space, e.g.,
407 ``sfc-user-guide`` instead of just ``user-guide``.
414 It is recommended that all rst content is validated by `doc8 <https://pypi.python.org/pypi/doc8>`_ standards.
415 To validate your rst files using doc8, install doc8.
419 sudo pip install doc8
421 doc8 can now be used to check the rst files. Execute as,
425 doc8 --ignore D000,D001 <file>
431 To test how the documentation renders in HTML, follow these steps:
433 Install `virtual environment <https://pypi.org/project/virtualenv>`_ & create one.
437 sudo pip install virtualenv
440 Activate `onap_docs` virtual environment.
444 source onap_docs/bin/activate
446 .. note:: Virtual environment activation has to be performed before attempting to build documentation.
447 Otherwise, tools necessary for the process might not be available.
449 Download a project repository.
453 git clone http://gerrit.onap.org/r/<project>
455 Download the doc repository.
459 git clone http://gerrit.onap.org/r/doc
461 Change directory to doc & install requirements.
466 pip install -r etc/requirements.txt
468 Copy the conf.py file to your project folder where RST files have been kept:
472 cp docs/conf.py <path-to-project-folder>/<folder where are rst files>
474 Copy the static files to the project folder where RST files have been kept:
478 cp -r docs/_static/ <path-to-project-folder>/<folder where are rst files>
480 Build the documentation from within your project folder:
484 sphinx-build -b html <path-to-project-folder>/<folder where are rst files> <path-to-output-folder>
486 Your documentation shall be built as HTML inside the
487 specified output folder directory.
489 You can use your Web Browser to open
490 and check resulting html pages in the output folder.
492 .. 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.
494 .. _building-all-documentation:
498 To build the all documentation under doc/, follow these steps:
500 Install virtual environment.
504 sudo pip install virtualenv
505 cd /local/repo/path/to/project
507 Download the DOC repository.
511 git clone http://gerrit.onap.org/r/doc
513 Build documentation using tox local environment & then open using any browser.
519 firefox docs/_build/html/index.html
521 .. note:: Make sure to run `tox -elocal` and not just `tox`.
522 This updates all submodule repositories that are integrated
525 There are additional tox environment options for checking External
526 URLs and Spelling. Use the tox environment options below and then
527 look at the output with the Linux `more` or similar command
528 scan for output that applies to the files you are validating.
533 more < docs/_build/linkcheck/output.txt
536 more < docs/_build/spellcheck/output.txt