Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 1 | .. This work is licensed under a Creative Commons Attribution 4.0 International License. |
| 2 | |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 3 | |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 4 | Setting Up |
| 5 | ========== |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 6 | Some initial set up is required to connect a project with |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 7 | the master document structure and enable automated publishing of |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 8 | changes as summarized in the following diagram and description below |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 9 | below. |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 10 | |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 11 | .. seqdiag:: |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 12 | :height: 700 |
| 13 | :width: 1000 |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 14 | |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 15 | 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 Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 23 | RD -> DA [label = "Acquire Account" ]; |
| 24 | DA -> DR [label = "Create initial\n doc repository content"]; |
| 25 | DA <<-- DR [label = "Merge" ]; |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 26 | RD <-- DA [label = "Connect gerrit.onap.org" ]; |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 27 | === 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 Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 36 | |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 37 | Setup doc project |
| 38 | ----------------- |
| 39 | These steps are performed only once for the doc project and include: |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 40 | |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 41 | (1) creating in the doc repository an initial: |
| 42 | - sphinx master document index |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 43 | - a directory structure aligned with the document structure |
| 44 | - tests performed in jenkins verify jobs |
| 45 | - sphinx configuration |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 46 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 47 | (2) establishing an account at readthedocs connected with the doc |
| 48 | doc project repo in gerrit.onap.org. |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 49 | |
| 50 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 51 | Setup new project repositories(s) |
| 52 | --------------------------------- |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 53 | These steps are performed for each new project repo (referred to in the |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 54 | next two code blocks as $reponame): |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 55 | |
| 56 | (1) clone, modify, and commit to the other project an initial: docs top |
| 57 | level directory; index.rst; any other intial content. |
| 58 | |
| 59 | .. code-block:: bash |
| 60 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 61 | reponame=test |
| 62 | git clone ssh://<your_id>@gerrit.onap.org:29418/$reponame |
| 63 | cd $reponame |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 64 | mkdir docs |
| 65 | echo ".. This work is licensed under a Creative Commons Attribution 4.0 International License. |
| 66 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 67 | TODO Add files to toctree and delete this header |
| 68 | ------------------------------------------------ |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 69 | .. 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 | |
| 80 | When the above commit is reviewed and merged complete step 2 before any |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 81 | new changes are merged into $reponame. |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 82 | |
| 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 Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 85 | .. code-block:: bash |
| 86 | |
| 87 | git clone ssh://<your_id>@gerrit.onap.org:29418/doc |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 88 | # 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 Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 92 | echo " $reponame <../submodules/$reponame/docs/index>" >> docs/release/repolist.rst |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 93 | |
| 94 | git submodule git https://gerrit.onap.org/r/$reponame |
| 95 | git submodule init $reponame/ |
| 96 | git submodule update $reponame/ |
| 97 | |
| 98 | |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 99 | git add . |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 100 | git commit -m "Add $reponame as a submodule" -s |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 101 | git commit --amend |
| 102 | # modify the commit message to comply with ONAP best practices |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 103 | git review |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 104 | |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 105 | |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 106 | |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 107 | The diagram below illustrates what is accomplished in the setup steps |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 108 | above from the perspective of a file structure created for a local test, |
| 109 | a jenkins verify job, and/or publish release documentation including: |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 110 | |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 111 | - all ONAP gerrit project repositories, |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 112 | - the doc project repository master document index.rst, templates, configuration |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 113 | - the submodules directory where other project repositories and directories/files may be referenced |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 114 | |
| 115 | |
| 116 | .. graphviz:: |
| 117 | |
| 118 | |
| 119 | digraph docstructure { |
| 120 | size="8,12"; |
| 121 | node [fontname = "helvetica"]; |
| 122 | // Align gerrit repos and docs directories |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 123 | {rank=same doc aaf aai reponame repoelipse vnfsdk vvp} |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 124 | {rank=same confpy release templates masterindex submodules otherdocdocumentelipse} |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 125 | |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 126 | |
| 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 Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 132 | gerrit -> reponame; |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 133 | gerrit -> repoelipse; |
| 134 | repoelipse [label=". . . ."]; |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 135 | gerrit -> vnfsdk; |
| 136 | gerrit -> vvp; |
| 137 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 138 | //Show example of local reponame instance of component info |
| 139 | reponame -> reponamedocsdir; |
| 140 | reponamesm -> reponamedocsdir; |
| 141 | reponamedocsdir [label="docs"]; |
| 142 | reponamedocsdir -> newrepodocsdirindex; |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 143 | newrepodocsdirindex [label="index.rst", shape=box]; |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 144 | |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 145 | //Show detail structure of a portion of doc/docs |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 146 | doc -> docs; |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 147 | docs -> confpy; |
| 148 | confpy [label="conf.py",shape=box]; |
| 149 | docs -> masterindex; |
| 150 | masterindex [label="Master index.rst", shape=box]; |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 151 | docs -> release; |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 152 | docs -> templates; |
| 153 | docs -> otherdocdocumentelipse; |
| 154 | otherdocdocumentelipse [label="...other\ndocuments"]; |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 155 | docs -> submodules |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 156 | |
| 157 | masterindex -> releasedocumentindex [style=dashed, label="sphinx\ntoctree\nreference"]; |
| 158 | |
| 159 | //Show submodule linkage to docs directory |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 160 | submodules -> reponamesm [style=dotted,label="git\nsubmodule\nreference"]; |
| 161 | reponamesm [label="reponame"]; |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 162 | |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 163 | //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 Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 168 | } |
| 169 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 170 | Creating Restructured Text |
| 171 | ========================== |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 172 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 173 | TODO Add simple example and references here |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 174 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 175 | Links and References |
| 176 | ==================== |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 177 | It's pretty common to want to reference another location in the |
| 178 | ONAP documentation and it's pretty easy to do with |
| 179 | reStructuredText. 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 | |
| 183 | Within a single document, you can reference another section simply by:: |
| 184 | |
| 185 | This is a reference to `The title of a section`_ |
| 186 | |
| 187 | Assuming that somewhere else in the same file there a is a section |
| 188 | title something like:: |
| 189 | |
| 190 | The title of a section |
| 191 | ^^^^^^^^^^^^^^^^^^^^^^ |
| 192 | |
| 193 | It's typically better to use ``:ref:`` syntax and labels to provide |
| 194 | links as they work across files and are resilient to sections being |
| 195 | renamed. 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 | |
| 204 | Then you can reference the section anywhere by simply doing:: |
| 205 | |
| 206 | This is a reference to :ref:`a-label` |
| 207 | |
| 208 | or:: |
| 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 | |
| 215 | Because the labels have to be unique, it usually makes sense to prefix |
| 216 | the labels with the project name to help share the label space, e.g., |
| 217 | ``sfc-user-guide`` instead of just ``user-guide``. |
| 218 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 219 | Testing |
| 220 | ======= |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 221 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 222 | One RST File |
| 223 | ------------ |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 224 | It is recommended that all rst content is validated by `doc8 <https://pypi.python.org/pypi/doc8>`_ standards. |
| 225 | To validate your rst files using doc8, install doc8. |
| 226 | |
| 227 | .. code-block:: bash |
| 228 | |
| 229 | sudo pip install doc8 |
| 230 | |
| 231 | doc8 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 Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 238 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 239 | One Project |
| 240 | ----------- |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 241 | To test how the documentation renders in HTML, follow these steps: |
| 242 | |
| 243 | Install virtual environment. |
| 244 | |
| 245 | .. code-block:: bash |
| 246 | |
| 247 | sudo pip install virtualenv |
| 248 | cd /local/repo/path/to/project |
| 249 | |
| 250 | Download the doc repository. |
| 251 | |
| 252 | .. code-block:: bash |
| 253 | |
| 254 | git clone http://gerrit.onap.org/r/doc |
| 255 | |
| 256 | Change directory to doc & install requirements. |
| 257 | |
| 258 | .. code-block:: bash |
| 259 | |
| 260 | cd doc |
| 261 | sudo pip install -r etc/requirements.txt |
| 262 | |
| 263 | Move 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 | |
| 269 | Move the static files to your project folder: |
| 270 | |
| 271 | .. code-block:: bash |
| 272 | |
| 273 | mv docs/_static/ <path-to-your-folder>/ |
| 274 | |
| 275 | Build 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 | |
| 281 | Your documentation shall be built as HTML inside the |
| 282 | specified 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 Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 287 | All Documentation |
| 288 | ----------------- |
| 289 | To build the whole documentation under doc/, follow these steps: |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 290 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 291 | Install virtual environment. |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 292 | |
| 293 | .. code-block:: bash |
| 294 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 295 | sudo pip install virtualenv |
| 296 | cd /local/repo/path/to/project |
| 297 | |
| 298 | Download the DOC repository. |
| 299 | |
| 300 | .. code-block:: bash |
| 301 | |
| 302 | git clone http://gerrit.onap.org/r/doc |
| 303 | |
| 304 | Change directory to docs & install requirements. |
| 305 | |
| 306 | .. code-block:: bash |
| 307 | |
| 308 | cd doc |
| 309 | sudo pip install -r etc/requirements.txt |
| 310 | |
| 311 | Update 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 Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 322 | |
| 323 | |