From 8faa88626d4eb2c30286d9e5b7801edbe54a6a12 Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Fri, 3 Jun 2016 15:13:26 -0700 Subject: [PATCH] Revamp doc generation Auto generated docs are **NO LONGER CHECKED IN**, only placeholders. To generate them, e.g. before exporting docs, run hack/generate-docs.sh. hack/verify-generated-docs.sh ensures that generated docs are merely the placeholder text. hack/update-generated-docs.sh puts the placeholder text in the proper places. The old munge behavior is moved into hack/{update|verify}-munge-docs.sh. --- build/common.sh | 1 - hack/autogenerated_placeholder.txt | 3 ++ hack/generate-docs.sh | 52 ++++++++++++++++++++++ hack/lib/util.sh | 45 +++++++++++-------- hack/update-generated-docs.sh | 46 +++++-------------- hack/update-munge-docs.sh | 64 +++++++++++++++++++++++++++ hack/verify-generated-docs.sh | 64 ++++++++------------------- hack/verify-munge-docs.sh | 71 ++++++++++++++++++++++++++++++ 8 files changed, 244 insertions(+), 102 deletions(-) create mode 100644 hack/autogenerated_placeholder.txt create mode 100755 hack/generate-docs.sh create mode 100755 hack/update-munge-docs.sh create mode 100755 hack/verify-munge-docs.sh diff --git a/build/common.sh b/build/common.sh index 63b52865b39..46ee1863143 100755 --- a/build/common.sh +++ b/build/common.sh @@ -483,7 +483,6 @@ function kube::build::source_targets() { third_party vendor contrib/mesos - .generated_docs ) if [ -n "${KUBERNETES_CONTRIB:-}" ]; then for contrib in "${KUBERNETES_CONTRIB}"; do diff --git a/hack/autogenerated_placeholder.txt b/hack/autogenerated_placeholder.txt new file mode 100644 index 00000000000..b6fd7a0f989 --- /dev/null +++ b/hack/autogenerated_placeholder.txt @@ -0,0 +1,3 @@ +This file is autogenerated, but we've stopped checking such files into the +repository to reduce the need for rebases. Please run hack/generate-docs.sh to +populate this file. diff --git a/hack/generate-docs.sh b/hack/generate-docs.sh new file mode 100755 index 00000000000..19ee1c83854 --- /dev/null +++ b/hack/generate-docs.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# Copyright 2014 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file is not intended to be run automatically. It is meant to be run +# immediately before exporting docs. We do not want to check these documents in +# by default. + +set -o errexit +set -o nounset +set -o pipefail + +KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. +source "${KUBE_ROOT}/hack/lib/init.sh" + +kube::golang::setup_env + +"${KUBE_ROOT}/hack/build-go.sh" \ + cmd/gendocs \ + cmd/genkubedocs \ + cmd/genman \ + cmd/genyaml \ + federation/cmd/genfeddocs + +kube::util::ensure-temp-dir + +kube::util::gen-docs "${KUBE_TEMP}" + +# remove all of the old docs +kube::util::remove-gen-docs + +# Copy fresh docs into the repo. +# the shopt is so that we get .generated_docs from the glob. +shopt -s dotglob +cp -af "${KUBE_TEMP}"/* "${KUBE_ROOT}" +shopt -u dotglob + +echo "Generated docs have been placed in the repository tree. Running hack/update-munge-docs.sh." + +"${KUBE_ROOT}/hack/update-munge-docs.sh" diff --git a/hack/lib/util.sh b/hack/lib/util.sh index e38c9b3b343..6be0cebc949 100755 --- a/hack/lib/util.sh +++ b/hack/lib/util.sh @@ -208,27 +208,34 @@ kube::util::gen-docs() { touch .generated_docs find . -type f | cut -sd / -f 2- | LC_ALL=C sort > .generated_docs popd > /dev/null +} - while read file; do - # Copy out of KUBE_ROOT if we didn't really change anything - if [[ -e "${dest}/${file}" && -e "${KUBE_ROOT}/${file}" ]]; then - # Filter all munges from original content. - original=$(cat "${KUBE_ROOT}/${file}" | sed '/^