From 0897c6aa133181be0bf5cb6cb11c7d111dc87ccd Mon Sep 17 00:00:00 2001 From: James Lamb Date: Mon, 11 Aug 2025 10:31:51 -0500 Subject: [PATCH 1/2] post-processing: prevent early exit in customization --- ci/customization/customize_doc.py | 21 +++++++++++++++----- ci/customization/customize_docs_in_folder.sh | 4 ++-- ci/post-process.sh | 6 +++--- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/ci/customization/customize_doc.py b/ci/customization/customize_doc.py index 4369db12a32..1229e904bb4 100644 --- a/ci/customization/customize_doc.py +++ b/ci/customization/customize_doc.py @@ -257,6 +257,15 @@ def delete_existing_elements(soup): delete_element(soup, element) +class UnsupportedThemeError(ValueError): + """ + Custom exception indicating that a document uses a Sphinx theme this script + either cannot identify or does not know how to modify. + """ + + pass + + def get_theme_info(soup, *, filepath: str): """ Determines what theme a given HTML file is using or exits if it's @@ -279,11 +288,9 @@ def get_theme_info(soup, *, filepath: str): if soup.select(pydata_identifier): return "pydata", soup.select(pydata_identifier)[0] - print( - f"Couldn't identify {filepath} as a supported theme type. Skipping file.", - file=sys.stderr, + raise UnsupportedThemeError( + f"Couldn't identify {filepath} as a supported theme type. Skipping file." ) - exit(0) def main(*, filepath: str, lib_path_dict: dict, versions_dict: dict[str, str]) -> None: @@ -304,7 +311,11 @@ def main(*, filepath: str, lib_path_dict: dict, versions_dict: dict[str, str]) - with open(filepath) as fp: soup = BeautifulSoup(fp, "html5lib") - doc_type, reference_el = get_theme_info(soup, filepath=filepath) + try: + doc_type, reference_el = get_theme_info(soup, filepath=filepath) + except UnsupportedThemeError as err: + print(f"{str(err)}", file=sys.stderr) + return # Delete any existing added/unnecessary elements delete_existing_elements(soup) diff --git a/ci/customization/customize_docs_in_folder.sh b/ci/customization/customize_docs_in_folder.sh index 1069dc5f4bb..831891aaf72 100755 --- a/ci/customization/customize_docs_in_folder.sh +++ b/ci/customization/customize_docs_in_folder.sh @@ -14,7 +14,7 @@ # Positional Arguments: # 1) FOLDER_TO_CUSTOMIZE: project root relative folder to customize (i.e. api/, api/rmm, etc.) ####################################### -set -e +set -euo pipefail display_usage() { echo "Usage:" @@ -51,5 +51,5 @@ grep "${JTD_SEARCH_TERM}\|${DOXYGEN_SEARCH_TERM}\|${PYDATA_SEARCH_TERM}" -rl \ > "${MANIFEST_FILE}" echo "Customizing $(wc -l < ${MANIFEST_FILE} | tr -d ' ') HTML files" -python ${SCRIPT_SRC_FOLDER}/customize_doc.py "${MANIFEST_FILE}" +python -u ${SCRIPT_SRC_FOLDER}/customize_doc.py "${MANIFEST_FILE}" echo "Done customizing" diff --git a/ci/post-process.sh b/ci/post-process.sh index 740e163c590..440f9674f4a 100755 --- a/ci/post-process.sh +++ b/ci/post-process.sh @@ -7,10 +7,10 @@ set -euo pipefail CURRENT_DIR=$(dirname $(realpath $0)) -pip install -r "${CURRENT_DIR}/customization/requirements.txt" +# pip install -r "${CURRENT_DIR}/customization/requirements.txt" -"${CURRENT_DIR}"/update_symlinks.sh +# "${CURRENT_DIR}"/update_symlinks.sh -"${CURRENT_DIR}"/customization/lib_map.sh +# "${CURRENT_DIR}"/customization/lib_map.sh "${CURRENT_DIR}"/customization/customize_docs_in_folder.sh "_site/api" From e529933ed2da1260934ec4578d009336140548ca Mon Sep 17 00:00:00 2001 From: James Lamb Date: Mon, 11 Aug 2025 11:17:07 -0500 Subject: [PATCH 2/2] uncomment --- ci/post-process.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/post-process.sh b/ci/post-process.sh index 440f9674f4a..740e163c590 100755 --- a/ci/post-process.sh +++ b/ci/post-process.sh @@ -7,10 +7,10 @@ set -euo pipefail CURRENT_DIR=$(dirname $(realpath $0)) -# pip install -r "${CURRENT_DIR}/customization/requirements.txt" +pip install -r "${CURRENT_DIR}/customization/requirements.txt" -# "${CURRENT_DIR}"/update_symlinks.sh +"${CURRENT_DIR}"/update_symlinks.sh -# "${CURRENT_DIR}"/customization/lib_map.sh +"${CURRENT_DIR}"/customization/lib_map.sh "${CURRENT_DIR}"/customization/customize_docs_in_folder.sh "_site/api"