aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/bash
diff options
context:
space:
mode:
authorpmikus <pmikus@cisco.com>2021-08-20 09:27:12 +0000
committerPeter Mikus <pmikus@cisco.com>2021-08-23 10:41:44 +0000
commitaa72d4256fb7409fa01a0cb33aaa763128f0d30b (patch)
tree837b11a17ebaca47800f294570c6e9cc66b2d182 /resources/libraries/bash
parentc849edfc256df9c3de1ece6babcd4757bb2a8072 (diff)
FIX: Docs generation
+ Tests will be fixed with renamed hoststack tests. + Tox is at least working Signed-off-by: pmikus <pmikus@cisco.com> Change-Id: Ibee30cd54c78b67d2ef907cdd14a71ae197be59e
Diffstat (limited to 'resources/libraries/bash')
-rw-r--r--resources/libraries/bash/entry/check/doc_verify.sh18
-rw-r--r--resources/libraries/bash/function/docs.sh67
2 files changed, 47 insertions, 38 deletions
diff --git a/resources/libraries/bash/entry/check/doc_verify.sh b/resources/libraries/bash/entry/check/doc_verify.sh
index 544586a767..baa9d8aa74 100644
--- a/resources/libraries/bash/entry/check/doc_verify.sh
+++ b/resources/libraries/bash/entry/check/doc_verify.sh
@@ -27,14 +27,9 @@ source "${BASH_FUNCTION_DIR}/common.sh" || {
echo "Source failed." >&2
exit 1
}
-
+source "${BASH_FUNCTION_DIR}/docs.sh" || die "Source failed."
common_dirs || die
-log_file="$(pwd)/doc_verify.log" || die
-
-# Pre-cleanup.
-rm -f "${log_file}" || die
-rm -f "${DOC_GEN_DIR}/csit.docs.tar.gz" || die
-rm -rf "${DOC_GEN_DIR}/_build" || die
+activate_virtualenv || die
# Documentation generation.
# Here we do store only stderr to file while stdout (inlcuding Xtrace) is
@@ -43,13 +38,12 @@ rm -rf "${DOC_GEN_DIR}/_build" || die
# task.
exec 3>&1 || die
export BASH_XTRACEFD="3" || die
+log_file="$(pwd)/doc_verify.log" || die
-pushd "${DOC_GEN_DIR}" || die
-source ./run_doc.sh ${GERRIT_BRANCH:-local} 2> ${log_file} || true
-popd || die
+generate_docs 2> ${log_file} || die
-if [[ ! -f "${log_file}" ]] || [[ -s "${log_file}" ]]; then
- # Output file not exists or is non empty.
+if [[ "${DOCS_EXIT_STATUS}" != 0 ]]; then
+ # Failed to generate report.
warn
warn "Doc verify checker: FAIL"
exit 1
diff --git a/resources/libraries/bash/function/docs.sh b/resources/libraries/bash/function/docs.sh
index ec5cbefdd0..be3f9861ce 100644
--- a/resources/libraries/bash/function/docs.sh
+++ b/resources/libraries/bash/function/docs.sh
@@ -50,53 +50,68 @@ function generate_docs () {
WORKING_DIR="tmp"
BUILD_DIR="_build"
+ # Remove the old build:
+ rm -rf ${BUILD_DIR} || true
+ rm -rf ${WORKING_DIR} || true
+
# Create working directories
- mkdir "${BUILD_DIR}"
- mkdir --parents "${WORKING_DIR}"/resources/libraries/python/
- mkdir --parents "${WORKING_DIR}"/resources/libraries/robot/
- mkdir --parents "${WORKING_DIR}"/tests/
+ mkdir -p "${BUILD_DIR}" || die "Mkdir failed!"
+ mkdir -p "${WORKING_DIR}"/resources/libraries/python/ || die "Mkdir failed!"
+ mkdir -p "${WORKING_DIR}"/resources/libraries/robot/ || die "Mkdir failed!"
+ mkdir -p "${WORKING_DIR}"/tests/ || die "Mkdir failed!"
# Copy the Sphinx source files:
- cp -r src/* ${WORKING_DIR}/
+ cp -r src/* ${WORKING_DIR}/ || die "Copy the Sphinx source files failed!"
# Copy the source files to be processed:
- from_dir="../../../resources/libraries/python/"
+ from_dir="${RESOURCES_DIR}/libraries/python/"
to_dir="${WORKING_DIR}/resources/libraries/python/"
- command="rsync -a --include '*/'"
- ${command} --include '*.py' --exclude '*' "${from_dir}" "${to_dir}"
- cp ../../../resources/__init__.py ${WORKING_DIR}/resources/
- cp ../../../resources/libraries/__init__.py ${WORKING_DIR}/resources/libraries/
- from_dir="../../../resources/libraries/robot/"
- to_dir="${WORKING_DIR}/resources/libraries/robot/"
- ${command} --include '*.robot' --exclude '*' "${from_dir}" "${to_dir}"
- from_dir="../../../tests/"
- to_dir="${WORKING_DIR}/tests/"
- ${command} --include '*.robot' --exclude '*' "${from_dir}" "${to_dir}"
+ dirs="${from_dir} ${to_dir}"
+ rsync -ar --include='*/' --include='*.py' --exclude='*' ${dirs} || {
+ die "rSync failed!"
+ }
- python3 gen_rst.py
- # Remove all rst files from ./${WORKING_DIR}/env directory - we do not need
- # them
- find ./${WORKING_DIR}/env -type f -name '*.rst' | xargs rm -f
+ from_dir="${RESOURCES_DIR}/libraries/robot/"
+ to_dir="${WORKING_DIR}/resources/libraries/robot/"
+ dirs="${from_dir} ${to_dir}"
+ rsync -ar --include='*/' --include '*.robot' --exclude '*' ${dirs} || {
+ die "rSync failed!"
+ }
+ touch ${to_dir}/index.robot || {
+ die "Touch index.robot file failed!"
+ }
+
+ # Due to hoststack tests having dots in the name of suite, tests will become
+ # disabled as spihnxdoc cannot properly work with the path. gen_rst
+ # is generating dots scheme. The solution is to rename suites as
+ # having dots is misleading with robot framework naming conventions.
+
+ #from_dir="${CSIT_DIR}/tests/"
+ #to_dir="${WORKING_DIR}/tests/"
+ #dirs="${from_dir} ${to_dir}"
+ #rsync -ar --include='*/' --include '*.robot' --exclude '*' ${dirs} || {
+ # die "rSync failed!"
+ #}
+
+ find ${WORKING_DIR}/ -type d -exec echo {} \; -exec touch {}/__init__.py \;
+
+ python3 gen_rst.py || die "Generate .rst files failed!"
# Generate the documentation:
- DATE=$(date -u '+%d-%b-%Y')
+ DATE=$(date -u '+%d-%b-%Y') || die "Get date failed!"
all_options=("-v")
all_options+=("-c" "${WORKING_DIR}")
all_options+=("-a")
all_options+=("-b" "html")
all_options+=("-E")
- all_options+=("-D" "release=$1")
- all_options+=("-D" "version='$1 documentation - $DATE'")
+ all_options+=("-D" "version="${GERRIT_BRANCH:-master}"")
all_options+=("${WORKING_DIR}" "${BUILD_DIR}/")
set +e
sphinx-build "${all_options[@]}"
DOCS_EXIT_STATUS="$?"
set -e
-
- find . -type d -name 'env' | xargs rm -rf
-
}
function generate_report () {