xtask: add html-docs task

This task is a bit annoying to implement because `sphinx-build` depends
on `fish_indent`, so that needs to be built, and the binary location
added to `PATH`.

Building `fish_indent` can be avoided by setting the `--fish-indent`
argument to the path to an existing `fish_indent` executable.

Use the new xtask in CMake builds. To do so without having to add
configuration options about where to put the docs, or having to copy
them from the default location to `build/user_doc`, we instead get rid of
the `user_doc` directory and change the code which accesses the docs to
read them from the non-configurable default output location in Cargo's
target directory.

Part of #12292
This commit is contained in:
Daniel Rainer
2025-08-22 17:24:42 +02:00
committed by Johannes Altmanninger
parent 2f74785620
commit 20cc07c5cd
12 changed files with 141 additions and 75 deletions

View File

@@ -105,21 +105,24 @@ Contributing documentation
==========================
The documentation is stored in ``doc_src/``, and written in ReStructured Text and built with Sphinx.
The builtins and various functions shipped with fish are documented in ``doc_src/cmds/``.
To build it locally, run either::
To build an HTML version of the docs locally, run::
sphinx-build -j auto -b html doc_src/ /tmp/fish-doc/
cargo xtask html-docs
which will output HTML docs to /tmp/fish-doc.
You can open it in a browser and see that it looks okay.
Alternatively, you can use::
will output to ``target/fish-docs/html`` or, if you use CMake::
cmake --build build -t sphinx-docs
which outputs to build/user_doc/html/.
will output to ``build/cargo/fish-docs/html/``. You can also run ``sphinx-build`` directly, which allows choosing the output directory::
sphinx-build -j auto -b html doc_src/ /tmp/fish-doc/
will output HTML docs to ``/tmp/fish-doc``.
After building them, you can open the HTML docs in a browser and see that it looks okay.
The builtins and various functions shipped with fish are documented in doc_src/cmds/.
Code Style
==========