doc: fix rst and jjb to have consistent view in html and pdf 63/3463/7
authorRyota MIBU <r-mibu@cq.jp.nec.com>
Wed, 25 Nov 2015 13:23:01 +0000 (22:23 +0900)
committerRyota Mibu <r-mibu@cq.jp.nec.com>
Thu, 26 Nov 2015 10:23:47 +0000 (10:23 +0000)
JIRA: RELENG-16

Change-Id: I6e36f16be6e1c9160820d137a78ac1e7674153f0
Signed-off-by: Ryota MIBU <r-mibu@cq.jp.nec.com>
docs/etc/conf.py
docs/how-to-use-docs/documentation-example.rst
docs/how-to-use-docs/index.rst
docs/jenkins-job-builder/index.rst
docs/jenkins-job-builder/opnfv-jjb-usage.rst
jjb/opnfv/opnfv-docs.yml
jjb/releng-macros.yaml

index 68e847e..6245cc0 100644 (file)
@@ -1,29 +1,23 @@
-import datetime
-import sys
-import os
+'''
+Base configuration file for sphinx-build.
 
-needs_sphinx = '1.3'
+You can override this configuration by putting 'conf.py' in the document
+directory (e.g. how-to-use-docs/conf.py).
+'''
 
-numfig = True
+import datetime
 
-source_suffix = '.rst'
+needs_sphinx = '1.3'
 master_doc = 'index'
 pygments_style = 'sphinx'
-html_use_index = False
-html_logo = 'opnfv-logo.png'
 
-pdf_documents = [('index', u'Copper', u'Copper Project', u'OPNFV')]
-pdf_fit_mode = "shrink"
-pdf_stylesheets = ['sphinx','kerning','a4']
-#latex_domain_indices = False
-#latex_use_modindex = False
+html_use_index = False
+numfig = True
+html_logo = '../etc/opnfv-logo.png'
 
-latex_elements = {
-    'printindex': '',
-}
-latex_logo = 'opnfv-logo.png'
+latex_elements = {'printindex': ''}
+latex_logo = '../etc/opnfv-logo.png'
 
-project = u'Copper: Virtual Infrastructure Deployment Policies'
 copyright = u'%s, OPNFV' % datetime.date.today().year
 version = u'1.0.0'
 release = u'1.0.0'
index 764b546..fd0563f 100644 (file)
@@ -1,5 +1,3 @@
-.. two dots create a comment. please leave this logo at the top of each of your rst files.
-
 How to create documentation for your OPNFV project
 ==================================================
 
@@ -21,8 +19,9 @@ This index file must refence your other rst files.
 
 .. code-block:: bash
 
-  Example Documentation table of contents
-  =======================================
+  =====================
+  Example Documentation
+  =====================
 
   Contents:
 
@@ -32,10 +31,8 @@ This index file must refence your other rst files.
 
      documentation-example.rst
 
-  Indices and tables
-  ==================
-
-  * :ref:`search`
+  ..
+      Leave these at the bottom of 'index.rst' file
 
   Revision: _sha1_
 
@@ -71,10 +68,3 @@ links are easy to add: Here is a link to sphinx, the tool that we are using to g
 .. code-block:: bash
 
   echo "Heres is a code block with bash syntax highlighting"
-
-
-Leave these at the bottom of each of your documents they are used internally
-
-Revision: _sha1_
-
-Build date: |today|
index 2d49331..0965eb3 100644 (file)
@@ -1,12 +1,9 @@
-.. OPNFV Release Engineering documentation, created by
-   sphinx-quickstart on Tue Jun  9 19:12:31 2015.
-   You can adapt this file completely to your liking, but it should at least
-   contain the root `toctree` directive.
+..
+    This is new template created on Thu Nov 26 16:18:09 JST 2015
 
-Example Documentation table of contents
-=======================================
-
-Contents:
+=====================
+Example Documentation
+=====================
 
 .. toctree::
    :numbered:
@@ -14,10 +11,8 @@ Contents:
 
    documentation-example.rst
 
-Indices and tables
-==================
-
-* :ref:`search`
+..
+    Leave these at the bottom of 'index.rst' file
 
 Revision: _sha1_
 
index 05847a1..f8f5683 100644 (file)
@@ -1,24 +1,13 @@
-.. OPNFV Release Engineering documentation, created by
-   sphinx-quickstart on Tue Jun  9 19:12:31 2015.
-   You can adapt this file completely to your liking, but it should at least
-   contain the root `toctree` directive.
-
+===========================
 Release Engineering Project
 ===========================
 
-Contents:
-
 .. toctree::
    :numbered:
    :maxdepth: 8
 
    opnfv-jjb-usage.rst
 
-Indices and tables
-==================
-
-* :ref:`search`
-
 Revision: _sha1_
 
 Build date: |today|
index 1945490..fa825c4 100644 (file)
@@ -175,8 +175,3 @@ The Current merge and verify jobs for jenkins job builder as pulled from the rep
                  cd /opt/jenkins-ci/releng
                  git pull
                  jenkins-jobs update --delete-old jjb/
-
-
-Revision: _sha1_
-
-Build date: |today| 
index c6b6f8d..0cc9420 100644 (file)
@@ -74,8 +74,7 @@
                     pattern: 'docs/**'
 
     builders:
-        - build-html-and-pdf-docs-output
-        - upload-under-review-docs-to-opnfv-artifacts
+        - upload-review-docs
 
 - job-template:
     name: 'opnfv-docs-merge'
                     pattern: 'docs/**'
 
     builders:
