From 2343a6b1f19f891cd4ed243ab7b845b4c6c806b6 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Mon, 18 Nov 2024 21:37:50 +0100 Subject: [PATCH] docs: Read version from the version file Makes it possible to generate the man pages without fish_indent available. (not the html docs because they highlight via fish_indent!) --- build.rs | 8 ++++---- cmake/Docs.cmake | 4 ++-- doc_src/conf.py | 13 ++++++++++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/build.rs b/build.rs index ecfc1d397..f9912ce57 100644 --- a/build.rs +++ b/build.rs @@ -29,12 +29,12 @@ fn main() { .unwrap(), ); + let version = &get_version(&env::current_dir().unwrap()); // Per https://doc.rust-lang.org/cargo/reference/build-scripts.html#inputs-to-the-build-script, // the source directory is the current working directory of the build script - rsconf::set_env_value( - "FISH_BUILD_VERSION", - &get_version(&env::current_dir().unwrap()), - ); + rsconf::set_env_value("FISH_BUILD_VERSION", version); + + std::env::set_var("FISH_BUILD_VERSION", version); rsconf::rebuild_if_path_changed("src/libc.c"); cc::Build::new() diff --git a/cmake/Docs.cmake b/cmake/Docs.cmake index 2a3faf896..8b1455b7f 100644 --- a/cmake/Docs.cmake +++ b/cmake/Docs.cmake @@ -29,7 +29,7 @@ add_custom_target(sphinx-docs # sphinx-manpages needs the fish_indent binary for the version number add_custom_target(sphinx-manpages - env PATH="${CMAKE_BINARY_DIR}:$$PATH" + env FISH_BUILD_VERSION_FILE="${CMAKE_CURRENT_BINARY_DIR}/${FBVF}" ${SPHINX_EXECUTABLE} -j auto -q -b man @@ -38,7 +38,7 @@ add_custom_target(sphinx-manpages "${SPHINX_SRC_DIR}" # TODO: This only works if we only have section 1 manpages. "${SPHINX_MANPAGE_DIR}/man1" - DEPENDS fish_indent + DEPENDS CHECK-FISH-BUILD-VERSION-FILE COMMENT "Building man pages with Sphinx") if(SPHINX_EXECUTABLE) diff --git a/doc_src/conf.py b/doc_src/conf.py index 081979458..21fbafd24 100644 --- a/doc_src/conf.py +++ b/doc_src/conf.py @@ -65,9 +65,16 @@ issue_url = "https://github.com/fish-shell/fish-shell/issues" # Parsing FISH-BUILD-VERSION-FILE is possible but hard to ensure that it is in the right place # fish_indent is guaranteed to be on PATH for the Pygments highlighter anyway -ret = subprocess.check_output( - ("fish_indent", "--version"), stderr=subprocess.STDOUT -).decode("utf-8") +if "FISH_BUILD_VERSION_FILE" in os.environ: + f = open(os.environ["FISH_BUILD_VERSION_FILE"], "r") + ret = f.readline().strip() +elif "FISH_BUILD_VERSION" in os.environ: + ret = os.environ["FISH_BUILD_VERSION"] +else: + ret = subprocess.check_output( + ("fish_indent", "--version"), stderr=subprocess.STDOUT + ).decode("utf-8") + # The full version, including alpha/beta/rc tags release = ret.strip().split(" ")[-1] # The short X.Y version