mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-08 20:50:24 +00:00
Support for in-place modification of docs
Adds cmd/mungedocs which is framework for processing all files under docs/ and either verifying that no changes needed or making in-place changes. Did not reuse kube::util::gen-docs because that seemed to be centered around handling added files, and this pass does not add files. Planned uses: - table of contents automatic updating - linkification - internal link checker - link-path-relativizer or absolutizer - example file syncer - header inserter. Just table-of-contents updating in this PR. Added Table of Contents to docs/networking.md. Demonstrates use of new TOC generator presubmit. Other docs will be added in future PRs. Additional development will be needed to handle some of the more complex cases.
This commit is contained in:
@@ -23,16 +23,18 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
|
||||
|
||||
kube::golang::setup_env
|
||||
|
||||
# Find binary
|
||||
gendocs=$(kube::util::find-binary "gendocs")
|
||||
genman=$(kube::util::find-binary "genman")
|
||||
genbashcomp=$(kube::util::find-binary "genbashcomp")
|
||||
mungedocs=$(kube::util::find-binary "mungedocs")
|
||||
|
||||
if [[ ! -x "$gendocs" || ! -x "$genman" || ! -x "$genbashcomp" ]]; then
|
||||
if [[ ! -x "$gendocs" || ! -x "$genman" || ! -x "$genbashcomp" || ! -x "$mungedocs" ]]; then
|
||||
{
|
||||
echo "It looks as if you don't have a compiled gendocs, genman, or genbashcomp binary"
|
||||
echo "It looks as if you don't have a compiled gendocs, genman, genbashcomp or mungedocs binary"
|
||||
echo
|
||||
echo "If you are running from a clone of the git repo, please run"
|
||||
echo "'./hack/build-go.sh cmd/gendocs cmd/genman cmd/genbashcomp'."
|
||||
echo "'./hack/build-go.sh cmd/gendocs cmd/genman cmd/genbashcomp cmd/mungedocs'."
|
||||
} >&2
|
||||
exit 1
|
||||
fi
|
||||
@@ -44,6 +46,17 @@ _tmp="${KUBE_ROOT}/_tmp"
|
||||
mkdir -p "${_tmp}"
|
||||
cp -a "${DOCROOT}" "${TMP_DOCROOT}"
|
||||
|
||||
"${mungedocs}" "--verify=true" "--root-dir=${TMP_DOCROOT}"
|
||||
ret=$?
|
||||
if [[ $ret -eq 1 ]]; then
|
||||
echo "${DOCROOT} is out of date. Please run hack/run-gendocs.sh"
|
||||
exit 1
|
||||
fi
|
||||
if [[ $ret -eq 2 ]]; then
|
||||
echo "Error running mungedocs"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
kube::util::gen-doc "${genman}" "${TMP_DOCROOT}/man/man1/"
|
||||
kube::util::gen-doc "${gendocs}" "${TMP_DOCROOT}"
|
||||
echo "diffing ${DOCROOT} against freshly generated docs"
|
||||
|
Reference in New Issue
Block a user