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 === |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 28 | DA -> DR [label = "Add new project repo as\ngit submodule" ]; |
Rich Bennett | 358472a | 2017-08-31 08:05:36 -0400 | [diff] [blame^] | 29 | 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 Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 37 | |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 38 | Setup doc project |
| 39 | ----------------- |
| 40 | These steps are performed only once for the doc project and include: |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 41 | |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 42 | (1) creating in the doc repository an initial: |
| 43 | - sphinx master document index |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 44 | - a directory structure aligned with the document structure |
| 45 | - tests performed in jenkins verify jobs |
| 46 | - sphinx configuration |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 47 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 48 | (2) establishing an account at readthedocs connected with the doc |
| 49 | doc project repo in gerrit.onap.org. |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 50 | |
| 51 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 52 | Setup new project repositories(s) |
| 53 | --------------------------------- |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 54 | 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] | 55 | next two code blocks as $reponame): |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 56 | |
Rich Bennett | 358472a | 2017-08-31 08:05:36 -0400 | [diff] [blame^] | 57 | (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 Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 81 | level directory; index.rst; any other intial content. |
| 82 | |
| 83 | .. code-block:: bash |
| 84 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 85 | git clone ssh://<your_id>@gerrit.onap.org:29418/$reponame |
| 86 | cd $reponame |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 87 | mkdir docs |
| 88 | echo ".. This work is licensed under a Creative Commons Attribution 4.0 International License. |
| 89 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 90 | TODO Add files to toctree and delete this header |
| 91 | ------------------------------------------------ |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 92 | .. 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 Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 103 | |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 104 | The diagram below illustrates what is accomplished in the setup steps |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 105 | above from the perspective of a file structure created for a local test, |
Rich Bennett | 358472a | 2017-08-31 08:05:36 -0400 | [diff] [blame^] | 106 | a jenkins verify job, and/or published release documentation including: |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 107 | |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 108 | - all ONAP gerrit project repositories, |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 109 | - the doc project repository master document index.rst, templates, configuration |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 110 | - 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] | 111 | |
| 112 | |
| 113 | .. graphviz:: |
| 114 | |
| 115 | |
| 116 | digraph docstructure { |
| 117 | size="8,12"; |
| 118 | node [fontname = "helvetica"]; |
| 119 | // Align gerrit repos and docs directories |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 120 | {rank=same doc aaf aai reponame repoelipse vnfsdk vvp} |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 121 | {rank=same confpy release templates masterindex submodules otherdocdocumentelipse} |
Rich Bennett | 358472a | 2017-08-31 08:05:36 -0400 | [diff] [blame^] | 122 | {rank=same releasedocumentindex releaserepolist} |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 123 | |
| 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 Bennett | 358472a | 2017-08-31 08:05:36 -0400 | [diff] [blame^] | 126 | doc [href="https://gerrit.onap.org/r/gitweb?p=doc.git;a=tree"]; |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 127 | gerrit -> doc; |
| 128 | gerrit -> aaf; |
| 129 | gerrit -> aai; |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 130 | gerrit -> reponame; |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 131 | gerrit -> repoelipse; |
| 132 | repoelipse [label=". . . ."]; |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 133 | gerrit -> vnfsdk; |
| 134 | gerrit -> vvp; |
| 135 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 136 | //Show example of local reponame instance of component info |
| 137 | reponame -> reponamedocsdir; |
| 138 | reponamesm -> reponamedocsdir; |
| 139 | reponamedocsdir [label="docs"]; |
| 140 | reponamedocsdir -> newrepodocsdirindex; |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 141 | newrepodocsdirindex [label="index.rst", shape=box]; |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 142 | |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 143 | //Show detail structure of a portion of doc/docs |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 144 | doc -> docs; |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 145 | docs -> confpy; |
| 146 | confpy [label="conf.py",shape=box]; |
| 147 | docs -> masterindex; |
Rich Bennett | 358472a | 2017-08-31 08:05:36 -0400 | [diff] [blame^] | 148 | masterindex [label="Master\nindex.rst", shape=box]; |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 149 | docs -> release; |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 150 | docs -> templates; |
| 151 | docs -> otherdocdocumentelipse; |
| 152 | otherdocdocumentelipse [label="...other\ndocuments"]; |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 153 | docs -> submodules |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 154 | |
| 155 | masterindex -> releasedocumentindex [style=dashed, label="sphinx\ntoctree\nreference"]; |
| 156 | |
| 157 | //Show submodule linkage to docs directory |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 158 | submodules -> reponamesm [style=dotted,label="git\nsubmodule\nreference"]; |
| 159 | reponamesm [label="reponame"]; |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 160 | |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 161 | //Example Release document index that references component info provided in other project repo |
| 162 | release -> releasedocumentindex; |
| 163 | releasedocumentindex [label="index.rst", shape=box]; |
Rich Bennett | 358472a | 2017-08-31 08:05:36 -0400 | [diff] [blame^] | 164 | 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 Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 168 | |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 169 | } |
| 170 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 171 | Creating Restructured Text |
| 172 | ========================== |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 173 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 174 | TODO Add simple example and references here |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 175 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 176 | Links and References |
| 177 | ==================== |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 178 | It's pretty common to want to reference another location in the |
| 179 | ONAP documentation and it's pretty easy to do with |
| 180 | reStructuredText. 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 | |
| 184 | Within a single document, you can reference another section simply by:: |
| 185 | |
| 186 | This is a reference to `The title of a section`_ |
| 187 | |
| 188 | Assuming that somewhere else in the same file there a is a section |
| 189 | title something like:: |
| 190 | |
| 191 | The title of a section |
| 192 | ^^^^^^^^^^^^^^^^^^^^^^ |
| 193 | |
| 194 | It's typically better to use ``:ref:`` syntax and labels to provide |
| 195 | links as they work across files and are resilient to sections being |
| 196 | renamed. 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 | |
| 205 | Then you can reference the section anywhere by simply doing:: |
| 206 | |
| 207 | This is a reference to :ref:`a-label` |
| 208 | |
| 209 | or:: |
| 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 | |
| 216 | Because the labels have to be unique, it usually makes sense to prefix |
| 217 | the labels with the project name to help share the label space, e.g., |
| 218 | ``sfc-user-guide`` instead of just ``user-guide``. |
| 219 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 220 | Testing |
| 221 | ======= |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 222 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 223 | One RST File |
| 224 | ------------ |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 225 | It is recommended that all rst content is validated by `doc8 <https://pypi.python.org/pypi/doc8>`_ standards. |
| 226 | To validate your rst files using doc8, install doc8. |
| 227 | |
| 228 | .. code-block:: bash |
| 229 | |
| 230 | sudo pip install doc8 |
| 231 | |
| 232 | doc8 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 Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 239 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 240 | One Project |
| 241 | ----------- |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 242 | To test how the documentation renders in HTML, follow these steps: |
| 243 | |
| 244 | Install virtual environment. |
| 245 | |
| 246 | .. code-block:: bash |
| 247 | |
| 248 | sudo pip install virtualenv |
| 249 | cd /local/repo/path/to/project |
| 250 | |
| 251 | Download the doc repository. |
| 252 | |
| 253 | .. code-block:: bash |
| 254 | |
| 255 | git clone http://gerrit.onap.org/r/doc |
| 256 | |
| 257 | Change directory to doc & install requirements. |
| 258 | |
| 259 | .. code-block:: bash |
| 260 | |
| 261 | cd doc |
| 262 | sudo pip install -r etc/requirements.txt |
| 263 | |
| 264 | Move 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 | |
| 270 | Move the static files to your project folder: |
| 271 | |
| 272 | .. code-block:: bash |
| 273 | |
| 274 | mv docs/_static/ <path-to-your-folder>/ |
| 275 | |
| 276 | Build 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 | |
| 282 | Your documentation shall be built as HTML inside the |
| 283 | specified 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 Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 288 | All Documentation |
| 289 | ----------------- |
| 290 | To build the whole documentation under doc/, follow these steps: |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 291 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 292 | Install virtual environment. |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 293 | |
| 294 | .. code-block:: bash |
| 295 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 296 | sudo pip install virtualenv |
| 297 | cd /local/repo/path/to/project |
| 298 | |
| 299 | Download the DOC repository. |
| 300 | |
| 301 | .. code-block:: bash |
| 302 | |
| 303 | git clone http://gerrit.onap.org/r/doc |
| 304 | |
| 305 | Change directory to docs & install requirements. |
| 306 | |
| 307 | .. code-block:: bash |
| 308 | |
| 309 | cd doc |
| 310 | sudo pip install -r etc/requirements.txt |
| 311 | |
| 312 | Update 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 Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 323 | |
| 324 | |