1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
6 Some initial set up is required to connect a project with
7 the master document structure and enable automated publishing of
8 changes as summarized in the following diagram and description below
16 RD [label = "Read The Docs", color =lightgreen ];
17 DA [label = "Doc Project\nAuthor/Committer", color=lightblue];
18 DR [label = "Doc Gerrit Repo" , color=pink];
19 PR [label = "Other Project\nGerrit Repo", color=pink ];
20 PA [label = "Other Project\nAuthor/Committer", color=lightblue];
22 === One time setup doc project only ===
23 RD -> DA [label = "Acquire Account" ];
24 DA -> DR [label = "Create initial\n doc repository content"];
25 DA <<-- DR [label = "Merge" ];
26 RD <-- DA [label = "Connect gerrit.onap.org" ];
27 === For each project repository containing document source ===
28 PA -> DR [label = "Add project repo as\ngit submodule" ];
29 DR -> DA [label = "Review & Plan to\nIntegrate Content with\nTocTree Structure" ];
30 DR <-- DA [label = "Vote +2/Merge" ];
31 PA <-- DR [label = "Merge Notification" ];
32 PA -> PR [label = "Create in project repo\ntop level directory and index.rst" ];
33 PR -> DA [label = "Add as Reviewer" ];
34 PR <-- DA [label = "Approve and Integrate" ];
35 PA <-- PR [label = "Merge" ];
42 These steps are performed only once for the doc project and include:
44 (1) creating in the doc repository an initial:
45 - sphinx master document index
46 - a directory structure aligned with the document structure
47 - tests performed in jenkins verify jobs
48 - sphinx configuration
50 (2) establishing an account at readthedocs connected with the doc
51 doc project repo in gerrit.onap.org.
54 Setup project repositories(s)
55 -----------------------------
56 These steps are performed for each project repository that provides documentation.
58 First let's set two variables that will be used in the following examples.
59 Set reponame to the project repository you are setting up just as it appears in the
60 **Project Name** column of the Gerrit projects page.
61 Set lfid to your Linux Foundation identity that you use to login to gerrit or for git
62 clone requests over ssh.
69 The next step is to add a directory in the doc project where your project will be included as a
70 submodule and at least one reference from the doc project to the documentation index in your repository.
74 git clone ssh://$lfid@gerrit.onap.org:29418/doc
76 mkdir -p `dirname docs/submodules/$reponame`
77 git submodule add https://gerrit.onap.org/r/$reponame docs/submodules/$reponame.git
78 git submodule init docs/submodules/$reponame.git
79 git submodule update docs/submodules/$reponame.git
81 echo " $reponame <../submodules/$reponame.git/docs/index>" >> docs/release/repolist.rst
89 The last step is to create a docs directory in your repository with an index.rst file.
93 git clone ssh://$lfid@gerrit.onap.org:29418/$reponame
96 echo ".. This work is licensed under a Creative Commons Attribution 4.0 International License.
98 TODO Add files to toctree and delete this header
99 ------------------------------------------------
110 The diagram below illustrates what is accomplished in the setup steps
111 above from the perspective of a file structure created for a local test,
112 a jenkins verify job, and/or published release documentation including:
114 - all ONAP gerrit project repositories,
115 - the doc project repository master document index.rst, templates, configuration
116 - the submodules directory where other project repositories and directories/files may be referenced
122 digraph docstructure {
124 node [fontname = "helvetica"];
125 // Align gerrit repos and docs directories
126 {rank=same doc aaf aai reponame repoelipse vnfsdk vvp}
127 {rank=same confpy release templates masterindex submodules otherdocdocumentelipse}
128 {rank=same releasedocumentindex releaserepolist}
130 //Illustrate Gerrit Repos and provide URL/Link for complete repo list
131 gerrit [label="gerrit.onap.org/r", href="https://gerrit.onap.org/r/#/admin/projects/" ];
132 doc [href="https://gerrit.onap.org/r/gitweb?p=doc.git;a=tree"];
137 gerrit -> repoelipse;
138 repoelipse [label=". . . ."];
142 //Show example of local reponame instance of component info
143 reponame -> reponamedocsdir;
144 reponamesm -> reponamedocsdir;
145 reponamedocsdir [label="docs"];
146 reponamedocsdir -> repnamedocsdirindex;
147 repnamedocsdirindex [label="index.rst", shape=box];
149 //Show detail structure of a portion of doc/docs
152 confpy [label="conf.py",shape=box];
154 masterindex [label="Master\nindex.rst", shape=box];
157 docs -> otherdocdocumentelipse;
158 otherdocdocumentelipse [label="...other\ndocuments"];
161 masterindex -> releasedocumentindex [style=dashed, label="sphinx\ntoctree\nreference"];
163 //Show submodule linkage to docs directory
164 submodules -> reponamesm [style=dotted,label="git\nsubmodule\nreference"];
165 reponamesm [label="reponame.git"];
167 //Example Release document index that references component info provided in other project repo
168 release -> releasedocumentindex;
169 releasedocumentindex [label="index.rst", shape=box];
170 releasedocumentindex -> releaserepolist [style=dashed, label="sphinx\ntoctree\nreference"];
171 releaserepolist [label="repolist.rst", shape=box];
172 release -> releaserepolist;
173 releaserepolist -> repnamedocsdirindex [style=dashed, label="sphinx\ntoctree\nreference"];
177 Creating Restructured Text
178 ==========================
180 TODO Add simple example and references here
184 It's pretty common to want to reference another location in the
185 ONAP documentation and it's pretty easy to do with
186 reStructuredText. This is a quick primer, more information is in the
187 `Sphinx section on Cross-referencing arbitrary locations
188 <http://www.sphinx-doc.org/en/stable/markup/inline.html#ref-role>`_.
190 Within a single document, you can reference another section simply by::
192 This is a reference to `The title of a section`_
194 Assuming that somewhere else in the same file there a is a section
195 title something like::
197 The title of a section
198 ^^^^^^^^^^^^^^^^^^^^^^
200 It's typically better to use ``:ref:`` syntax and labels to provide
201 links as they work across files and are resilient to sections being
202 renamed. First, you need to create a label something like::
206 The title of a section
207 ^^^^^^^^^^^^^^^^^^^^^^
209 .. note:: The underscore (_) before the label is required.
211 Then you can reference the section anywhere by simply doing::
213 This is a reference to :ref:`a-label`
217 This is a reference to :ref:`a section I really liked <a-label>`
219 .. note:: When using ``:ref:``-style links, you don't need a trailing
222 Because the labels have to be unique, it usually makes sense to prefix
223 the labels with the project name to help share the label space, e.g.,
224 ``sfc-user-guide`` instead of just ``user-guide``.
231 It is recommended that all rst content is validated by `doc8 <https://pypi.python.org/pypi/doc8>`_ standards.
232 To validate your rst files using doc8, install doc8.
236 sudo pip install doc8
238 doc8 can now be used to check the rst files. Execute as,
242 doc8 --ignore D000,D001 <file>
248 To test how the documentation renders in HTML, follow these steps:
250 Install virtual environment.
254 sudo pip install virtualenv
255 cd /local/repo/path/to/project
257 Download the doc repository.
261 git clone http://gerrit.onap.org/r/doc
263 Change directory to doc & install requirements.
268 sudo pip install -r etc/requirements.txt
270 Move the conf.py file to your project folder where RST files have been kept:
274 mv doc/docs/conf.py <path-to-your-folder>/
276 Move the static files to your project folder:
280 mv docs/_static/ <path-to-your-folder>/
282 Build the documentation from within your project folder:
286 sphinx-build -b html <path-to-your-folder> <path-to-output-folder>
288 Your documentation shall be built as HTML inside the
289 specified output folder directory.
291 .. 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.
296 To build the whole documentation under doc/, follow these steps:
298 Install virtual environment.
302 sudo pip install virtualenv
303 cd /local/repo/path/to/project
305 Download the DOC repository.
309 git clone http://gerrit.onap.org/r/doc
311 Change directory to docs & install requirements.
316 sudo pip install -r etc/requirements.txt
318 Update submodules, build documentation using tox & then open using any browser.
323 git submodule update --init
325 firefox docs/_build/html/index.html
327 .. note:: Make sure to run `tox -edocs` and not just `tox`.