1 How to setup the workflow of automatic documentation build for your project
2 ----------------------------------------------------------------------------
4 **Setup you repository and then clone locally**::
8 git clone ssh://<username>@gerrit.opnfv.org:29418/<project>
13 **Inside the repository create the following structure:**::
15 gerrit.opnfv.org/<project>/docs/some-project-description.rst
19 docs/release/some-release-doc.rst
21 requirements/requirements.rst
23 design_docs/some-design-doc.rst
26 More details about the default structure you can find `here <https://wiki.opnfv.org/documentation>`_ at paragraph "How and where to store the document content files in your repository".
28 **In order to obtain a nice .html & .pdf at then end you must write you documentation using reSt markup**
32 * http://docutils.sourceforge.net/docs/user/rst/quickref.html
33 * http://rest-sphinx-memo.readthedocs.org/en/latest/ReST.html
34 * http://www.math.uiuc.edu/~gfrancis/illimath/windows/aszgard_mini/movpy-2.0.0-py2.4.4/manuals/docutils/ref/rst/directives.html
36 An `nice online editor <http://rst.ninjs.org/>`_ that will help you write reSt and see your changes live. After done editing you can copy the source document in the repository and follow the workflow.
39 **Clone the releng repository so you can created jobs for JJB**::
41 git clone ssh://<username>@gerrit.opnfv.org:29418/releng
44 Enter the project settings::
46 cd releng/jjb/<project>/
49 **Create the verify & build scripts**
51 The script is the same for most of the projects and you can just copy it under your project in releng/jjb/<project>/
53 example: cp releng/jjb/opnfvdocs/build-docu.sh releng/jjb/<your-project>/
61 project="$(git remote -v | head -n1 | awk '{{print $2}}' | sed -e 's,.*:\(.*/\)\?,,' -e 's/\.git$//')"
62 export PATH=$PATH:/usr/local/bin/
64 git_sha1="$(git rev-parse HEAD)"
65 docu_build_date="$(date)"
68 while read -r -d ''; do
70 done < <(find * -type f -iname '*.rst' -print0)
72 for file in "${{files[@]}}"; do
74 file_cut="${{file%.*}}"
75 gs_cp_folder="${{file_cut}}"
78 sed -i "s/_sha1_/$git_sha1/g" $file
79 sed -i "s/_date_/$docu_build_date/g" $file
83 rst2html $file | gsutil cp -L gsoutput.txt - \
84 gs://artifacts.opnfv.org/"$project"/"$gs_cp_folder".html
85 gsutil setmeta -h "Content-Type:text/html" \
86 -h "Cache-Control:private, max-age=0, no-transform" \
87 gs://artifacts.opnfv.org/"$project"/"$gs_cp_folder".html
92 rst2pdf $file -o - | gsutil cp -L gsoutput.txt - \
93 gs://artifacts.opnfv.org/"$project"/"$gs_cp_folder".pdf
94 gsutil setmeta -h "Content-Type:application/pdf" \
95 -h "Cache-Control:private, max-age=0, no-transform" \
96 gs://artifacts.opnfv.org/"$project"/"$gs_cp_folder".pdf
103 while read -r -d ''; do
105 done < <(find * -type f \( -iname \*.jpg -o -iname \*.png \) -print0)
107 for img in "${{images[@]}}"; do
109 # uploading found images
110 echo "uploading $img"
111 cat "$img" | gsutil cp -L gsoutput.txt - \
112 gs://artifacts.opnfv.org/"$project"/"$img"
113 gsutil setmeta -h "Content-Type:image/jpeg" \
114 -h "Cache-Control:private, max-age=0, no-transform" \
115 gs://artifacts.opnfv.org/"$project"/"$img"
121 #the double {{ in file_cut="${{file%.*}}" is to escape jjb's yaml
130 project="$(git remote -v | head -n1 | awk '{{print $2}}' | sed -e 's,.*:\(.*/\)\?,,' -e 's/\.git$//')"
131 export PATH=$PATH:/usr/local/bin/
133 git_sha1="$(git rev-parse HEAD)"
134 docu_build_date="$(date)"
137 while read -r -d ''; do
139 done < <(find * -type f -iname '*.rst' -print0)
141 for file in "${{files[@]}}"; do
143 file_cut="${{file%.*}}"
144 gs_cp_folder="${{file_cut}}"
147 sed -i "s/_sha1_/$git_sha1/g" $file
148 sed -i "s/_date_/$docu_build_date/g" $file
151 echo "rst2html $file"
152 rst2html $file > $file_cut".html"
155 rst2pdf $file -o $file_cut".pdf"
159 #the double {{ in file_cut="${{file%.*}}" is to escape jjb's yaml
162 **Edit <your-project>.yml**::
164 vi releng/jjb/<your-project>/<your-project>.yml
167 Make sure you have the job-templates set correctly as below.
169 example: less releng/jjb/opnfvdocs/opnfvdocs.yml (pay extra attention at the "builder" sections)
174 name: 'opnfvdocs-daily-{stream}'
180 !include-raw docu-build.sh
183 name: 'opnfvdocs-verify'
189 !include-raw docu-verify.sh
192 name: 'opnfvdocs-merge'
198 !include-raw docu-build.sh
201 "node: master" is important here as all documentations are built on Jenkins master node for now.
203 Please reffer to the releng repository for the correct indentation as JJB is very picky with those and also for the rest of the code that is missing in the example code and replaced by "...".
204 Also you must have your documentation under docs/ in the repository or gsutil will fail to copy them; for customizations you might need to addapt build-docu.sh as we did for genesis project as different documents need to go into different places.
209 git add build-docu.sh <project>.yml
212 Commit change with --signoff::
217 Send code for review in Gerrit::
222 Create the documentation using the recommended structure in your repository and submit to gerrit for review
225 **Jenkins will take over and produce artifacts in the form of .html & .pdf**
227 Jenkins has the proper packages installed in order to produce the artifacts.
230 **Artifacts are stored on Google Storage (still to decide where, structure and how to present them)**
232 http://artifacts.opnfv.org/
235 `Here you can download the PDF version <http://artifacts.opnfv.org/opnfvdocs/docs/enable_docu_gen.pdf>`_ of this guide.
238 **Scrape content from html artifacts on wiki**
240 This section describes how the html build artifacts can be made visible on Wiki using he scrape method.
241 In order to have you documentation on Wiki you need to create a wiki page and include an adaption of the code below:
245 {{scrape>http://artifacts.opnfv.org/opnfvdocs/docs/enable_docu_gen.html}}
248 Please try to write documentation as accurate and clear as possible as once reviewed and merged it will be automatically built and displayed on Wiki and everyone would apreciate a good written/nice looking guide.
250 If you want to see on wiki what code is scraped from the built artifacts click "Show pagesource" in the right (it will appear if you hover over the magnifier icon); this way you know what is written straight on wiki and what is embedded with "scrape". By knowing these details you will be able to prevent damages by manually updating wiki.
253 **How to track documentation**
255 You must include at the bottom of every document that you want to track the following::
257 **Documentation tracking**
263 # add one "_" at the end of each trigger variable (they have also a prefix "_") when inserting them into documents to enable auto-replacement
266 **Image inclusion for artifacts**
268 Create a folder called images in the same folder where you documentation resides and copy .jpg or .png files there, according to the guide here: https://wiki.opnfv.org/documentation
270 Here is an example of what you need to include in the .rst files to include an image::
272 .. image:: images/smiley.png
275 :alt: Just a smiley face!
278 The image will be shown in both .html and .pdf resulting artifacts.
284 In order to generate html & pdf documentation the needed packages are rst2pdf & python-docutils if the Jenkins is CentOS/RHEL; many variants have been tested but this is the cleanest solution found.
285 For html generation it also supports css styles if needed.
288 **Documentation tracking**