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