docs: use stardoc proto output to generate markdown docs (#1629)
The template language Stardoc uses (Velocity) is niche and fairly
esoteric, and requires a lot of experimenting to understand how to
make it produce the desired output. In particular, it largely assumes
whitespace doesn't matter, which makes it a poor fit for generating
Markdown, where whitespace often does matter.
Instead, a small Python program is used to consume the binary proto
output of Stardoc, which converts it to Markdown. This also makes it
easier to customize the overall output and re-use code for the different
types of objects rendered.
The visible changes to the docs are:
* Module extensions are now documented
* Repository rules follow the style of the other generated docs
* Fixed the rendering of pip_repository docs -- it had an h2
section which broke the section grouping of the API objects.
* Puts some padding between the border and content for text in
params/attrs/fields listings.
Other notable changes:
* Make RTD builds use bzlmod. This is necessary so that the pip
extension can be documented. It loads
`@pythons_hub//:interpreters.bzl`, but that repo is only created
when bzlmod is enabled)
---------
Co-authored-by: Ignas Anikevicius <240938+aignas@users.noreply.github.com>diff --git a/WORKSPACE b/WORKSPACE
index 074a7b9..b8e778e 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -109,7 +109,7 @@
# Install sphinx for doc generation.
pip_parse(
- name = "docs_deps",
+ name = "dev_pip",
experimental_requirement_cycles = {
"sphinx": [
"sphinx",
@@ -126,7 +126,7 @@
requirements_lock = "//docs/sphinx:requirements_linux.txt",
)
-load("@docs_deps//:requirements.bzl", docs_install_deps = "install_deps")
+load("@dev_pip//:requirements.bzl", docs_install_deps = "install_deps")
docs_install_deps()
@@ -140,3 +140,9 @@
"https://files.pythonhosted.org/packages/50/67/3e966d99a07d60a21a21d7ec016e9e4c2642a86fea251ec68677daf71d4d/numpy-1.25.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
],
)
+
+# rules_proto expects //external:python_headers to point at the python headers.
+bind(
+ name = "python_headers",
+ actual = "//python/cc:current_py_cc_headers",
+)