Skip to content

Commit f253347

Browse files
authored
[maintenance] Move all docs-related targets to the docs folder, mark stardoc as a dev dependency (#1435)
1 parent 12b8069 commit f253347

File tree

7 files changed

+48
-46
lines changed

7 files changed

+48
-46
lines changed

.bazelci/presubmit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ tasks:
7373
name: Stardoc api documentation
7474
platform: rbe_ubuntu2404
7575
build_targets:
76-
- //kotlin:stardoc
76+
- //docs:stardoc
7777
test_targets:
7878
- //docs/...
7979
ktlint:

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ maven.override(
133133
use_repo(maven, "kotlin_rules_maven", "unpinned_kotlin_rules_maven")
134134

135135
bazel_dep(name = "rules_pkg", version = "1.0.1")
136-
bazel_dep(name = "stardoc", version = "0.8.0", repo_name = "io_bazel_stardoc")
137136

137+
bazel_dep(name = "stardoc", version = "0.8.0", dev_dependency = True, repo_name = "io_bazel_stardoc")
138138
bazel_dep(name = "aspect_bazel_lib", version = "2.22.0", dev_dependency = True)
139139
bazel_dep(name = "rules_testing", version = "0.9.0", dev_dependency = True)
140140
bazel_dep(name = "rules_bazel_integration_test", version = "0.34.0", dev_dependency = True)

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ deps.regen:
3030
scripts/regen_deps
3131

3232
docs.regen:
33-
bazel build //kotlin:stardoc
34-
cp bazel-bin/kotlin/kotlin.md docs/kotlin.md
33+
bazel run //docs:write_docs
3534

3635
proto.regen:
3736
scripts/gen_proto_jars

docs/BUILD.bazel

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,40 @@
11
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
2+
load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
3+
4+
[
5+
stardoc(
6+
name = doc,
7+
out = "%s.md" % doc,
8+
input = "//kotlin:%s.bzl" % doc,
9+
deps = [
10+
"//kotlin/internal",
11+
],
12+
)
13+
for doc in [
14+
"jvm",
15+
"lint",
16+
"core",
17+
"repositories.doc",
18+
]
19+
]
20+
21+
genrule(
22+
name = "stardoc",
23+
srcs = [doc for doc in [
24+
"jvm",
25+
"lint",
26+
"core",
27+
"repositories.doc",
28+
]],
29+
outs = ["kotlin.md.generated"],
30+
cmd = """
31+
cat $(SRCS) >> $@
32+
""",
33+
)
234

335
write_source_files(
436
name = "write_docs",
537
files = {
6-
"kotlin.md": "//kotlin:stardoc",
38+
"kotlin.md": ":stardoc",
739
},
840
)

kotlin/BUILD

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
2-
31
# Copyright 2018 The Bazel Authors. All rights reserved.
42
#
53
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,6 +13,13 @@ load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
1513
# limitations under the License.
1614
load("//src/main/starlark/release:packager.bzl", "release_archive")
1715

16+
exports_files([
17+
"jvm.bzl",
18+
"lint.bzl",
19+
"core.bzl",
20+
"repositories.doc.bzl",
21+
])
22+
1823
release_archive(
1924
name = "pkg",
2025
srcs = glob(
@@ -32,38 +37,3 @@ release_archive(
3237
"//kotlin/settings:pkg",
3338
],
3439
)
35-
36-
[
37-
stardoc(
38-
name = doc,
39-
out = "%s.md" % doc,
40-
input = "%s.bzl" % doc,
41-
deps = [
42-
"//kotlin/internal",
43-
],
44-
)
45-
for doc in [
46-
"jvm",
47-
"lint",
48-
"core",
49-
"repositories.doc",
50-
]
51-
]
52-
53-
genrule(
54-
name = "stardoc",
55-
srcs = [doc for doc in [
56-
"jvm",
57-
"lint",
58-
"core",
59-
"repositories.doc",
60-
]],
61-
outs = ["kotlin.md"],
62-
cmd = """
63-
cat $(SRCS) >> $@
64-
""",
65-
executable = True,
66-
visibility = [
67-
"//visibility:public",
68-
],
69-
)

kotlin/internal/BUILD

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ release_archive(
3737
bzl_library(
3838
name = "internal",
3939
srcs = glob(["*.bzl"]),
40-
visibility = ["//kotlin:__subpackages__"],
40+
visibility = [
41+
"//docs:__pkg__",
42+
"//kotlin:__subpackages__",
43+
],
4144
deps = [
4245
"//kotlin/internal/jvm",
4346
"//kotlin/internal/lint",

scripts/generate_docs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
#!/usr/bin/env bash
22

3-
bazel build //kotlin:stardoc || fail "docs did not generate"
4-
5-
cp -f bazel-bin/kotlin/kotlin.md docs/ || fail "couldn't copy"
3+
bazel run //docs:write_docs || fail "docs did not generate"

0 commit comments

Comments
 (0)