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 | ========== |
jsseidel | da2324a | 2017-09-15 10:43:14 -0400 | [diff] [blame] | 6 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 7 | Some initial set up is required to connect a project with |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 8 | the master document structure and enable automated publishing of |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 9 | changes as summarized in the following diagram and description below |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 10 | below. |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 11 | |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 12 | .. seqdiag:: |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 13 | :height: 700 |
| 14 | :width: 1000 |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 15 | |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 16 | seqdiag { |
| 17 | RD [label = "Read The Docs", color =lightgreen ]; |
| 18 | DA [label = "Doc Project\nAuthor/Committer", color=lightblue]; |
| 19 | DR [label = "Doc Gerrit Repo" , color=pink]; |
| 20 | PR [label = "Other Project\nGerrit Repo", color=pink ]; |
| 21 | PA [label = "Other Project\nAuthor/Committer", color=lightblue]; |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 22 | |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 23 | === One time setup doc project only === |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 24 | RD -> DA [label = "Acquire Account" ]; |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 25 | DA -> DR [label = "Create initial\n doc repository content"]; |
| 26 | DA <<-- DR [label = "Merge" ]; |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 27 | RD <-- DA [label = "Connect gerrit.onap.org" ]; |
Rich Bennett | e4c4251 | 2017-09-06 08:07:22 -0400 | [diff] [blame] | 28 | === For each project repository containing document source === |
| 29 | PA -> DR [label = "Add project repo as\ngit submodule" ]; |
| 30 | DR -> DA [label = "Review & Plan to\nIntegrate Content with\nTocTree Structure" ]; |
| 31 | DR <-- DA [label = "Vote +2/Merge" ]; |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 32 | PA <-- DR [label = "Merge Notification" ]; |
Rich Bennett | e4c4251 | 2017-09-06 08:07:22 -0400 | [diff] [blame] | 33 | PA -> PR [label = "Create in project repo\ntop level directory and index.rst" ]; |
Rich Bennett | 358472a | 2017-08-31 08:05:36 -0400 | [diff] [blame] | 34 | PR -> DA [label = "Add as Reviewer" ]; |
| 35 | PR <-- DA [label = "Approve and Integrate" ]; |
| 36 | PA <-- PR [label = "Merge" ]; |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 37 | } |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 38 | |
| 39 | |
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 | Setup doc project |
| 42 | ----------------- |
| 43 | These steps are performed only once for the doc project and include: |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 44 | |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 45 | (1) creating in the doc repository an initial: |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 46 | - sphinx master document index |
| 47 | - a directory structure aligned with the document structure |
| 48 | - tests performed in jenkins verify jobs |
| 49 | - sphinx configuration |
| 50 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 51 | (2) establishing an account at readthedocs connected with the doc |
| 52 | doc project repo in gerrit.onap.org. |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 53 | |
| 54 | |
Rich Bennett | e4c4251 | 2017-09-06 08:07:22 -0400 | [diff] [blame] | 55 | Setup project repositories(s) |
| 56 | ----------------------------- |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 57 | These steps are performed for each project repository that provides documentation. |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 58 | |
Rich Bennett | 5baea46 | 2017-09-13 03:19:19 -0400 | [diff] [blame] | 59 | First let's set two variables that will be used in the subsequent steps. |
Rich Bennett | e4c4251 | 2017-09-06 08:07:22 -0400 | [diff] [blame] | 60 | Set reponame to the project repository you are setting up just as it appears in the |
| 61 | **Project Name** column of the Gerrit projects page. |
| 62 | Set lfid to your Linux Foundation identity that you use to login to gerrit or for git |
| 63 | clone requests over ssh. |
| 64 | |
| 65 | .. code-block:: bash |
| 66 | |
| 67 | reponame= |
| 68 | lfid= |
| 69 | |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 70 | The next step is to add a directory in the doc project where your project will be included as a |
Rich Bennett | e4c4251 | 2017-09-06 08:07:22 -0400 | [diff] [blame] | 71 | submodule and at least one reference from the doc project to the documentation index in your repository. |
Rich Bennett | 5baea46 | 2017-09-13 03:19:19 -0400 | [diff] [blame] | 72 | The following sequence will do this over ssh. |
| 73 | |
| 74 | .. caution:: |
| 75 | |
| 76 | If your access network restricts ssh, you will need to use equivalent git commands and |
| 77 | HTTP Passwords as described `here <http://wiki.onap.org/x/X4AP>`_. |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 78 | |
Rich Bennett | 358472a | 2017-08-31 08:05:36 -0400 | [diff] [blame] | 79 | .. code-block:: bash |
| 80 | |
Rich Bennett | e4c4251 | 2017-09-06 08:07:22 -0400 | [diff] [blame] | 81 | git clone ssh://$lfid@gerrit.onap.org:29418/doc |
Rich Bennett | 358472a | 2017-08-31 08:05:36 -0400 | [diff] [blame] | 82 | cd doc |
| 83 | mkdir -p `dirname docs/submodules/$reponame` |
Rich Bennett | 2360e21 | 2017-09-20 08:26:05 -0400 | [diff] [blame] | 84 | git submodule add ../$reponame docs/submodules/$reponame.git |
Rich Bennett | e4c4251 | 2017-09-06 08:07:22 -0400 | [diff] [blame] | 85 | git submodule init docs/submodules/$reponame.git |
| 86 | git submodule update docs/submodules/$reponame.git |
Rich Bennett | 358472a | 2017-08-31 08:05:36 -0400 | [diff] [blame] | 87 | |
Rich Bennett | e4c4251 | 2017-09-06 08:07:22 -0400 | [diff] [blame] | 88 | echo " $reponame <../submodules/$reponame.git/docs/index>" >> docs/release/repolist.rst |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 89 | |
Rich Bennett | 358472a | 2017-08-31 08:05:36 -0400 | [diff] [blame] | 90 | git add . |
Rich Bennett | e4c4251 | 2017-09-06 08:07:22 -0400 | [diff] [blame] | 91 | git commit -s |
Rich Bennett | 358472a | 2017-08-31 08:05:36 -0400 | [diff] [blame] | 92 | git review |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 93 | |
Rich Bennett | 5baea46 | 2017-09-13 03:19:19 -0400 | [diff] [blame] | 94 | .. caution:: |
| 95 | Wait for the above change to be merged before any merge to the |
| 96 | project repository that you have just added as a submodule. |
| 97 | If the project repository added as submodule changes before the doc project merge, git may not |
| 98 | automatically update the submodule reference on changes and/or the verify job will |
| 99 | fail in the step below. |
Rich Bennett | 358472a | 2017-08-31 08:05:36 -0400 | [diff] [blame] | 100 | |
| 101 | |
Rich Bennett | e4c4251 | 2017-09-06 08:07:22 -0400 | [diff] [blame] | 102 | The last step is to create a docs directory in your repository with an index.rst file. |
Rich Bennett | 5baea46 | 2017-09-13 03:19:19 -0400 | [diff] [blame] | 103 | The following sequence will complete the minimum required over ssh. As you have time |
| 104 | to convert or add new content you can update the index and add files under the docs folder. |
| 105 | |
| 106 | .. hint:: |
| 107 | If you have additional content, you can include it by editing the |
| 108 | index.rst file and/or adding other files before the git commit. |
| 109 | See `Templates and Examples`_ below and :ref:`converting-to-rst` for more information. |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 110 | |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 111 | |
| 112 | .. code-block:: bash |
| 113 | |
Rich Bennett | e4c4251 | 2017-09-06 08:07:22 -0400 | [diff] [blame] | 114 | git clone ssh://$lfid@gerrit.onap.org:29418/$reponame |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 115 | cd $reponame |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 116 | mkdir docs |
| 117 | echo ".. This work is licensed under a Creative Commons Attribution 4.0 International License. |
| 118 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 119 | TODO Add files to toctree and delete this header |
| 120 | ------------------------------------------------ |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 121 | .. toctree:: |
| 122 | :maxdepth: 1 |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 123 | |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 124 | " > docs/index.rst |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 125 | |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 126 | git add . |
Rich Bennett | e4c4251 | 2017-09-06 08:07:22 -0400 | [diff] [blame] | 127 | git commit -s |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 128 | git review |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 129 | |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 130 | |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 131 | The diagram below illustrates what is accomplished in the setup steps |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 132 | 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] | 133 | a jenkins verify job, and/or published release documentation including: |
Rich Bennett | 0c82643 | 2017-09-18 17:28:09 -0400 | [diff] [blame] | 134 | |
| 135 | - ONAP gerrit project repositories, |
| 136 | - doc project repository master document index.rst, templates, configuration, and other documents |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 137 | - submodules directory where other project repositories and directories/files are referenced |
Rich Bennett | 0c82643 | 2017-09-18 17:28:09 -0400 | [diff] [blame] | 138 | - file structure: directories (ellipses), files(boxes) |
| 139 | - references: directory/files (solid edges), git submodule (dotted edges), sphinx toctree (dashed edges) |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 140 | |
| 141 | |
| 142 | .. graphviz:: |
| 143 | |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 144 | |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 145 | digraph docstructure { |
| 146 | size="8,12"; |
| 147 | node [fontname = "helvetica"]; |
| 148 | // Align gerrit repos and docs directories |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 149 | {rank=same doc aaf aai reponame repoelipse vnfsdk vvp} |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 150 | {rank=same confpy release templates masterindex submodules otherdocdocumentelipse} |
Rich Bennett | 358472a | 2017-08-31 08:05:36 -0400 | [diff] [blame] | 151 | {rank=same releasedocumentindex releaserepolist} |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 152 | |
| 153 | //Illustrate Gerrit Repos and provide URL/Link for complete repo list |
| 154 | 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] | 155 | 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] | 156 | gerrit -> doc; |
| 157 | gerrit -> aaf; |
| 158 | gerrit -> aai; |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 159 | gerrit -> reponame; |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 160 | gerrit -> repoelipse; |
| 161 | repoelipse [label=". . . ."]; |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 162 | gerrit -> vnfsdk; |
| 163 | gerrit -> vvp; |
| 164 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 165 | //Show example of local reponame instance of component info |
| 166 | reponame -> reponamedocsdir; |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 167 | reponamesm -> reponamedocsdir; |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 168 | reponamedocsdir [label="docs"]; |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 169 | reponamedocsdir -> repnamedocsdirindex; |
Rich Bennett | e4c4251 | 2017-09-06 08:07:22 -0400 | [diff] [blame] | 170 | repnamedocsdirindex [label="index.rst", shape=box]; |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 171 | |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 172 | //Show detail structure of a portion of doc/docs |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 173 | doc -> docs; |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 174 | docs -> confpy; |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 175 | confpy [label="conf.py",shape=box]; |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 176 | docs -> masterindex; |
Rich Bennett | 358472a | 2017-08-31 08:05:36 -0400 | [diff] [blame] | 177 | masterindex [label="Master\nindex.rst", shape=box]; |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 178 | docs -> release; |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 179 | docs -> templates; |
| 180 | docs -> otherdocdocumentelipse; |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 181 | otherdocdocumentelipse [label="...other\ndocuments"]; |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 182 | docs -> submodules |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 183 | |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 184 | masterindex -> releasedocumentindex [style=dashed, label="sphinx\ntoctree\nreference"]; |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 185 | |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 186 | //Show submodule linkage to docs directory |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 187 | submodules -> reponamesm [style=dotted,label="git\nsubmodule\nreference"]; |
Rich Bennett | e4c4251 | 2017-09-06 08:07:22 -0400 | [diff] [blame] | 188 | reponamesm [label="reponame.git"]; |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 189 | |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 190 | //Example Release document index that references component info provided in other project repo |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 191 | release -> releasedocumentindex; |
Rich Bennett | 1da3046 | 2017-08-24 12:11:36 -0400 | [diff] [blame] | 192 | releasedocumentindex [label="index.rst", shape=box]; |
Rich Bennett | 358472a | 2017-08-31 08:05:36 -0400 | [diff] [blame] | 193 | releasedocumentindex -> releaserepolist [style=dashed, label="sphinx\ntoctree\nreference"]; |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 194 | releaserepolist [label="repolist.rst", shape=box]; |
Rich Bennett | 358472a | 2017-08-31 08:05:36 -0400 | [diff] [blame] | 195 | release -> releaserepolist; |
Rich Bennett | e4c4251 | 2017-09-06 08:07:22 -0400 | [diff] [blame] | 196 | releaserepolist -> repnamedocsdirindex [style=dashed, label="sphinx\ntoctree\nreference"]; |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 197 | |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 198 | } |
| 199 | |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 200 | About GIT branches |
| 201 | ------------------ |
| 202 | |
| 203 | GIT is a powerful tool allowing many actions, but without respecting some rules |
| 204 | the GIT structure can be quickly ugly and unmaintaible. |
| 205 | |
| 206 | Here are some conventions about GIT branches: |
| 207 | - ALWAYS create a local branch to edit or create any file. This local branch |
| 208 | will be considered as a topic in Gerrit and allow contributors to work at the |
| 209 | same time on the same project. |
| 210 | - 1 feature = 1 branch. In the case of documentation, a new chapter or page about |
| 211 | a new code feature can be considered as a 'doc feature' |
| 212 | - 1 bug = 1 branch. In the case of documentation, a correction on an existing |
| 213 | sentence can be considered as a 'doc bug' |
| 214 | - the master branch is considered as "unstable", containing new features that |
| 215 | will converge to a stable situation for the release date. |
| 216 | |
| 217 | The day of the release, the repository owner will create a new branch to |
| 218 | fix the code and documentation. This will represent the 'stable' code of the |
| 219 | release. In this context: |
| 220 | - NEVER push a new feature on a stable branch |
| 221 | - Only bug correction are authorized on a stable branch using cherry pick method |
| 222 | |
| 223 | .. image:: git_branches.png |
| 224 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 225 | Creating Restructured Text |
| 226 | ========================== |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 227 | |
Rich Bennett | 5baea46 | 2017-09-13 03:19:19 -0400 | [diff] [blame] | 228 | Templates and Examples |
| 229 | ---------------------- |
Rich Bennett | 7134cba | 2017-10-10 07:39:06 -0400 | [diff] [blame] | 230 | Templates are available that capture the kinds of information |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 231 | useful for different types of projects and provide some examples of |
| 232 | restructured text. We organize templates in the following way to: help authors |
| 233 | understand relationships between documents; keep the user audience context in mind when writing; |
Rich Bennett | 7134cba | 2017-10-10 07:39:06 -0400 | [diff] [blame] | 234 | and tailor sections for different kinds of projects. |
| 235 | |
| 236 | **Sections** Represent a certain type of content. A section is **provided** in a repository, to |
| 237 | to describe something about the characteristics, use, capability, etc. of things in that repository. |
| 238 | A section may also be **referenced** from other sections and in other repositories. |
| 239 | The notes in the beginning of each section template provide |
| 240 | additional detail about what is typically covered and where there may be references to the section. |
| 241 | |
| 242 | **Collections** Are a set of sections that are typically provided for a particular type |
| 243 | of project, repository, guide, reference manual, etc. |
| 244 | |
| 245 | You can: browse the template *collections* and *sections* below; show source to look at the Restructured |
| 246 | Text and Sphinx directives used; copy the source either from a browser window |
Rich Bennett | 5baea46 | 2017-09-13 03:19:19 -0400 | [diff] [blame] | 247 | or by downloading the file in raw form from |
Rich Bennett | 7134cba | 2017-10-10 07:39:06 -0400 | [diff] [blame] | 248 | the `gerrit doc repository <https://gerrit.onap.org/r/gitweb?p=doc.git;a=tree;f=docs/templates;/>`_ and |
| 249 | then add them to your repository docs folder and index.rst. |
| 250 | |
| 251 | |
| 252 | Sections |
| 253 | ++++++++ |
Rich Bennett | 5baea46 | 2017-09-13 03:19:19 -0400 | [diff] [blame] | 254 | |
| 255 | .. toctree:: |
| 256 | :maxdepth: 1 |
| 257 | :glob: |
| 258 | |
Rich Bennett | 7134cba | 2017-10-10 07:39:06 -0400 | [diff] [blame] | 259 | ../../../templates/sections/* |
| 260 | |
| 261 | |
| 262 | Collections |
| 263 | +++++++++++ |
| 264 | |
| 265 | .. toctree:: |
| 266 | :maxdepth: 1 |
| 267 | :glob: |
| 268 | |
| 269 | ../../../templates/collections/* |
| 270 | |
| 271 | |
Rich Bennett | 5baea46 | 2017-09-13 03:19:19 -0400 | [diff] [blame] | 272 | |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 273 | In addition to these simple templates and examples |
Rich Bennett | 5baea46 | 2017-09-13 03:19:19 -0400 | [diff] [blame] | 274 | there are many open source projects (e.g. Open Daylight, Open Stack) |
| 275 | that are using Sphinx and Readthedocs where you may find examples to start with. |
| 276 | Working with project teams we will continue to enhance templates here and |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 277 | capture frequently asked questions on the developer wiki question |
Rich Bennett | 5baea46 | 2017-09-13 03:19:19 -0400 | [diff] [blame] | 278 | topic `documentation <https://wiki.onap.org/questions/topics/16384055/documentation>`_. |
| 279 | |
| 280 | Each project should: decide what is relevant content; determine the |
| 281 | best way to create/maintain it in a CI/CD process; and work with the |
| 282 | documentation team to reference content from the master index and guides. |
Blaisonneau David | 2963ece | 2017-11-27 10:07:18 +0100 | [diff] [blame^] | 283 | Consider options including filling in a template, |
Rich Bennett | 5baea46 | 2017-09-13 03:19:19 -0400 | [diff] [blame] | 284 | identifying existing content that can be used as is or |
| 285 | easily converted, and use of Sphinx directives/extensions to automatically |
| 286 | generate restructured text from other source you already have. |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 287 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 288 | Links and References |
Rich Bennett | 5baea46 | 2017-09-13 03:19:19 -0400 | [diff] [blame] | 289 | -------------------- |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 290 | It's pretty common to want to reference another location in the |
| 291 | ONAP documentation and it's pretty easy to do with |
| 292 | reStructuredText. This is a quick primer, more information is in the |
| 293 | `Sphinx section on Cross-referencing arbitrary locations |
| 294 | <http://www.sphinx-doc.org/en/stable/markup/inline.html#ref-role>`_. |
| 295 | |
| 296 | Within a single document, you can reference another section simply by:: |
| 297 | |
| 298 | This is a reference to `The title of a section`_ |
| 299 | |
| 300 | Assuming that somewhere else in the same file there a is a section |
| 301 | title something like:: |
| 302 | |
| 303 | The title of a section |
| 304 | ^^^^^^^^^^^^^^^^^^^^^^ |
| 305 | |
| 306 | It's typically better to use ``:ref:`` syntax and labels to provide |
| 307 | links as they work across files and are resilient to sections being |
| 308 | renamed. First, you need to create a label something like:: |
| 309 | |
| 310 | .. _a-label: |
| 311 | |
| 312 | The title of a section |
| 313 | ^^^^^^^^^^^^^^^^^^^^^^ |
| 314 | |
| 315 | .. note:: The underscore (_) before the label is required. |
| 316 | |
| 317 | Then you can reference the section anywhere by simply doing:: |
| 318 | |
| 319 | This is a reference to :ref:`a-label` |
| 320 | |
| 321 | or:: |
| 322 | |
| 323 | This is a reference to :ref:`a section I really liked <a-label>` |
| 324 | |
| 325 | .. note:: When using ``:ref:``-style links, you don't need a trailing |
| 326 | underscore (_). |
| 327 | |
| 328 | Because the labels have to be unique, it usually makes sense to prefix |
| 329 | the labels with the project name to help share the label space, e.g., |
| 330 | ``sfc-user-guide`` instead of just ``user-guide``. |
| 331 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 332 | Testing |
| 333 | ======= |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 334 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 335 | One RST File |
| 336 | ------------ |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 337 | It is recommended that all rst content is validated by `doc8 <https://pypi.python.org/pypi/doc8>`_ standards. |
| 338 | To validate your rst files using doc8, install doc8. |
| 339 | |
| 340 | .. code-block:: bash |
| 341 | |
| 342 | sudo pip install doc8 |
| 343 | |
| 344 | doc8 can now be used to check the rst files. Execute as, |
| 345 | |
| 346 | .. code-block:: bash |
| 347 | |
| 348 | doc8 --ignore D000,D001 <file> |
| 349 | |
| 350 | |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 351 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 352 | One Project |
| 353 | ----------- |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 354 | To test how the documentation renders in HTML, follow these steps: |
| 355 | |
| 356 | Install virtual environment. |
| 357 | |
| 358 | .. code-block:: bash |
| 359 | |
| 360 | sudo pip install virtualenv |
| 361 | cd /local/repo/path/to/project |
| 362 | |
| 363 | Download the doc repository. |
| 364 | |
| 365 | .. code-block:: bash |
| 366 | |
| 367 | git clone http://gerrit.onap.org/r/doc |
| 368 | |
| 369 | Change directory to doc & install requirements. |
| 370 | |
| 371 | .. code-block:: bash |
| 372 | |
| 373 | cd doc |
| 374 | sudo pip install -r etc/requirements.txt |
| 375 | |
| 376 | Move the conf.py file to your project folder where RST files have been kept: |
| 377 | |
| 378 | .. code-block:: bash |
| 379 | |
| 380 | mv doc/docs/conf.py <path-to-your-folder>/ |
| 381 | |
| 382 | Move the static files to your project folder: |
| 383 | |
| 384 | .. code-block:: bash |
| 385 | |
| 386 | mv docs/_static/ <path-to-your-folder>/ |
| 387 | |
| 388 | Build the documentation from within your project folder: |
| 389 | |
| 390 | .. code-block:: bash |
| 391 | |
| 392 | sphinx-build -b html <path-to-your-folder> <path-to-output-folder> |
| 393 | |
| 394 | Your documentation shall be built as HTML inside the |
| 395 | specified output folder directory. |
| 396 | |
| 397 | .. 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. |
| 398 | |
jsseidel | 8066619 | 2017-09-19 13:29:23 -0400 | [diff] [blame] | 399 | .. _building-all-documentation: |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 400 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 401 | All Documentation |
| 402 | ----------------- |
| 403 | To build the whole documentation under doc/, follow these steps: |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 404 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 405 | Install virtual environment. |
Rich Bennett | ac93e0e | 2017-07-19 01:36:52 -0400 | [diff] [blame] | 406 | |
| 407 | .. code-block:: bash |
| 408 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 409 | sudo pip install virtualenv |
| 410 | cd /local/repo/path/to/project |
| 411 | |
| 412 | Download the DOC repository. |
| 413 | |
| 414 | .. code-block:: bash |
| 415 | |
| 416 | git clone http://gerrit.onap.org/r/doc |
| 417 | |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 418 | Update submodules, build documentation using tox & then open using any browser. |
| 419 | |
| 420 | .. code-block:: bash |
| 421 | |
| 422 | cd doc |
Cédric Ollivier | 268209c | 2017-11-10 11:31:53 +0100 | [diff] [blame] | 423 | tox -elocal |
Rich Bennett | a9d6a44 | 2017-08-25 02:37:15 -0400 | [diff] [blame] | 424 | firefox docs/_build/html/index.html |
| 425 | |
Cédric Ollivier | 268209c | 2017-11-10 11:31:53 +0100 | [diff] [blame] | 426 | .. note:: Make sure to run `tox -elocal` and not just `tox`. |