Rework doc generation to simplify and centralize

Just do all doc generation in the hack::util::gen-docs instead of spread
around. We also only track the generated docs in a single file for the
whole tree.
This commit is contained in:
Eric Paris
2015-08-20 19:17:26 -07:00
parent 9cf7bb6b4f
commit 58d6b29e97
7 changed files with 120 additions and 143 deletions

View File

@@ -31,11 +31,6 @@ mungedocs=$(kube::util::find-binary "mungedocs")
DOCROOT="${KUBE_ROOT}/docs/"
EXAMPLEROOT="${KUBE_ROOT}/examples/"
TMP_DOCROOT="${KUBE_ROOT}/_tmp/docs/"
_tmp="${KUBE_ROOT}/_tmp"
mkdir -p "${_tmp}"
cp -a "${DOCROOT}" "${TMP_DOCROOT}"
# mungedocs --verify can (and should) be run on the real docs, otherwise their
# links will be distorted. --verify means that it will not make changes.
@@ -59,12 +54,15 @@ if [[ $ret -gt 1 ]]; then
exit 1
fi
kube::util::gen-doc "${genman}" "${_tmp}" "docs/man/man1/"
kube::util::gen-doc "${gendocs}" "${_tmp}" "docs/user-guide/kubectl/" '###### Auto generated by spf13/cobra'
echo "diffing ${DOCROOT} against freshly generated docs"
diff -Naupr "${DOCROOT}" "${TMP_DOCROOT}" && ret=0 || ret=$?
rm -rf "${_tmp}"
kube::util::ensure-temp-dir
kube::util::gen-docs "${KUBE_TEMP}"
diff -Naup "${KUBE_TEMP}/.generated_docs" "${KUBE_ROOT}/.generated_docs" || ret=1 || true
while read file; do
diff -Naup "${KUBE_TEMP}/${file}" "${KUBE_ROOT}/${file}" || ret=1 || true
done <"${KUBE_TEMP}/.generated_docs"
needsanalytics=($(kube::util::gen-analytics "${KUBE_ROOT}" 1))
if [[ ${#needsanalytics[@]} -ne 0 ]]; then
echo -e "Some md files are missing ga-beacon analytics link:"
@@ -73,26 +71,9 @@ if [[ ${#needsanalytics[@]} -ne 0 ]]; then
fi
if [[ $ret -eq 0 ]]
then
echo "${DOCROOT} up to date."
echo "Generated docs are up to date."
else
echo "${DOCROOT} is out of date. Please run hack/update-generated-docs.sh"
echo "Generated docs are out of date. Please run hack/update-generated-docs.sh"
exit 1
fi
COMPROOT="${KUBE_ROOT}/contrib/completions"
TMP_COMPROOT="${KUBE_ROOT}/contrib/completions_tmp"
cp -a "${COMPROOT}" "${TMP_COMPROOT}"
kube::util::gen-doc "${genbashcomp}" "${TMP_COMPROOT}" "bash/"
diff -Naupr "${COMPROOT}" "${TMP_COMPROOT}" && ret=0 || ret=$?
rm -rf ${TMP_COMPROOT}
if [ $ret -eq 0 ]
then
echo "${COMPROOT} up to date."
else
echo "${COMPROOT} is out of date. Please run hack/update-generated-docs.sh"
echo "If you did not make a change to kubectl or its dependencies,"
echo "run 'make clean' and retry this command."
exit 1
fi
# ex: ts=2 sw=2 et filetype=sh