diff --git a/build_docs b/build_docs index 03d488d..16bdb3f 100755 --- a/build_docs +++ b/build_docs @@ -1,18 +1,31 @@ #!/usr/bin/env bash set -e +# $scriptname will already be set if build_docs is getting called from build_docs_to_publish. +# Otherwise, we need to set it to the basename of this script. +if [[ -z "${scriptname}" ]]; then + scriptname="${0##*/}" +fi + if [ ! -e doc-builder ]; then # We're in the doc-builder directory itself - script="./tools/build_docs.py" + script="./tools/${scriptname}.py" files_to_copy_to_source="conf.py substitutions.py _templates _static" cp -a ${files_to_copy_to_source} source/ else - # We're in a repo that has doc-builder as a submodule - script="./doc-builder/tools/build_docs.py" + # We're in a repo that *includes* doc-builder + script="./doc-builder/tools/${scriptname}.py" - # Make sure the submodule is checked out. For now, we assume the repo is using git-fleximod to - # manage submodules. - "$(git rev-parse --show-toplevel)"/bin/git-fleximod update doc-builder + # Make sure the doc-builder submodule is checked out. If doc-builder isn't a submodule but is + # instead manually included, we will perform the `else`, which is safe because it's a no-op in + # that situation. + # (Assume that if the repo uses git-fleximod, doc-builder is handled with it.) + git_fleximod_path="$(git rev-parse --show-toplevel)/bin/git-fleximod" + if [[ -e "${git_fleximod_path}" ]]; then + "${git_fleximod_path}" update doc-builder + else + git submodule update --init -- doc-builder + fi fi # Check if --verbose or -V was passed diff --git a/build_docs_to_publish b/build_docs_to_publish index d5eeaf7..6928d51 100755 --- a/build_docs_to_publish +++ b/build_docs_to_publish @@ -1,51 +1,4 @@ #!/usr/bin/env bash set -e -if [ ! -e doc-builder ]; then - # We're in the doc-builder directory itself - script="./tools/build_docs_to_publish.py" - files_to_copy_to_source="conf.py substitutions.py _templates _static" - cp -a ${files_to_copy_to_source} source/ -else - # We're in a repo that has doc-builder as a submodule - script="./doc-builder/tools/build_docs_to_publish.py" - - # Make sure the submodule is checked out. For now, we assume the repo is using git-fleximod to - # manage submodules. - "$(git rev-parse --show-toplevel)"/bin/git-fleximod update doc-builder -fi - -# Check if --verbose or -V was passed -verbose=false -for arg in "$@"; do - case "$arg" in - --verbose|-V) verbose=true; break ;; - esac -done - -cd "${script_dir}" - -if $verbose; then - echo "Running: make fetch-images" - make fetch-images -else - make fetch-images > /dev/null 2>&1 -fi - -if $verbose; then - echo "Running: ${script} $@" - pwd -fi -set +e -${script} "$@" -exit_code=$? -set -e - -if [ ! -e doc-builder ]; then - # Clean up these things we copied - for f in ${files_to_copy_to_source}; do - rm -r "source/$f" - done -fi - -exit $exit_code +. ./build_docs build_docs_to_publish diff --git a/tools/build_docs_to_publish.py b/tools/build_docs_to_publish.py index 6a42e05..3163357 100755 --- a/tools/build_docs_to_publish.py +++ b/tools/build_docs_to_publish.py @@ -78,7 +78,6 @@ def setup_this_ref(args): permanent_files.append("doc-builder") # Check some things about "permanent" files before checkout - print(f"{os.getcwd()=}") for filename in permanent_files: check_permanent_file(filename) @@ -130,7 +129,7 @@ def checkout_and_build(version, permanent_files, args): build_args += ["--container-cli-tool", args.container_cli_tool] if args.verbose: build_args.append("--verbose") - print(" ".join(build_args)) + print(f"build_logs command-line args: {build_args}") build_docs(build_args)