Skip to content

Commit 353b063

Browse files
committed
feat: improve our docs generation
Move out of stardoc and start using something supported by BCR as suggested by https://github.com/bazelbuild/bazel-central-registry/blob/main/docs/stardoc.md
1 parent b65df06 commit 353b063

File tree

11 files changed

+38
-76
lines changed

11 files changed

+38
-76
lines changed

.github/workflows/release_prep.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ tar --file $ARCHIVE_TMP --append ${PREFIX}/MODULE.bazel
6262
gzip < $ARCHIVE_TMP > $ARCHIVE
6363
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')
6464

65+
# Add generated API docs to the release, see https://github.com/bazelbuild/bazel-central-registry/issues/5593
66+
docs="$(mktemp -d)"; targets="$(mktemp)"
67+
bazel --output_base="$docs" query --output=label --output_file="$targets" 'kind("starlark_doc_extract rule", //...)'
68+
bazel --output_base="$docs" build --target_pattern_file="$targets"
69+
tar --create --auto-compress \
70+
--directory "$(bazel --output_base="$docs" info bazel-bin)" \
71+
--file "$GITHUB_WORKSPACE/${ARCHIVE%.tar.gz}.docs.tar.gz" .
72+
6573
# Set by GH actions, see
6674
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
6775
REPO_URL="${GITHUB_REPOSITORY:-rmohr/bazeldnf}"

