blob: b0d4b95484788162edc19b6360292720f8038a17 [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
Rich Bennettac93e0e2017-07-19 01:36:52 -04003
Rich Bennett1da30462017-08-24 12:11:36 -04004Setting Up
5==========
Rich Bennetta9d6a442017-08-25 02:37:15 -04006Some initial set up is required to connect a project with
Rich Bennett1da30462017-08-24 12:11:36 -04007the master document structure and enable automated publishing of
Rich Bennetta9d6a442017-08-25 02:37:15 -04008changes as summarized in the following diagram and description below
Rich Bennett1da30462017-08-24 12:11:36 -04009below.
Rich Bennettac93e0e2017-07-19 01:36:52 -040010
Rich Bennett1da30462017-08-24 12:11:36 -040011.. seqdiag::
Rich Bennetta9d6a442017-08-25 02:37:15 -040012 :height: 700
13 :width: 1000
Rich Bennettac93e0e2017-07-19 01:36:52 -040014
Rich Bennett1da30462017-08-24 12:11:36 -040015 seqdiag {
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];
21
22 === One time setup doc project only ===
Rich Bennetta9d6a442017-08-25 02:37:15 -040023 RD -> DA [label = "Acquire Account" ];
24 DA -> DR [label = "Create initial\n doc repository content"];
25 DA <<-- DR [label = "Merge" ];
Rich Bennett1da30462017-08-24 12:11:36 -040026 RD <-- DA [label = "Connect gerrit.onap.org" ];
Rich Bennetta9d6a442017-08-25 02:37:15 -040027 === For each new project repository containing document source ===
28 DA -> PR [label = "Create in new project repo\ntop level directory and index.rst" ];
29 PR <-- PA [label = "Review/Approve" ];
30 DA <-- PR [label = "Merge" ];
31 DA -> DR [label = "Add new project repo as\ngit submodule" ];
32 DA <-- DR [label = "Merge" ];
Rich Bennett1da30462017-08-24 12:11:36 -040033 }
34
35
Rich Bennettac93e0e2017-07-19 01:36:52 -040036
Rich Bennett1da30462017-08-24 12:11:36 -040037Setup doc project
38-----------------
39These steps are performed only once for the doc project and include:
Rich Bennettac93e0e2017-07-19 01:36:52 -040040
Rich Bennett1da30462017-08-24 12:11:36 -040041(1) creating in the doc repository an initial:
42 - sphinx master document index
Rich Bennetta9d6a442017-08-25 02:37:15 -040043 - a directory structure aligned with the document structure
44 - tests performed in jenkins verify jobs
45 - sphinx configuration
Rich Bennett1da30462017-08-24 12:11:36 -040046
Rich Bennetta9d6a442017-08-25 02:37:15 -040047(2) establishing an account at readthedocs connected with the doc
48doc project repo in gerrit.onap.org.
Rich Bennett1da30462017-08-24 12:11:36 -040049
50
Rich Bennetta9d6a442017-08-25 02:37:15 -040051Setup new project repositories(s)
52---------------------------------
Rich Bennett1da30462017-08-24 12:11:36 -040053These steps are performed for each new project repo (referred to in the
Rich Bennetta9d6a442017-08-25 02:37:15 -040054next two code blocks as $reponame):
Rich Bennett1da30462017-08-24 12:11:36 -040055
56(1) clone, modify, and commit to the other project an initial: docs top
57level directory; index.rst; any other intial content.
58
59.. code-block:: bash
60
Rich Bennetta9d6a442017-08-25 02:37:15 -040061 reponame=test
62 git clone ssh://<your_id>@gerrit.onap.org:29418/$reponame
63 cd $reponame
Rich Bennett1da30462017-08-24 12:11:36 -040064 mkdir docs
65 echo ".. This work is licensed under a Creative Commons Attribution 4.0 International License.
66
Rich Bennetta9d6a442017-08-25 02:37:15 -040067 TODO Add files to toctree and delete this header
68 ------------------------------------------------
Rich Bennett1da30462017-08-24 12:11:36 -040069 .. toctree::
70 :maxdepth: 1
71
72 " > docs/index.rst
73
74 git add .
75 git commit -m "Add RST docs directory and index" -s
76 git commit --amend
77 # modify the commit message to comply with ONAP best practices
78 git review
79
80When the above commit is reviewed and merged complete step 2 before any
Rich Bennetta9d6a442017-08-25 02:37:15 -040081new changes are merged into $reponame.
Rich Bennett1da30462017-08-24 12:11:36 -040082
83(2) clone, modify, and commit to the doc project: a directory under doc/docs/submodules with the same path/name as the other project and initialized as a git submodule.
84
Rich Bennettac93e0e2017-07-19 01:36:52 -040085.. code-block:: bash
86
87 git clone ssh://<your_id>@gerrit.onap.org:29418/doc
Rich Bennett1da30462017-08-24 12:11:36 -040088 # For top level repositories use the following
89 mkdir doc/docs/submodules/$reponame
90 # For lower level repositories you may need to make a directory for each node in path
91
Rich Bennetta9d6a442017-08-25 02:37:15 -040092 echo " $reponame <../submodules/$reponame/docs/index>" >> docs/release/repolist.rst
Rich Bennett1da30462017-08-24 12:11:36 -040093
94 git submodule git https://gerrit.onap.org/r/$reponame
95 git submodule init $reponame/
96 git submodule update $reponame/
97
98
Rich Bennettac93e0e2017-07-19 01:36:52 -040099 git add .
Rich Bennetta9d6a442017-08-25 02:37:15 -0400100 git commit -m "Add $reponame as a submodule" -s
Rich Bennett1da30462017-08-24 12:11:36 -0400101 git commit --amend
102 # modify the commit message to comply with ONAP best practices
Rich Bennettac93e0e2017-07-19 01:36:52 -0400103 git review
Rich Bennett1da30462017-08-24 12:11:36 -0400104
Rich Bennettac93e0e2017-07-19 01:36:52 -0400105
Rich Bennettac93e0e2017-07-19 01:36:52 -0400106
Rich Bennett1da30462017-08-24 12:11:36 -0400107The diagram below illustrates what is accomplished in the setup steps
Rich Bennetta9d6a442017-08-25 02:37:15 -0400108above from the perspective of a file structure created for a local test,
109a jenkins verify job, and/or publish release documentation including:
Rich Bennettac93e0e2017-07-19 01:36:52 -0400110
Rich Bennettac93e0e2017-07-19 01:36:52 -0400111 - all ONAP gerrit project repositories,
Rich Bennetta9d6a442017-08-25 02:37:15 -0400112 - the doc project repository master document index.rst, templates, configuration
Rich Bennett1da30462017-08-24 12:11:36 -0400113 - the submodules directory where other project repositories and directories/files may be referenced
Rich Bennettac93e0e2017-07-19 01:36:52 -0400114
115
116.. graphviz::
117
118
119 digraph docstructure {
120 size="8,12";
121 node [fontname = "helvetica"];
122 // Align gerrit repos and docs directories
Rich Bennetta9d6a442017-08-25 02:37:15 -0400123 {rank=same doc aaf aai reponame repoelipse vnfsdk vvp}
Rich Bennett1da30462017-08-24 12:11:36 -0400124 {rank=same confpy release templates masterindex submodules otherdocdocumentelipse}
Rich Bennettac93e0e2017-07-19 01:36:52 -0400125
Rich Bennettac93e0e2017-07-19 01:36:52 -0400126
127 //Illustrate Gerrit Repos and provide URL/Link for complete repo list
128 gerrit [label="gerrit.onap.org/r", href="https://gerrit.onap.org/r/#/admin/projects/" ];
129 gerrit -> doc;
130 gerrit -> aaf;
131 gerrit -> aai;
Rich Bennetta9d6a442017-08-25 02:37:15 -0400132 gerrit -> reponame;
Rich Bennett1da30462017-08-24 12:11:36 -0400133 gerrit -> repoelipse;
134 repoelipse [label=". . . ."];
Rich Bennettac93e0e2017-07-19 01:36:52 -0400135 gerrit -> vnfsdk;
136 gerrit -> vvp;
137
Rich Bennetta9d6a442017-08-25 02:37:15 -0400138 //Show example of local reponame instance of component info
139 reponame -> reponamedocsdir;
140 reponamesm -> reponamedocsdir;
141 reponamedocsdir [label="docs"];
142 reponamedocsdir -> newrepodocsdirindex;
Rich Bennett1da30462017-08-24 12:11:36 -0400143 newrepodocsdirindex [label="index.rst", shape=box];
Rich Bennettac93e0e2017-07-19 01:36:52 -0400144
Rich Bennett1da30462017-08-24 12:11:36 -0400145 //Show detail structure of a portion of doc/docs
Rich Bennettac93e0e2017-07-19 01:36:52 -0400146 doc -> docs;
Rich Bennett1da30462017-08-24 12:11:36 -0400147 docs -> confpy;
148 confpy [label="conf.py",shape=box];
149 docs -> masterindex;
150 masterindex [label="Master index.rst", shape=box];
Rich Bennettac93e0e2017-07-19 01:36:52 -0400151 docs -> release;
Rich Bennett1da30462017-08-24 12:11:36 -0400152 docs -> templates;
153 docs -> otherdocdocumentelipse;
154 otherdocdocumentelipse [label="...other\ndocuments"];
Rich Bennettac93e0e2017-07-19 01:36:52 -0400155 docs -> submodules
Rich Bennett1da30462017-08-24 12:11:36 -0400156
157 masterindex -> releasedocumentindex [style=dashed, label="sphinx\ntoctree\nreference"];
158
159 //Show submodule linkage to docs directory
Rich Bennetta9d6a442017-08-25 02:37:15 -0400160 submodules -> reponamesm [style=dotted,label="git\nsubmodule\nreference"];
161 reponamesm [label="reponame"];
Rich Bennettac93e0e2017-07-19 01:36:52 -0400162
Rich Bennett1da30462017-08-24 12:11:36 -0400163 //Example Release document index that references component info provided in other project repo
164 release -> releasedocumentindex;
165 releasedocumentindex [label="index.rst", shape=box];
166 releasedocumentindex -> newrepodocsdirindex [style=dashed, label="sphinx\ntoctree\nreference"];
167
Rich Bennettac93e0e2017-07-19 01:36:52 -0400168 }
169
Rich Bennetta9d6a442017-08-25 02:37:15 -0400170Creating Restructured Text
171==========================
Rich Bennettac93e0e2017-07-19 01:36:52 -0400172
Rich Bennetta9d6a442017-08-25 02:37:15 -0400173TODO Add simple example and references here
Rich Bennettac93e0e2017-07-19 01:36:52 -0400174
Rich Bennetta9d6a442017-08-25 02:37:15 -0400175Links and References
176====================
Rich Bennettac93e0e2017-07-19 01:36:52 -0400177It's pretty common to want to reference another location in the
178ONAP documentation and it's pretty easy to do with
179reStructuredText. This is a quick primer, more information is in the
180`Sphinx section on Cross-referencing arbitrary locations
181<http://www.sphinx-doc.org/en/stable/markup/inline.html#ref-role>`_.
182
183Within a single document, you can reference another section simply by::
184
185 This is a reference to `The title of a section`_
186
187Assuming that somewhere else in the same file there a is a section
188title something like::
189
190 The title of a section
191 ^^^^^^^^^^^^^^^^^^^^^^
192
193It's typically better to use ``:ref:`` syntax and labels to provide
194links as they work across files and are resilient to sections being
195renamed. First, you need to create a label something like::
196
197 .. _a-label:
198
199 The title of a section
200 ^^^^^^^^^^^^^^^^^^^^^^
201
202.. note:: The underscore (_) before the label is required.
203
204Then you can reference the section anywhere by simply doing::
205
206 This is a reference to :ref:`a-label`
207
208or::
209
210 This is a reference to :ref:`a section I really liked <a-label>`
211
212.. note:: When using ``:ref:``-style links, you don't need a trailing
213 underscore (_).
214
215Because the labels have to be unique, it usually makes sense to prefix
216the labels with the project name to help share the label space, e.g.,
217``sfc-user-guide`` instead of just ``user-guide``.
218
Rich Bennetta9d6a442017-08-25 02:37:15 -0400219Testing
220=======
Rich Bennettac93e0e2017-07-19 01:36:52 -0400221
Rich Bennetta9d6a442017-08-25 02:37:15 -0400222One RST File
223------------
Rich Bennettac93e0e2017-07-19 01:36:52 -0400224It is recommended that all rst content is validated by `doc8 <https://pypi.python.org/pypi/doc8>`_ standards.
225To validate your rst files using doc8, install doc8.
226
227.. code-block:: bash
228
229 sudo pip install doc8
230
231doc8 can now be used to check the rst files. Execute as,
232
233.. code-block:: bash
234
235 doc8 --ignore D000,D001 <file>
236
237
Rich Bennettac93e0e2017-07-19 01:36:52 -0400238
Rich Bennetta9d6a442017-08-25 02:37:15 -0400239One Project
240-----------
Rich Bennettac93e0e2017-07-19 01:36:52 -0400241To test how the documentation renders in HTML, follow these steps:
242
243Install virtual environment.
244
245.. code-block:: bash
246
247 sudo pip install virtualenv
248 cd /local/repo/path/to/project
249
250Download the doc repository.
251
252.. code-block:: bash
253
254 git clone http://gerrit.onap.org/r/doc
255
256Change directory to doc & install requirements.
257
258.. code-block:: bash
259
260 cd doc
261 sudo pip install -r etc/requirements.txt
262
263Move the conf.py file to your project folder where RST files have been kept:
264
265.. code-block:: bash
266
267 mv doc/docs/conf.py <path-to-your-folder>/
268
269Move the static files to your project folder:
270
271.. code-block:: bash
272
273 mv docs/_static/ <path-to-your-folder>/
274
275Build the documentation from within your project folder:
276
277.. code-block:: bash
278
279 sphinx-build -b html <path-to-your-folder> <path-to-output-folder>
280
281Your documentation shall be built as HTML inside the
282specified output folder directory.
283
284.. 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.
285
286
Rich Bennetta9d6a442017-08-25 02:37:15 -0400287All Documentation
288-----------------
289To build the whole documentation under doc/, follow these steps:
Rich Bennettac93e0e2017-07-19 01:36:52 -0400290
Rich Bennetta9d6a442017-08-25 02:37:15 -0400291Install virtual environment.
Rich Bennettac93e0e2017-07-19 01:36:52 -0400292
293.. code-block:: bash
294
Rich Bennetta9d6a442017-08-25 02:37:15 -0400295 sudo pip install virtualenv
296 cd /local/repo/path/to/project
297
298Download the DOC repository.
299
300.. code-block:: bash
301
302 git clone http://gerrit.onap.org/r/doc
303
304Change directory to docs & install requirements.
305
306.. code-block:: bash
307
308 cd doc
309 sudo pip install -r etc/requirements.txt
310
311Update submodules, build documentation using tox & then open using any browser.
312
313.. code-block:: bash
314
315 cd doc
316 git submodule update --init
317 tox -edocs
318 firefox docs/_build/html/index.html
319
320.. note:: Make sure to run `tox -edocs` and not just `tox`.
321
Rich Bennett1da30462017-08-24 12:11:36 -0400322
323