fix(docs): Port docs generation to bzlmod to fix user facing doc generation (#1193)

This commit is contained in:
James Sharpe 2024-04-11 23:38:00 +01:00 committed by GitHub
parent 5c34b7136f
commit 50b7d9bc94
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 20 additions and 82 deletions

View File

@ -3,5 +3,4 @@
# https://github.com/bazelbuild/stardoc/issues/112
common --incompatible_allow_tags_propagation
common --noenable_bzlmod
build --workspace_status_command=tools/workspace_status.sh

View File

@ -1,5 +1,5 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
load("@stardoc//stardoc:stardoc.bzl", "stardoc")
genrule(
name = "flatten_header_vm",
@ -8,8 +8,9 @@ genrule(
"docs.bzl",
],
outs = ["flatten_header.vm"],
cmd = "$(location gen_header.sh) $(location docs.bzl) $@",
cmd = "PYTHON3=$(PYTHON3) $(location gen_header.sh) $(location docs.bzl) $@",
output_to_bindir = True,
toolchains=["@rules_python//python:current_py_toolchain"],
)
# Note that the stardoc `out` files are prefixed with `stardoc_` so the

12
docs/MODULE.bazel Normal file
View File

@ -0,0 +1,12 @@
bazel_dep(name = "rules_foreign_cc")
local_path_override(
module_name = "rules_foreign_cc",
path = "..",
)
bazel_dep(name = "stardoc", version = "0.6.2", dev_dependency = True)
bazel_dep(name = "rules_python", version = "0.31.0", dev_dependency = True)
bazel_dep(name = "gazelle", version = "0.36.0", dev_dependency = True)
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.5.0", dev_dependency = True)

View File

@ -1,51 +0,0 @@
workspace(name = "rules_foreign_cc_docs")
local_repository(
name = "rules_foreign_cc",
path = "..",
)
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
rules_foreign_cc_dependencies()
load("//:stardoc_repository.bzl", "stardoc_repository")
stardoc_repository()
load("//:stardoc_deps.bzl", "stardoc_deps")
stardoc_deps()
# Gazelle dependencies
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "bazel_gazelle",
sha256 = "b7387f72efb59f876e4daae42f1d3912d0d45563eac7cb23d1de0b094ab588cf",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.34.0/bazel-gazelle-v0.34.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.34.0/bazel-gazelle-v0.34.0.tar.gz",
],
)
http_archive(
name = "bazel_skylib_gazelle_plugin",
sha256 = "747addf3f508186234f6232674dd7786743efb8c68619aece5fb0cac97b8f415",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-gazelle-plugin-1.5.0.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-gazelle-plugin-1.5.0.tar.gz",
],
)
load("@bazel_skylib_gazelle_plugin//:workspace.bzl", "bazel_skylib_gazelle_plugin_workspace")
bazel_skylib_gazelle_plugin_workspace()
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("@bazel_skylib_gazelle_plugin//:setup.bzl", "bazel_skylib_gazelle_plugin_setup")
bazel_skylib_gazelle_plugin_setup()
gazelle_dependencies(go_repository_default_config = "//:WORKSPACE.bazel")

View File

@ -20,7 +20,7 @@ TABLE_OF_CONTENTS=$(grep "=" "$1" \
| sed '/^$/d' \
| sed '/^#/d' \
| sed 's/ = .*//' \
| python -c 'import sys; print("\n".join(["- [{}](#{})".format(symbol.strip(), symbol.strip().lower()) for symbol in sys.stdin.readlines()]))' \
| ${PYTHON3} -c 'import sys; print("\n".join(["- [{}](#{})".format(symbol.strip(), symbol.strip().lower()) for symbol in sys.stdin.readlines()]))' \
| sort -f
)

View File

@ -1,7 +0,0 @@
"""A wrapper for defining stardoc dependencies to make instantiating
it in a WORKSPACE file more consistent
"""
load("@io_bazel_stardoc//:setup.bzl", _stardoc_repositories = "stardoc_repositories")
stardoc_deps = _stardoc_repositories

View File

@ -1,15 +0,0 @@
"""A module for defining the stardoc repository"""
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
def stardoc_repository():
maybe(
http_archive,
name = "io_bazel_stardoc",
sha256 = "3fd8fec4ddec3c670bd810904e2e33170bedfe12f90adf943508184be458c8bb",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/stardoc/releases/download/0.5.3/stardoc-0.5.3.tar.gz",
"https://github.com/bazelbuild/stardoc/releases/download/0.5.3/stardoc-0.5.3.tar.gz",
],
)

View File

@ -20,6 +20,7 @@ bzl_library(
srcs = ["cmake.bzl"],
visibility = ["//visibility:public"],
deps = [
"//foreign_cc/built_tools:cmake_build",
"//foreign_cc/private:cc_toolchain_util",
"//foreign_cc/private:cmake_script",
"//foreign_cc/private:detect_root",
@ -74,6 +75,7 @@ bzl_library(
srcs = ["make.bzl"],
visibility = ["//visibility:public"],
deps = [
"//foreign_cc/built_tools:make_build",
"//foreign_cc/private:cc_toolchain_util",
"//foreign_cc/private:detect_root",
"//foreign_cc/private:framework",
@ -104,6 +106,7 @@ bzl_library(
srcs = ["ninja.bzl"],
visibility = ["//visibility:public"],
deps = [
"//foreign_cc/built_tools:ninja_build",
"//foreign_cc/private:detect_root",
"//foreign_cc/private:framework",
"//toolchains/native_tools:tool_access",

View File

@ -4,7 +4,6 @@ bzl_library(
name = "cmake_build",
srcs = ["cmake_build.bzl"],
visibility = ["//visibility:public"],
deps = ["//foreign_cc:defs"],
)
bzl_library(

View File

@ -75,10 +75,7 @@ bzl_library(
bzl_library(
name = "detect_root",
srcs = ["detect_root.bzl"],
visibility = [
"//foreign_cc:__subpackages__",
"//test:__subpackages__",
],
visibility = ["//foreign_cc:__subpackages__"],
)
bzl_library(