diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 7f4bf2c93..daa39f029 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,6 +3,8 @@ fish 4.2.1 (released ???) This release fixes the following problems identified in 4.2.0: +- When building from a tarball without Sphinx (that is, with ``-DBUILD_DOCS=OFF`` or when ``sphinx-build`` is not found), + builtin man pages and help files were missing, which has been fixed (:issue:`12052`). - ``fish_config``'s theme selector (the "colors" tab) was broken, which has been fixed (:issue:`12053`). fish 4.2.0 (released November 10, 2025) diff --git a/CMakeLists.txt b/CMakeLists.txt index d161def83..764ed19a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,7 @@ set(VARS_FOR_CARGO "${FISH_PCRE2_BUILDFLAG}" "RUSTFLAGS=$ENV{RUSTFLAGS} ${rust_debugflags}" "FISH_SPHINX=${SPHINX_EXECUTABLE}" + "FISH_USE_PREBUILT_DOCS=${USE_PREBUILT_DOCS}" ) # Let fish pick up when we're running out of the build directory without installing diff --git a/build.rs b/build.rs index bfd49a5e4..c0c0365c4 100644 --- a/build.rs +++ b/build.rs @@ -82,6 +82,7 @@ fn detect_cfgs(target: &mut Target) { ("apple", &detect_apple), ("bsd", &detect_bsd), ("using_cmake", &|_| option_env!("FISH_CMAKE_BINARY_DIR").is_some()), + ("use_prebuilt_docs", &|_| env_var("FISH_USE_PREBUILT_DOCS").is_some_and(|v| v == "TRUE") ), ("cygwin", &detect_cygwin), ("small_main_stack", &has_small_stack), // See if libc supports the thread-safe localeconv_l(3) alternative to localeconv(3). diff --git a/build_tools/make_tarball.sh b/build_tools/make_tarball.sh index 7393224f4..d44559a28 100755 --- a/build_tools/make_tarball.sh +++ b/build_tools/make_tarball.sh @@ -66,13 +66,15 @@ PREFIX_TMPDIR=$(mktemp -d) cd "$PREFIX_TMPDIR" echo "$VERSION" > version cmake -G "$BUILD_GENERATOR" -DCMAKE_BUILD_TYPE=Debug "$wd" +mkdir $PWD/user_doc/src FISH_SPHINX_BUILD_DATE=$tag_creation_date \ +FISH_SPHINX_HELP_SECTIONS_OUTPUT=$PWD/user_doc/src/help_sections.rs \ $BUILD_TOOL doc TAR_APPEND="$TAR --append --file=$path --mtime=now --owner=0 --group=0 \ --mode=g+w,a+rX --transform s/^/$prefix\//" $TAR_APPEND --no-recursion user_doc -$TAR_APPEND user_doc/html user_doc/man +$TAR_APPEND user_doc/html user_doc/man user_doc/src/help_sections.rs $TAR_APPEND version cd - diff --git a/cmake/Docs.cmake b/cmake/Docs.cmake index 2fddd0e46..9466adb6d 100644 --- a/cmake/Docs.cmake +++ b/cmake/Docs.cmake @@ -66,6 +66,7 @@ endif() add_feature_info(Documentation INSTALL_DOCS "user manual and documentation") +set(USE_PREBUILT_DOCS FALSE) if(BUILD_DOCS) configure_file("${SPHINX_SRC_DIR}/conf.py" "${SPHINX_BUILD_DIR}/conf.py" @ONLY) add_custom_target(doc ALL @@ -76,6 +77,7 @@ if(BUILD_DOCS) PROPERTY FOLDER cmake/DocTargets) elseif(HAVE_PREBUILT_DOCS) + set(USE_PREBUILT_DOCS TRUE) if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) # Out of tree build - link the prebuilt documentation to the build tree add_custom_target(link_doc ALL) diff --git a/crates/build-man-pages/build.rs b/crates/build-man-pages/build.rs index a07c510b1..eeadac521 100644 --- a/crates/build-man-pages/build.rs +++ b/crates/build-man-pages/build.rs @@ -1,4 +1,4 @@ -use fish_build_helper::env_var; +use fish_build_helper::{env_var, workspace_root}; use std::path::Path; fn main() { @@ -9,6 +9,16 @@ fn main() { let _ = std::fs::create_dir_all(&sec1_dir); let help_sections_path = Path::new(&env_var("OUT_DIR").unwrap()).join("help_sections.rs"); + + if env_var("FISH_USE_PREBUILT_DOCS").is_some_and(|v| v == "TRUE") { + std::fs::copy( + workspace_root().join("user_doc/src/help_sections.rs"), + help_sections_path, + ) + .unwrap(); + return; + } + std::fs::write( help_sections_path.clone(), r#"pub static HELP_SECTIONS: &str = "";"#, @@ -26,8 +36,6 @@ fn build_man(man_dir: &Path, sec1_dir: &Path, help_sections_path: &Path) { process::{Command, Stdio}, }; - use fish_build_helper::workspace_root; - let workspace_root = workspace_root(); let doc_src_dir = workspace_root.join("doc_src"); diff --git a/doc_src/conf.py b/doc_src/conf.py index 12ac5005d..e62e98ef4 100644 --- a/doc_src/conf.py +++ b/doc_src/conf.py @@ -97,7 +97,12 @@ def setup(app): app.add_directive("synopsis", FishSynopsisDirective) app.add_config_value("issue_url", default=None, rebuild="html") - app.add_config_value("fish_help_sections_output", "", "man", str) + app.add_config_value( + "fish_help_sections_output", + default=os.environ.get("FISH_SPHINX_HELP_SECTIONS_OUTPUT", ""), + rebuild="man", + types=str, + ) app.add_role("issue", issue_role) app.connect("builder-inited", remove_fish_indent_lexer) diff --git a/src/builtins/status.rs b/src/builtins/status.rs index 461ebd2ed..ebf1153ae 100644 --- a/src/builtins/status.rs +++ b/src/builtins/status.rs @@ -334,10 +334,19 @@ fn parse_cmd_opts( use rust_embed::RustEmbed; #[cfg(feature = "embed-data")] -#[derive(RustEmbed)] -#[folder = "$FISH_RESOLVED_BUILD_DIR/fish-man/man1"] -#[prefix = "man/man1/"] -struct Docs; +cfg_if!( + if #[cfg(use_prebuilt_docs)] { + #[derive(RustEmbed)] + #[folder = "user_doc/man/man1"] + #[prefix = "man/man1/"] + struct Docs; + } else { + #[derive(RustEmbed)] + #[folder = "$FISH_RESOLVED_BUILD_DIR/fish-man/man1"] + #[prefix = "man/man1/"] + struct Docs; + } +); #[cfg(all(using_cmake, feature = "embed-data"))] #[derive(RustEmbed)]