test: Store test logs on artifacts.opnfv.org
[releng.git] / utils / docs-build.sh
index 55cb9f6..6c863cb 100755 (executable)
@@ -1,8 +1,14 @@
 #!/bin/bash -e
-
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# Copyright (c) 2016 NEC and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
 export PATH=$PATH:/usr/local/bin/
 
-
 DOCS_DIR=${DOCS_DIR:-docs}
 INDEX_RST=${INDEX_RST:-index.rst}
 BUILD_DIR=${BUILD_DIR:-docs_build}
@@ -49,8 +55,8 @@ function check_rst_doc() {
     # Note: This check may fail in many jobs for building project docs, since
     #       the old sample has lines more than 120. We ignore failures on this
     #       check right now, but these have to be fixed before OPNFV B release.
-    _out=$(doc8 --max-line-length 120 --ignore D000 "$_src") || {
-        _msg='Error: rst validatino (doc8) has failed, please fix the following error(s).'
+    _out=$(doc8 --max-line-length 240 --ignore D000 "$_src") || {
+        _msg='Warning: rst validation (doc8) has failed, please fix the following error(s).'
         _errs=$(echo "$_out" | sed -n -e "/^$_src/s/^/    /p")
         echo
         echo -e "$_msg\n$_errs"
@@ -137,7 +143,11 @@ prepare_src_files
 find $DOCS_DIR -name $INDEX_RST -printf '%h\n' | while read dir
 do
     name=$(generate_name $dir)
-    src="$SRC_DIR/${dir#$DOCS_DIR/}"
+    if is_top_dir "$dir" ; then
+        src="$SRC_DIR"
+    else
+        src="$SRC_DIR/${dir#$DOCS_DIR/}"
+    fi
     build="$BUILD_DIR/$name"
     output="$OUTPUT_DIR/$name"
     conf="$src/conf.py"
@@ -182,9 +192,14 @@ do
     # TODO: failures in ODT creation should be handled error and
     #       cause 'exit 1' before OPNFV B release.
     tex=$(find $build -name '*.tex' | head -1)
-    odt=$(basename "${tex%.tex}.odt")
+    odt="${tex%.tex}.odt"
     if [[ -e $tex ]] && which pandoc > /dev/null ; then
-        pandoc $tex -o $output/$odt || {
+        (
+            cd $(dirname $tex)
+            pandoc $(basename $tex) -o $(basename $odt)
+        ) && {
+            mv $odt $output/
+        }|| {
             msg="Error: ODT creation for $dir has failed."
             echo
             echo "$msg"