-        - build-html-and-pdf-docs-output
-        - upload-merged-docs-to-opnfv-artifacts
-        - remove-old-docs-from-opnfv-artifacts
+        - upload-merged-docs
index 3be93c8..9a875a5 100644 (file)
 
             [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
 
-            git_sha1="$(git rev-parse HEAD)"
-
-            find docs/ -type f -iname '*.rst' -print0 | while read file
-            do
-                sed -i "s/_sha1_/$git_sha1/g" "$file"
-            done
+            _get_title_script="
+            import os
+            from docutils import core
+            with open('index.rst', 'r') as file:
+                data = file.read()
+                doctree = core.publish_doctree(data,
+                    settings_overrides={'report_level': 5,
+                                        'halt_level': 5})
+                print doctree[0].astext()"
+            _git_sha1="$(git rev-parse HEAD)"
 
             find docs/ -name 'index.rst' -printf '%h\n' | while read dir
             do
                 echo "#################${dir//?/#}"
                 echo
 
-                mkdir -p "$_output"
+                sed -i "s/_sha1_/$_git_sha1/g" "$dir/index.rst"
 
-                sphinx-build -b html -E -c docs/etc "$dir" "$_output"
+                if [[ ! -f "$dir/conf.py" ]] ; then
+                    cp "etc/conf.py" "$dir/conf.py"
+                    _title=$(cd $dir; python -c "$_get_title_script")
+                    echo "latex_documents = [('index', '$_name.tex', '$_title', 'OPNFV', 'manual'),]" >> "$dir/conf.py"
+                fi
 
-                #sphinx-build -b latex -E -c docs/etc -D project=$_name "$dir" "$_build"
-                #make -C "$_build" LATEXOPTS='--interaction=nonstopmode' all-pdf
-                #mv "$_build"/*.pdf "$_output"
+                mkdir -p "$_output"
+
+                sphinx-build -b html -E "$dir" "$_output"
+
+                # Note: PDF creation may fail in project doc builds.
+                #       We allow this test to be marked as succeeded with
+                #       failure in PDF creation, but leave message to fix it.
+                #       Any failure has to be fixed before B release.
+                {
+                    sphinx-build -b latex -E "$dir" "$_build"
+                    make -C "$_build" LATEXOPTS='--interaction=nonstopmode' all-pdf
+                    mv "$_build"/*.pdf "$_output"
+                } || {
+                    _msg="Error: PDF creation for $dir has failed, please fix source rst file(s)."
+                    echo
+                    echo "$_msg"
+                    echo
+                    echo "$_msg" >> gerrit_comment.txt
+                }
             done
 
-#TODO(r-mibu): change this to publisher
 - builder:
     name: upload-under-review-docs-to-opnfv-artifacts
     builders:
                     "gs://$gs_path"/**.html
             fi
 
-            files=$(find docs/output | grep -e 'index.html$' -e 'pdf$' | \
-                    sed -e "s|^docs/output|    http://$gs_path|")
-            gerrit_comment="Document link(s):
-            $files"
-            echo
-            echo "$gerrit_comment"
-            echo
-            ssh -p 29418 gerrit.opnfv.org "gerrit review -p $GERRIT_PROJECT -m '$gerrit_comment' $GERRIT_PATCHSET_REVISION"
+            echo "Document link(s):" >> gerrit_comment.txt
+            find docs/output | grep -e 'index.html$' -e 'pdf$' | \
+                sed -e "s|^docs/output|    http://$gs_path|" >> gerrit_comment.txt
 
-#TODO(r-mibu): change this to publisher
 - builder:
     name: upload-merged-docs-to-opnfv-artifacts
     builders:
                     "gs://$gs_path"/**.html
             fi
 
-            files=$(find docs/output | grep -e 'index.html$' -e 'pdf$' | \
-                    sed -e "s|^docs/output|    http://$gs_path|")
-            gerrit_comment="Document link(s):
-            $files"
-            echo
-            echo "$gerrit_comment"
-            echo
-            ssh -p 29418 gerrit.opnfv.org "gerrit review -p $GERRIT_PROJECT -m '$gerrit_comment' $GERRIT_PATCHSET_REVISION"
+            echo "Document link(s):" >> gerrit_comment.txt
+            find docs/output | grep -e 'index.html$' -e 'pdf$' | \
+                sed -e "s|^docs/output|    http://$gs_path|" >> gerrit_comment.txt
+
+- builder:
+    name: report-docs-build-result-to-gerrit
+    builders:
+        - shell: |
+            #!/bin/bash -e
+            export PATH=$PATH:/usr/local/bin/
+            if [[ -e gerrit_comment.txt ]] ; then
+                echo
+                echo "posting review comment to gerrit..."
+                echo
+                cat gerrit_comment.txt
+                echo
+                ssh -p 29418 gerrit.opnfv.org \
+                    "gerrit review -p $GERRIT_PROJECT \
+                     -m '$(cat gerrit_comment.txt)' \
+                     $GERRIT_PATCHSET_REVISION"
+            fi
 
-#TODO(r-mibu): change this to publisher
 - builder:
     name: remove-old-docs-from-opnfv-artifacts
     builders:
                 echo "Deleting Out-of-dated Documents..."
                 gsutil -m rm -r "gs://$gs_path"
             fi
+
+- builder:
+    name: upload-review-docs
+    builders:
+        - build-html-and-pdf-docs-output
+        - upload-under-review-docs-to-opnfv-artifacts
+        - report-docs-build-result-to-gerrit
+
+- builder:
+    name: upload-merged-docs
+    builders:
+        - build-html-and-pdf-docs-output
+        - upload-merged-docs-to-opnfv-artifacts
+        - report-docs-build-result-to-gerrit
+        - remove-old-docs-from-opnfv-artifacts