blob: 9052090bd6b42bf079a8e0fbc78f63910b59a235 [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 ===
Rich Bennetta9d6a442017-08-25 02:37:15 -040028 DA -> DR [label = "Add new project repo as\ngit submodule" ];
Rich Bennett358472a2017-08-31 08:05:36 -040029 DA <-- DR [label = "Merge" ];
30 PA -> PR [label = "Create in new project repo\ntop level directory and index.rst" ];
31 PR -> DA [label = "Add as Reviewer" ];
32 PR <-- DA [label = "Approve and Integrate" ];
33 PA <-- PR [label = "Merge" ];
Rich Bennett1da30462017-08-24 12:11:36 -040034 }
35
36
Rich Bennettac93e0e2017-07-19 01:36:52 -040037
Rich Bennett1da30462017-08-24 12:11:36 -040038Setup doc project
39-----------------
40These steps are performed only once for the doc project and include:
Rich Bennettac93e0e2017-07-19 01:36:52 -040041
Rich Bennett1da30462017-08-24 12:11:36 -040042(1) creating in the doc repository an initial:
43 - sphinx master document index
Rich Bennetta9d6a442017-08-25 02:37:15 -040044 - a directory structure aligned with the document structure
45 - tests performed in jenkins verify jobs
46 - sphinx configuration
Rich Bennett1da30462017-08-24 12:11:36 -040047
Rich Bennetta9d6a442017-08-25 02:37:15 -040048(2) establishing an account at readthedocs connected with the doc
49doc project repo in gerrit.onap.org.
Rich Bennett1da30462017-08-24 12:11:36 -040050
51
Rich Bennetta9d6a442017-08-25 02:37:15 -040052Setup new project repositories(s)
53---------------------------------
Rich Bennett1da30462017-08-24 12:11:36 -040054These steps are performed for each new project repo (referred to in the
Rich Bennetta9d6a442017-08-25 02:37:15 -040055next two code blocks as $reponame):
Rich Bennett1da30462017-08-24 12:11:36 -040056
Rich Bennett358472a2017-08-31 08:05:36 -040057(1) clone, modify, and commit to the doc project: a directory under doc/docs/submodules with the same path/name as the new project initialized as a git submodule.
58
59.. code-block:: bash
60
61 reponame=<your_repo_name>
62
63 git clone ssh://<your_id>@gerrit.onap.org:29418/doc
64 cd doc
65 mkdir -p `dirname docs/submodules/$reponame`
66 git submodule add https://gerrit.onap.org/r/$reponame docs/submodules/$reponame
67 git submodule init docs/submodules/$reponame
68 git submodule update docs/submodules/$reponame
69
70 echo " $reponame <../submodules/$reponame/docs/index>" >> docs/release/repolist.rst
71
72 git add .
73 git commit -m "Add $reponame as a submodule" -s
74 git commit --amend
75 # modify the commit message to comply with ONAP best practices
76 git review
77
78
79
80(2) clone, modify, and commit to the new project an initial: docs top
Rich Bennett1da30462017-08-24 12:11:36 -040081level directory; index.rst; any other intial content.
82
83.. code-block:: bash
84
Rich Bennetta9d6a442017-08-25 02:37:15 -040085 git clone ssh://<your_id>@gerrit.onap.org:29418/$reponame
86 cd $reponame
Rich Bennett1da30462017-08-24 12:11:36 -040087 mkdir docs
88 echo ".. This work is licensed under a Creative Commons Attribution 4.0 International License.
89
Rich Bennetta9d6a442017-08-25 02:37:15 -040090 TODO Add files to toctree and delete this header
91 ------------------------------------------------
Rich Bennett1da30462017-08-24 12:11:36 -040092 .. toctree::
93 :maxdepth: 1
94
95 " > docs/index.rst
96
97 git add .
98 git commit -m "Add RST docs directory and index" -s
99 git commit --amend
100 # modify the commit message to comply with ONAP best practices
101 git review
102
Rich Bennettac93e0e2017-07-19 01:36:52 -0400103
Rich Bennett1da30462017-08-24 12:11:36 -0400104The diagram below illustrates what is accomplished in the setup steps
Rich Bennetta9d6a442017-08-25 02:37:15 -0400105above from the perspective of a file structure created for a local test,
Rich Bennett358472a2017-08-31 08:05:36 -0400106a jenkins verify job, and/or published release documentation including:
Rich Bennettac93e0e2017-07-19 01:36:52 -0400107
Rich Bennettac93e0e2017-07-19 01:36:52 -0400108 - all ONAP gerrit project repositories,
Rich Bennetta9d6a442017-08-25 02:37:15 -0400109 - the doc project repository master document index.rst, templates, configuration
Rich Bennett1da30462017-08-24 12:11:36 -0400110 - the submodules directory where other project repositories and directories/files may be referenced
Rich Bennettac93e0e2017-07-19 01:36:52 -0400111
112
113.. graphviz::
114
115
116 digraph docstructure {
117 size="8,12";
118 node [fontname = "helvetica"];
119 // Align gerrit repos and docs directories
Rich Bennetta9d6a442017-08-25 02:37:15 -0400120 {rank=same doc aaf aai reponame repoelipse vnfsdk vvp}
Rich Bennett1da30462017-08-24 12:11:36 -0400121 {rank=same confpy release templates masterindex submodules otherdocdocumentelipse}
Rich Bennett358472a2017-08-31 08:05:36 -0400122 {rank=same releasedocumentindex releaserepolist}
Rich Bennettac93e0e2017-07-19 01:36:52 -0400123
124 //Illustrate Gerrit Repos and provide URL/Link for complete repo list
125 gerrit [label="gerrit.onap.org/r", href="https://gerrit.onap.org/r/#/admin/projects/" ];
Rich Bennett358472a2017-08-31 08:05:36 -0400126 doc [href="https://gerrit.onap.org/r/gitweb?p=doc.git;a=tree"];
Rich Bennettac93e0e2017-07-19 01:36:52 -0400127 gerrit -> doc;
128 gerrit -> aaf;
129 gerrit -> aai;
Rich Bennetta9d6a442017-08-25 02:37:15 -0400130 gerrit -> reponame;
Rich Bennett1da30462017-08-24 12:11:36 -0400131 gerrit -> repoelipse;
132 repoelipse [label=". . . ."];
Rich Bennettac93e0e2017-07-19 01:36:52 -0400133 gerrit -> vnfsdk;
134 gerrit -> vvp;
135
Rich Bennetta9d6a442017-08-25 02:37:15 -0400136 //Show example of local reponame instance of component info
137 reponame -> reponamedocsdir;
138 reponamesm -> reponamedocsdir;
139 reponamedocsdir [label="docs"];
140 reponamedocsdir -> newrepodocsdirindex;
Rich Bennett1da30462017-08-24 12:11:36 -0400141 newrepodocsdirindex [label="index.rst", shape=box];
Rich Bennettac93e0e2017-07-19 01:36:52 -0400142
Rich Bennett1da30462017-08-24 12:11:36 -0400143 //Show detail structure of a portion of doc/docs
Rich Bennettac93e0e2017-07-19 01:36:52 -0400144 doc -> docs;
Rich Bennett1da30462017-08-24 12:11:36 -0400145 docs -> confpy;
146 confpy [label="conf.py",shape=box];
147 docs -> masterindex;
Rich Bennett358472a2017-08-31 08:05:36 -0400148 masterindex [label="Master\nindex.rst", shape=box];
Rich Bennettac93e0e2017-07-19 01:36:52 -0400149 docs -> release;
Rich Bennett1da30462017-08-24 12:11:36 -0400150 docs -> templates;
151 docs -> otherdocdocumentelipse;
152 otherdocdocumentelipse [label="...other\ndocuments"];
Rich Bennettac93e0e2017-07-19 01:36:52 -0400153 docs -> submodules
Rich Bennett1da30462017-08-24 12:11:36 -0400154
155 masterindex -> releasedocumentindex [style=dashed, label="sphinx\ntoctree\nreference"];
156
157 //Show submodule linkage to docs directory
Rich Bennetta9d6a442017-08-25 02:37:15 -0400158 submodules -> reponamesm [style=dotted,label="git\nsubmodule\nreference"];
159 reponamesm [label="reponame"];
Rich Bennettac93e0e2017-07-19 01:36:52 -0400160
Rich Bennett1da30462017-08-24 12:11:36 -0400161 //Example Release document index that references component info provided in other project repo
162 release -> releasedocumentindex;
163 releasedocumentindex [label="index.rst", shape=box];
Rich Bennett358472a2017-08-31 08:05:36 -0400164 releasedocumentindex -> releaserepolist [style=dashed, label="sphinx\ntoctree\nreference"];
165 releaserepolist [label="repolist.rst", shape=box];
166 release -> releaserepolist;
167 releaserepolist -> newrepodocsdirindex [style=dashed, label="sphinx\ntoctree\nreference"];
Rich Bennett1da30462017-08-24 12:11:36 -0400168
Rich Bennettac93e0e2017-07-19 01:36:52 -0400169 }
170
Rich Bennetta9d6a442017-08-25 02:37:15 -0400171Creating Restructured Text
172==========================
Rich Bennettac93e0e2017-07-19 01:36:52 -0400173
Rich Bennetta9d6a442017-08-25 02:37:15 -0400174TODO Add simple example and references here
Rich Bennettac93e0e2017-07-19 01:36:52 -0400175
Rich Bennetta9d6a442017-08-25 02:37:15 -0400176Links and References
177====================
Rich Bennettac93e0e2017-07-19 01:36:52 -0400178It's pretty common to want to reference another location in the
179ONAP documentation and it's pretty easy to do with
180reStructuredText. This is a quick primer, more information is in the
181`Sphinx section on Cross-referencing arbitrary locations
182<http://www.sphinx-doc.org/en/stable/markup/inline.html#ref-role>`_.
183
184Within a single document, you can reference another section simply by::
185
186 This is a reference to `The title of a section`_
187
188Assuming that somewhere else in the same file there a is a section
189title something like::
190
191 The title of a section
192 ^^^^^^^^^^^^^^^^^^^^^^
193
194It's typically better to use ``:ref:`` syntax and labels to provide
195links as they work across files and are resilient to sections being
196renamed. First, you need to create a label something like::
197
198 .. _a-label:
199
200 The title of a section
201 ^^^^^^^^^^^^^^^^^^^^^^
202
203.. note:: The underscore (_) before the label is required.
204
205Then you can reference the section anywhere by simply doing::
206
207 This is a reference to :ref:`a-label`
208
209or::
210
211 This is a reference to :ref:`a section I really liked <a-label>`
212
213.. note:: When using ``:ref:``-style links, you don't need a trailing
214 underscore (_).
215
216Because the labels have to be unique, it usually makes sense to prefix
217the labels with the project name to help share the label space, e.g.,
218``sfc-user-guide`` instead of just ``user-guide``.
219
Rich Bennetta9d6a442017-08-25 02:37:15 -0400220Testing
221=======
Rich Bennettac93e0e2017-07-19 01:36:52 -0400222
Rich Bennetta9d6a442017-08-25 02:37:15 -0400223One RST File
224------------
Rich Bennettac93e0e2017-07-19 01:36:52 -0400225It is recommended that all rst content is validated by `doc8 <https://pypi.python.org/pypi/doc8>`_ standards.
226To validate your rst files using doc8, install doc8.
227
228.. code-block:: bash
229
230 sudo pip install doc8
231
232doc8 can now be used to check the rst files. Execute as,
233
234.. code-block:: bash
235
236 doc8 --ignore D000,D001 <file>
237
238
Rich Bennettac93e0e2017-07-19 01:36:52 -0400239
Rich Bennetta9d6a442017-08-25 02:37:15 -0400240One Project
241-----------
Rich Bennettac93e0e2017-07-19 01:36:52 -0400242To test how the documentation renders in HTML, follow these steps:
243
244Install virtual environment.
245
246.. code-block:: bash
247
248 sudo pip install virtualenv
249 cd /local/repo/path/to/project
250
251Download the doc repository.
252
253.. code-block:: bash
254
255 git clone http://gerrit.onap.org/r/doc
256
257Change directory to doc & install requirements.
258
259.. code-block:: bash
260
261 cd doc
262 sudo pip install -r etc/requirements.txt
263
264Move the conf.py file to your project folder where RST files have been kept:
265
266.. code-block:: bash
267
268 mv doc/docs/conf.py <path-to-your-folder>/
269
270Move the static files to your project folder:
271
272.. code-block:: bash
273
274 mv docs/_static/ <path-to-your-folder>/
275
276Build the documentation from within your project folder:
277
278.. code-block:: bash
279
280 sphinx-build -b html <path-to-your-folder> <path-to-output-folder>
281
282Your documentation shall be built as HTML inside the
283specified output folder directory.
284
285.. 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.
286
287
Rich Bennetta9d6a442017-08-25 02:37:15 -0400288All Documentation
289-----------------
290To build the whole documentation under doc/, follow these steps:
Rich Bennettac93e0e2017-07-19 01:36:52 -0400291
Rich Bennetta9d6a442017-08-25 02:37:15 -0400292Install virtual environment.
Rich Bennettac93e0e2017-07-19 01:36:52 -0400293
294.. code-block:: bash
295
Rich Bennetta9d6a442017-08-25 02:37:15 -0400296 sudo pip install virtualenv
297 cd /local/repo/path/to/project
298
299Download the DOC repository.
300
301.. code-block:: bash
302
303 git clone http://gerrit.onap.org/r/doc
304
305Change directory to docs & install requirements.
306
307.. code-block:: bash
308
309 cd doc
310 sudo pip install -r etc/requirements.txt
311
312Update submodules, build documentation using tox & then open using any browser.
313
314.. code-block:: bash
315
316 cd doc
317 git submodule update --init
318 tox -edocs
319 firefox docs/_build/html/index.html
320
321.. note:: Make sure to run `tox -edocs` and not just `tox`.
322
Rich Bennett1da30462017-08-24 12:11:36 -0400323
324