BUILD.bazel

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
1+
load("@bazel_lib//:bzl_library.bzl", "bzl_library")
22
load("@buildifier_prebuilt//:rules.bzl", "buildifier")
33
load("@gazelle//:def.bzl", "gazelle", "gazelle_binary")
44
load("@rules_cc//cc:defs.bzl", "cc_library")
@@ -18,6 +18,7 @@ gazelle_binary(
1818
# gazelle:prefix github.com/rmohr/bazeldnf
1919
# gazelle:resolve go github.com/bazelbuild/buildtools/build @com_github_bazelbuild_buildtools//build:go_default_library
2020
# gazelle:resolve go github.com/bazelbuild/buildtools/edit @com_github_bazelbuild_buildtools//edit:go_default_library
21+
# gazelle:map_kind bzl_library bzl_library @bazel_lib//:bzl_library.bzl
2122
gazelle(
2223
name = "gazelle",
2324
args = [
@@ -93,12 +94,4 @@ bzl_library(
9394
deps = ["@bazeldnf//bazeldnf:defs"],
9495
)
9596

96-
bzl_library(
97-
name = "deps",
98-
srcs = ["deps.bzl"],
99-
visibility = ["//visibility:public"],
100-
deps = [
101-
"@bazeldnf//bazeldnf:defs",
102-
"@bazeldnf//bazeldnf:deps",
103-
],
104-
)
97+
# gazelle:exclude deps.bzl

MODULE.bazel

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ register_toolchains("@bazeldnf_toolchains//:all")
2020
bazel_dep(name = "bazel_skylib", version = "1.9.0")
2121
bazel_dep(name = "platforms", version = "1.0.0")
2222
bazel_dep(name = "bazel_features", version = "1.41.0")
23+
bazel_dep(name = "bazel_lib", version = "3.2.0")
2324

2425
# if someone wants to build the bazeldnf toolchain from sources needs this set of dependencies
2526
bazel_dep(name = "gazelle", version = "0.47.0")
@@ -94,6 +95,4 @@ bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.9.0", dev_dependenc
9495
bazel_dep(name = "aspect_bazel_lib", version = "2.22.5", dev_dependency = True)
9596
bazel_dep(name = "buildifier_prebuilt", version = "8.2.1.2", dev_dependency = True)
9697
bazel_dep(name = "rules_pkg", version = "1.2.0", dev_dependency = True)
97-
bazel_dep(name = "stardoc", version = "0.8.1", dev_dependency = True)
98-
bazel_dep(name = "rules_java", version = "9.5.0", dev_dependency = True)
9998
bazel_dep(name = "rules_cc", version = "0.2.16", dev_dependency = True)

bazeldnf/BUILD.bazel

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
1+
load("@bazel_lib//:bzl_library.bzl", "bzl_library")
22
load("//bazeldnf/private:resolved_bazeldnf_toolchain.bzl", "resolved_bazeldnf_toolchain")
33

44
# this directory contains the public API from bazeldnf, anything on this directory
@@ -16,14 +16,8 @@ resolved_bazeldnf_toolchain(
1616
visibility = ["//visibility:public"],
1717
)
1818

19-
bzl_library(
20-
name = "alias_macros",
21-
srcs = ["alias_macros.bzl"],
22-
visibility = ["//visibility:public"],
23-
deps = [
24-
"//internal:rpm",
25-
],
26-
)
19+
# gazelle:exclude deps.bzl
20+
# gazelle:exclude alias_macros.bzl
2721

2822
bzl_library(
2923
name = "defs",
@@ -37,13 +31,6 @@ bzl_library(
3731
],
3832
)
3933

40-
bzl_library(
41-
name = "deps",
42-
srcs = ["deps.bzl"],
43-
visibility = ["//visibility:public"],
44-
deps = [":repositories"],
45-
)
46-
4734
bzl_library(
4835
name = "extensions",
4936
srcs = ["extensions.bzl"],
@@ -55,6 +42,14 @@ bzl_library(
5542
],
5643
)
5744

45+
exports_files(
46+
[
47+
"defs.bzl",
48+
"deps.bzl",
49+
],
50+
visibility = ["//:__subpackages__"],
51+
)
52+
5853
bzl_library(
5954
name = "repositories",
6055
srcs = ["repositories.bzl"],
@@ -64,19 +59,12 @@ bzl_library(
6459
"//bazeldnf/private:toolchains_repo",
6560
"//tools:integrity",
6661
"//tools:version",
62+
"@bazel_tools//tools/build_defs/repo:cache.bzl", # keep
6763
"@bazel_tools//tools/build_defs/repo:http.bzl",
6864
"@bazel_tools//tools/build_defs/repo:utils.bzl",
6965
],
7066
)
7167

72-
exports_files(
73-
[
74-
"defs.bzl",
75-
"deps.bzl",
76-
],
77-
visibility = ["//:__subpackages__"],
78-
)
79-
8068
bzl_library(
8169
name = "platforms",
8270
srcs = ["platforms.bzl"],

bazeldnf/extensions.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ based on: https://github.com/bazel-contrib/rules-template/blob/0dadcb716f06f6728
66
"""
77

88
load("@bazel_features//:features.bzl", "bazel_features")
9-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_jar")
109
load("//internal:rpm.bzl", rpm_repository = "rpm")
1110
load(":repositories.bzl", "bazeldnf_register_toolchains")
1211

bazeldnf/private/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
1+
load("@bazel_lib//:bzl_library.bzl", "bzl_library")
22

33
bzl_library(
44
name = "toolchains_repo",

bazeldnf/repositories.bzl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ def bazeldnf_dependencies():
3838
],
3939
sha256 = "218efe8ee736d26a3572663b374a253c012b716d8af0c07e842e82f238a0a7ee",
4040
)
41+
http_archive(
42+
name = "bazel_lib",
43+
sha256 = "e733937de2f542436c5d3d618e22c638489b40dfd251284050357babe71103d7",
44+
strip_prefix = "bazel-lib-3.2.0",
45+
url = "https://github.com/bazel-contrib/bazel-lib/releases/download/v3.2.0/bazel-lib-v3.2.0.tar.gz",
46+
)
4147

4248
########
4349
# Remaining content of the file is only used to support toolchains.
@@ -77,7 +83,9 @@ def bazeldnf_register_toolchains(name, register = True, **kwargs):
7783
- TODO: create a convenience repository for the host platform like "bazeldnf_host"
7884
- create a repository exposing toolchains for each platform like "bazeldnf_platforms"
7985
- register a toolchain pointing at each platform
86+
8087
Users can avoid this macro and do these steps themselves, if they want more control.
88+
8189
Args:
8290
name: base name for all created repos, like "bazeldnf1_14"
8391
register: whether to call through to native.register_toolchains.

docs/BUILD.bazel

Lines changed: 0 additions & 23 deletions
This file was deleted.

internal/BUILD.bazel

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
1+
load("@bazel_lib//:bzl_library.bzl", "bzl_library")
22

33
exports_files(["runner.bash.template"])
44

@@ -7,6 +7,7 @@ bzl_library(
77
srcs = ["bazeldnf.bzl"],
88
visibility = ["//:__subpackages__"],
99
deps = [
10+
"//bazeldnf:toolchain",
1011
"@bazel_skylib//lib:shell",
1112
],
1213
)
@@ -23,6 +24,7 @@ bzl_library(
2324
srcs = ["rpmtree.bzl"],
2425
visibility = ["//:__subpackages__"],
2526
deps = [
27+
":rpm",
2628
"//bazeldnf:toolchain",
2729
"@bazel_skylib//lib:paths",
2830
],

tools/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
1+
load("@bazel_lib//:bzl_library.bzl", "bzl_library")
22

33
bzl_library(
44
name = "integrity",

0 commit comments

Comments
 (0)