mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
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:
parent
56de2d11a0
commit
37787ffe90
@ -33,9 +33,10 @@ import (
|
|||||||
const latestReleaseBranch = "release-1.2"
|
const latestReleaseBranch = "release-1.2"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
verbose = flag.Bool("verbose", false, "On verification failure, emit pre-munge and post-munge versions.")
|
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.")
|
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.")
|
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
|
// "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.
|
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.
|
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 {
|
func newWalkFunc(fp *fileProcessor, changesNeeded *bool) filepath.WalkFunc {
|
||||||
return func(path string, info os.FileInfo, err error) error {
|
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 {
|
if err := fp.visit(path); err != nil {
|
||||||
*changesNeeded = true
|
*changesNeeded = true
|
||||||
if err != ErrChangesNeeded {
|
if err != ErrChangesNeeded {
|
||||||
@ -194,7 +199,7 @@ func main() {
|
|||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if *rootDir == "" {
|
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)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,4 +58,15 @@ elif [[ $ret -gt 1 ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
# ex: ts=2 sw=2 et filetype=sh
|
||||||
|
Loading…
Reference in New Issue
Block a user