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 | |
| 3 | .. _include-documentation: |
| 4 | |
| 5 | ============================ |
| 6 | Including your Documentation |
| 7 | ============================ |
| 8 | |
| 9 | .. contents:: |
| 10 | :depth: 3 |
| 11 | :local: |
| 12 | |
| 13 | In your project repository |
| 14 | -------------------------- |
| 15 | |
| 16 | Add your documentation to your repository in the folder structure and |
Rich Bennett | 976bffd | 2017-08-15 07:56:32 -0400 | [diff] [blame] | 17 | using templates as described above. |
| 18 | When using a template, copy the directory in `doc/docs/templates/`, |
| 19 | to your <repo>/docs/ directory in your repository. |
| 20 | For instance if you want to document component-info, then your steps shall be |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 21 | as follows: |
| 22 | |
| 23 | .. code-block:: bash |
| 24 | |
| 25 | git clone ssh://<your_id>@gerrit.onap.org:29418/doc |
Rich Bennett | 976bffd | 2017-08-15 07:56:32 -0400 | [diff] [blame] | 26 | cp -p doc/docs/templates/component-info <your_repo>/docs/component-info/ |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 27 | |
| 28 | |
Rich Bennett | 976bffd | 2017-08-15 07:56:32 -0400 | [diff] [blame] | 29 | You should then add the relevant information to the template. |
| 30 | When you are done writing, you can commit |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 31 | the documentation to the your project repository. |
Rich Bennett | 976bffd | 2017-08-15 07:56:32 -0400 | [diff] [blame] | 32 | The sequence below shows basic git/gerrit steps, |
| 33 | see `Developer Best Practices`_ for complete current information. |
| 34 | |
| 35 | .. _Developer Best Practices: https://wiki.onap.org/x/BZZk |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 36 | |
| 37 | .. code-block:: bash |
| 38 | |
| 39 | git add . |
| 40 | git commit --signoff --all |
| 41 | git review |
| 42 | |
| 43 | In the ONAP doc Repository |
| 44 | -------------------------- |
| 45 | |
| 46 | To import project documents from project repositories, we use git submodules. |
Rich Bennett | 976bffd | 2017-08-15 07:56:32 -0400 | [diff] [blame] | 47 | Each ONAP project providing documentation, other than the doc project, is loaded under |
| 48 | `doc/docs/submodules/` when needed for validating or publishing documentation. |
| 49 | To describe the relationship between content files we use the `Sphinx toctree directive`. |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 50 | |
| 51 | The following diagram illustrates: |
| 52 | - all ONAP gerrit project repositories, |
Rich Bennett | 976bffd | 2017-08-15 07:56:32 -0400 | [diff] [blame] | 53 | - the doc project repository including a master document index.rst, |
| 54 | - other document directories and/or RST files that organize sections and documents doc repository, |
| 55 | - the submodules directory where other project repositories and directories/files may be referenced, |
| 56 | - the templates directory with one example, a component-info template that may referenced in release orhigh level design documents, and |
| 57 | - another project repository example, `appc` that provides documentation source by copying and filling in an instance of the component-info template. |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 58 | |
| 59 | |
| 60 | .. graphviz:: |
| 61 | |
| 62 | |
| 63 | digraph docstructure { |
| 64 | size="8,12"; |
| 65 | node [fontname = "helvetica"]; |
| 66 | // Align gerrit repos and docs directories |
| 67 | {rank=same doc aaf aai appc repoelipse vnfsdk vvp} |
Rich Bennett | 976bffd | 2017-08-15 07:56:32 -0400 | [diff] [blame] | 68 | {rank=same componentinfotemplate localappcdocs } |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 69 | |
| 70 | //Show submodule linkage to docs directory |
| 71 | submodules -> localappcdocs [style=dotted]; |
| 72 | |
| 73 | //Illustrate Gerrit Repos and provide URL/Link for complete repo list |
| 74 | gerrit [label="gerrit.onap.org/r", href="https://gerrit.onap.org/r/#/admin/projects/" ]; |
| 75 | gerrit -> doc; |
| 76 | gerrit -> aaf; |
| 77 | gerrit -> aai; |
| 78 | gerrit -> appc; |
Rich Bennett | 976bffd | 2017-08-15 07:56:32 -0400 | [diff] [blame] | 79 | gerrit -> repoelipse; repoelipse [label=". . . ."]; |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 80 | gerrit -> vnfsdk; |
| 81 | gerrit -> vvp; |
| 82 | |
Rich Bennett | 976bffd | 2017-08-15 07:56:32 -0400 | [diff] [blame] | 83 | //Show example of local appc instance of component info |
| 84 | appc -> localappcdocs; localappcdocs [label="docs"]; |
| 85 | localappcdocs -> componentinfoinstance; componentinfoinstance [label="component-info"]; |
| 86 | componentinfoinstance -> compinfoindexinstance; compinfoindexinstance [label="index.rst", shape=box]; |
| 87 | componentinfoinstance -> compinofotherinstance; compinofotherinstance [label="... other sections", shape=box]; |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 88 | |
| 89 | //Show detail structure of a portion of doc/docs _images _static _templates multiple master documents omitted |
| 90 | doc -> docs; |
| 91 | docs -> confpy; confpy [label="conf.py",shape=box]; |
| 92 | docs -> toplevelindex; toplevelindex [label="index.rst", shape=box]; |
| 93 | docs -> release; |
| 94 | docs -> rsttemplates; rsttemplates [label="templates"]; |
| 95 | docs -> indexdirelipse; indexdirelipse [label="...other\ndocuments"]; |
| 96 | docs -> submodules |
| 97 | |
Rich Bennett | 976bffd | 2017-08-15 07:56:32 -0400 | [diff] [blame] | 98 | //Example Release document, section release notes, and reference to an instance of component-info |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 99 | release -> releasenotes; releasenotes [label="release-notes"]; |
| 100 | releasenotes -> lowerlevelindex; lowerlevelindex [label="index.rst", shape=box]; |
Rich Bennett | 976bffd | 2017-08-15 07:56:32 -0400 | [diff] [blame] | 101 | lowerlevelindex -> componentinfoinstance; |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 102 | |
Rich Bennett | 976bffd | 2017-08-15 07:56:32 -0400 | [diff] [blame] | 103 | //Example component-info template |
| 104 | rsttemplates -> componentinfotemplate; componentinfotemplate [label="component-info"]; |
| 105 | componentinfotemplate -> compinfotmpindex; compinfotmpindex [label="index.rst", shape=box]; |
| 106 | componentinfotemplate -> compinfotmpother; compinfotmpother [label="... other sections", shape=box]; |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | In the toctree |
| 110 | ++++++++++++++ |
| 111 | |
| 112 | To include your project specific documentation in the composite documentation, |
| 113 | first identify where your project documentation should be included. |
Rich Bennett | 976bffd | 2017-08-15 07:56:32 -0400 | [diff] [blame] | 114 | Say your project provides component-info and should be referenced in the `doc/docs/release/release-info/index.rst toctree`, then: |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 115 | |
| 116 | .. code-block:: bash |
| 117 | |
| 118 | git clone ssh://<your_id>@gerrit.onap.org:29418/doc |
| 119 | vim doc/docs/release/release-notes/index.rst |
| 120 | |
| 121 | This opens the text editor. Identify where you want to add your release notes. |
| 122 | If your release notes are to be added to the toctree, simply include the path to |
| 123 | it, example: |
| 124 | |
| 125 | |
| 126 | .. code-block:: bash |
| 127 | |
| 128 | .. toctree:: |
| 129 | :maxdepth: 1 |
| 130 | |
Rich Bennett | 976bffd | 2017-08-15 07:56:32 -0400 | [diff] [blame] | 131 | ../../submodules/<your_repo>/docs/component-info/index |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 132 | |
| 133 | When finished, you can request a commit to the doc project repository. |
Rich Bennett | 976bffd | 2017-08-15 07:56:32 -0400 | [diff] [blame] | 134 | Be sure to add the PTL of the docs project as a reviewer of the change you just |
| 135 | pushed in gerrit. |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 136 | |
| 137 | .. code-block:: bash |
| 138 | |
| 139 | git add . |
| 140 | git commit --signoff --all |
| 141 | git review |
| 142 | |
| 143 | |
| 144 | As a Hyperlink |
| 145 | ++++++++++++++ |
| 146 | |
| 147 | It's pretty common to want to reference another location in the |
| 148 | ONAP documentation and it's pretty easy to do with |
| 149 | reStructuredText. This is a quick primer, more information is in the |
| 150 | `Sphinx section on Cross-referencing arbitrary locations |
| 151 | <http://www.sphinx-doc.org/en/stable/markup/inline.html#ref-role>`_. |
| 152 | |
| 153 | Within a single document, you can reference another section simply by:: |
| 154 | |
| 155 | This is a reference to `The title of a section`_ |
| 156 | |
| 157 | Assuming that somewhere else in the same file there a is a section |
| 158 | title something like:: |
| 159 | |
| 160 | The title of a section |
| 161 | ^^^^^^^^^^^^^^^^^^^^^^ |
| 162 | |
| 163 | It's typically better to use ``:ref:`` syntax and labels to provide |
| 164 | links as they work across files and are resilient to sections being |
| 165 | renamed. First, you need to create a label something like:: |
| 166 | |
| 167 | .. _a-label: |
| 168 | |
| 169 | The title of a section |
| 170 | ^^^^^^^^^^^^^^^^^^^^^^ |
| 171 | |
| 172 | .. note:: The underscore (_) before the label is required. |
| 173 | |
| 174 | Then you can reference the section anywhere by simply doing:: |
| 175 | |
| 176 | This is a reference to :ref:`a-label` |
| 177 | |
| 178 | or:: |
| 179 | |
| 180 | This is a reference to :ref:`a section I really liked <a-label>` |
| 181 | |
| 182 | .. note:: When using ``:ref:``-style links, you don't need a trailing |
| 183 | underscore (_). |
| 184 | |
| 185 | Because the labels have to be unique, it usually makes sense to prefix |
| 186 | the labels with the project name to help share the label space, e.g., |
| 187 | ``sfc-user-guide`` instead of just ``user-guide``. |
| 188 | |
| 189 | |
| 190 | 'doc8' Validation |
| 191 | ----------------- |
| 192 | It is recommended that all rst content is validated by `doc8 <https://pypi.python.org/pypi/doc8>`_ standards. |
| 193 | To validate your rst files using doc8, install doc8. |
| 194 | |
| 195 | .. code-block:: bash |
| 196 | |
| 197 | sudo pip install doc8 |
| 198 | |
| 199 | doc8 can now be used to check the rst files. Execute as, |
| 200 | |
| 201 | .. code-block:: bash |
| 202 | |
| 203 | doc8 --ignore D000,D001 <file> |
| 204 | |
| 205 | |
| 206 | Testing: Build Documentation Locally |
| 207 | ------------------------------------ |
| 208 | |
| 209 | Composite DOC documentation |
| 210 | +++++++++++++++++++++++++++++++++ |
| 211 | To build the whole documentation under doc/, follow these steps: |
| 212 | |
| 213 | Install virtual environment. |
| 214 | |
| 215 | .. code-block:: bash |
| 216 | |
| 217 | sudo pip install virtualenv |
| 218 | cd /local/repo/path/to/project |
| 219 | |
| 220 | Download the DOC repository. |
| 221 | |
| 222 | .. code-block:: bash |
| 223 | |
| 224 | git clone http://gerrit.onap.org/r/doc |
| 225 | |
| 226 | Change directory to docs & install requirements. |
| 227 | |
| 228 | .. code-block:: bash |
| 229 | |
| 230 | cd doc |
| 231 | sudo pip install -r etc/requirements.txt |
| 232 | |
| 233 | Update submodules, build documentation using tox & then open using any browser. |
| 234 | |
| 235 | .. code-block:: bash |
| 236 | |
| 237 | cd doc |
| 238 | git submodule update --init |
| 239 | tox -edocs |
| 240 | firefox docs/_build/html/index.html |
| 241 | |
| 242 | .. note:: Make sure to run `tox -edocs` and not just `tox`. |
| 243 | |
| 244 | Individual project documentation |
| 245 | ++++++++++++++++++++++++++++++++ |
| 246 | To test how the documentation renders in HTML, follow these steps: |
| 247 | |
| 248 | Install virtual environment. |
| 249 | |
| 250 | .. code-block:: bash |
| 251 | |
| 252 | sudo pip install virtualenv |
| 253 | cd /local/repo/path/to/project |
| 254 | |
| 255 | Download the doc repository. |
| 256 | |
| 257 | .. code-block:: bash |
| 258 | |
| 259 | git clone http://gerrit.onap.org/r/doc |
| 260 | |
| 261 | Change directory to doc & install requirements. |
| 262 | |
| 263 | .. code-block:: bash |
| 264 | |
| 265 | cd doc |
| 266 | sudo pip install -r etc/requirements.txt |
| 267 | |
| 268 | Move the conf.py file to your project folder where RST files have been kept: |
| 269 | |
| 270 | .. code-block:: bash |
| 271 | |
| 272 | mv doc/docs/conf.py <path-to-your-folder>/ |
| 273 | |
| 274 | Move the static files to your project folder: |
| 275 | |
| 276 | .. code-block:: bash |
| 277 | |
| 278 | mv docs/_static/ <path-to-your-folder>/ |
| 279 | |
| 280 | Build the documentation from within your project folder: |
| 281 | |
| 282 | .. code-block:: bash |
| 283 | |
| 284 | sphinx-build -b html <path-to-your-folder> <path-to-output-folder> |
| 285 | |
| 286 | Your documentation shall be built as HTML inside the |
| 287 | specified output folder directory. |
| 288 | |
| 289 | .. 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. |
| 290 | |
| 291 | |
| 292 | Adding your project repository as a submodule |
| 293 | --------------------------------------------- |
| 294 | |
| 295 | Clone the doc repository and add your submodule using the commands below and where $reponame is your repository name. |
| 296 | |
| 297 | .. code-block:: bash |
| 298 | |
| 299 | cd docs/submodules/ |
| 300 | git submodule git https://gerrit.onap.org/r/$reponame |
| 301 | git submodule init $reponame/ |
| 302 | git submodule update $reponame/ |
| 303 | git add . |
| 304 | git review |