Add --norecurse bool to allow mungedocs to process kube root.

Run hack/after-build/update-generated-docs.sh on kube root with --norecurse and
--skip-munges=unversioned-warning.
This commit is contained in:
David McMahon 2016-03-24 14:30:14 -07:00
parent 56de2d11a0
commit 37787ffe90
2 changed files with 20 additions and 4 deletions

View File

@ -33,9 +33,10 @@ import (
const latestReleaseBranch = "release-1.2"
var (
verbose = flag.Bool("verbose", false, "On verification failure, emit pre-munge and post-munge versions.")
verify = flag.Bool("verify", false, "Exit with status 1 if files would have needed changes but do not change.")
rootDir = flag.String("root-dir", "", "Root directory containing documents to be processed.")
verbose = flag.Bool("verbose", false, "On verification failure, emit pre-munge and post-munge versions.")
verify = flag.Bool("verify", false, "Exit with status 1 if files would have needed changes but do not change.")
norecurse = flag.Bool("norecurse", false, "Only process the files of --root-dir.")
rootDir = flag.String("root-dir", "", "Root directory containing documents to be processed.")
// "repo-root" seems like a dumb name, this is the relative path (from rootDir) to get to the repoRoot
relRoot = flag.String("repo-root", "..", `Appended to --root-dir to get the repository root.
It's done this way so that generally you just have to set --root-dir.
@ -155,6 +156,10 @@ func (f fileProcessor) visit(path string) error {
func newWalkFunc(fp *fileProcessor, changesNeeded *bool) filepath.WalkFunc {
return func(path string, info os.FileInfo, err error) error {
stat, err := os.Stat(path)
if path != *rootDir && stat.IsDir() && *norecurse {
return filepath.SkipDir
}
if err := fp.visit(path); err != nil {
*changesNeeded = true
if err != ErrChangesNeeded {
@ -194,7 +199,7 @@ func main() {
flag.Parse()
if *rootDir == "" {
fmt.Fprintf(os.Stderr, "usage: %s [--verify] --root-dir <docs root>\n", flag.Arg(0))
fmt.Fprintf(os.Stderr, "usage: %s [--help] [--verify] [--norecurse] --root-dir [--skip-munges=<skip list>] <docs root>\n", flag.Arg(0))
os.Exit(1)
}

View File

@ -58,4 +58,15 @@ elif [[ $ret -gt 1 ]]; then
exit 1
fi
"${mungedocs}" "--skip-munges=unversioned-warning,analytics" \
"--norecurse" \
"--root-dir=${KUBE_ROOT}/" && ret=0 || ret=$?
if [[ $ret -eq 1 ]]; then
echo "${KUBE_ROOT}/ requires manual changes. See preceding errors."
exit 1
elif [[ $ret -gt 1 ]]; then
echo "Error running mungedocs."
exit 1
fi
# ex: ts=2 sw=2 et filetype=sh