Skip to content

Commit fe1d1c0

Browse files
committed
Fix stardoc to document rules, not the wrapping macros
1 parent d730f75 commit fe1d1c0

30 files changed

Lines changed: 162 additions & 168 deletions

File tree

‎BUILD.bazel‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
22
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
3-
load("@build_bazel_rules_nodejs//:defs.bzl", "npm_package")
3+
load("@build_bazel_rules_nodejs//:defs.bzl", "COMMON_REPLACEMENTS", "npm_package")
44

55
package(default_visibility = ["//visibility:public"])
66

@@ -9,7 +9,7 @@ exports_files(["tsconfig.json"])
99
bzl_library(
1010
name = "bzl",
1111
srcs = ["defs.bzl"],
12-
visibility = ["//visibility:public"], #["@npm_bazel_typescript//:__subpackages__"],
12+
visibility = ["//visibility:public"],
1313
deps = [
1414
"//internal/history-server:bzl",
1515
"//internal/http-server:bzl",
@@ -38,6 +38,7 @@ npm_package(
3838
# Don't replace the default 0.0.0-PLACEHOLDER for this npm_package since
3939
# we are packaging up the packager itself and this replacement will break it
4040
replace_with_version = "",
41+
replacements = COMMON_REPLACEMENTS,
4142
deps = [
4243
"//third_party/github.com/bazelbuild/bazel-skylib:package_contents",
4344
"//third_party/github.com/buffer-from:package_contents",
@@ -69,6 +70,7 @@ npm_package(
6970
# Don't replace the default 0.0.0-PLACEHOLDER for this npm_package since
7071
# we are packaging up the packager itself and this replacement will break it
7172
replace_with_version = "",
73+
replacements = COMMON_REPLACEMENTS,
7274
)
7375

7476
# This artifact is published to GitHub along with each release

‎defs.bzl‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ history_server = _history_server
4343
http_server = _http_server
4444
# ANY RULES ADDED HERE SHOULD BE DOCUMENTED, run yarn skydoc to verify
4545

46+
# Allows us to avoid a transitive dependency on bazel_skylib from leaking to users
47+
def dummy_bzl_library(name, **kwargs):
48+
native.filegroup(name = name)
49+
50+
COMMON_REPLACEMENTS = {
51+
# Replace loads from @bazel_skylib with the dummy rule above
52+
"(load\\(\"@bazel_skylib//:bzl_library.bzl\", \"bzl_library\"\\))": "# bazel_skylib mocked out\n# $1\nload(\"@build_bazel_rules_nodejs//:defs.bzl\", bzl_library = \"dummy_bzl_library\")",
53+
}
54+
4655
def node_modules_filegroup(packages, patterns = [], **kwargs):
4756
native.filegroup(
4857
srcs = native.glob(["/".join([

‎internal/common/BUILD.bazel‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ licenses(["notice"]) # Apache 2.0
1818

1919
package(default_visibility = ["//internal:__subpackages__"])
2020

21-
# Exported to be consumed for generating skydoc.
22-
exports_files(["check_bazel_version.bzl"])
23-
2421
bzl_library(
2522
name = "bzl",
2623
srcs = glob(["*.bzl"]),
27-
visibility = ["//visibility:public"], #["@npm_bazel_typescript//:__subpackages__"],
24+
visibility = ["//visibility:public"],
2825
)
2926

27+
# Exported to be consumed for generating skydoc.
28+
exports_files(["check_bazel_version.bzl"])
29+
3030
py_test(
3131
name = "check_version_test",
3232
size = "small",

‎internal/history-server/BUILD.bazel‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
1616

1717
package(default_visibility = ["//visibility:public"])
1818

19-
exports_files([
20-
# Exported to be consumed for generating skydoc.
21-
"history_server.bzl",
22-
])
23-
2419
bzl_library(
2520
name = "bzl",
2621
srcs = glob(["*.bzl"]),
27-
visibility = ["//visibility:public"], #["@npm_bazel_typescript//:__subpackages__"],
22+
visibility = ["//visibility:public"],
2823
deps = ["//internal/node:bzl"],
2924
)
3025

26+
exports_files([
27+
# Exported to be consumed for generating skydoc.
28+
"history_server.bzl",
29+
])
30+
3131
filegroup(
3232
name = "package_contents",
3333
srcs = glob(["*"]),

‎internal/http-server/BUILD.bazel‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,17 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
1616

1717
package(default_visibility = ["//visibility:public"])
1818

19-
exports_files([
20-
# Exported to be consumed for generating skydoc.
21-
"http_server.bzl",
22-
])
23-
2419
bzl_library(
2520
name = "bzl",
2621
srcs = glob(["*.bzl"]),
27-
visibility = ["//visibility:public"], #["@npm_bazel_typescript//:__subpackages__"],
28-
deps = [
29-
# "//internal/node:bzl",
30-
],
22+
visibility = ["//visibility:public"],
3123
)
3224

25+
exports_files([
26+
# Exported to be consumed for generating skydoc.
27+
"http_server.bzl",
28+
])
29+
3330
filegroup(
3431
name = "package_contents",
3532
srcs = glob(["*"]),

‎internal/jasmine_node_test/BUILD.bazel‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,18 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
1616

1717
package(default_visibility = ["//visibility:public"])
1818

19+
bzl_library(
20+
name = "bzl",
21+
srcs = glob(["*.bzl"]),
22+
visibility = ["//visibility:public"],
23+
)
24+
1925
exports_files([
2026
"jasmine_runner.js",
2127
# Exported to be consumed for generating skydoc.
2228
"jasmine_node_test.bzl",
2329
])
2430

25-
bzl_library(
26-
name = "bzl",
27-
srcs = glob(["*.bzl"]),
28-
visibility = ["//visibility:public"], #["@npm_bazel_typescript//:__subpackages__"],
29-
deps = [
30-
# "//internal/node:bzl",
31-
],
32-
)
33-
3431
filegroup(
3532
name = "package_contents",
3633
srcs = glob(["*"]),

‎internal/js_library/BUILD.bazel‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
22

3+
bzl_library(
4+
name = "bzl",
5+
srcs = glob(["*.bzl"]),
6+
visibility = ["//visibility:public"],
7+
)
8+
39
filegroup(
410
name = "package_contents",
511
srcs = glob(["*"]),
612
visibility = ["//:__pkg__"],
713
)
8-
9-
bzl_library(
10-
name = "bzl",
11-
srcs = glob(["*.bzl"]),
12-
visibility = ["//visibility:public"], #["@npm_bazel_typescript//:__subpackages__"],
13-
)

‎internal/node/BUILD.bazel‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
1616

1717
package(default_visibility = ["//visibility:public"])
1818

19-
exports_files([
20-
"node.bzl", # Exported to be consumed for generating skydoc.
21-
"node_repositories.bzl", # Exported to be consumed for generating skydoc.
22-
"node_launcher.sh",
23-
"node_loader.js",
24-
])
25-
2619
bzl_library(
2720
name = "bzl",
2821
srcs = glob(["*.bzl"]),
29-
visibility = ["//visibility:public"], #["@npm_bazel_typescript//:__subpackages__"],
22+
visibility = ["//visibility:public"],
3023
deps = [
3124
"//internal/npm_install:bzl",
3225
"//third_party/github.com/bazelbuild/bazel-skylib:bzl",
3326
],
3427
)
3528

29+
exports_files([
30+
"node.bzl", # Exported to be consumed for generating skydoc.
31+
"node_repositories.bzl", # Exported to be consumed for generating skydoc.
32+
"node_launcher.sh",
33+
"node_loader.js",
34+
])
35+
3636
filegroup(
3737
name = "package_contents",
3838
srcs = glob([

‎internal/node/node.bzl‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,9 @@ nodejs_binary = rule(
322322
attrs = _NODEJS_EXECUTABLE_ATTRS,
323323
executable = True,
324324
outputs = _NODEJS_EXECUTABLE_OUTPUTS,
325-
doc = "Runs some JavaScript code in NodeJS.",
326325
)
326+
"""Runs some JavaScript code in NodeJS.
327+
"""
327328

328329
nodejs_test = rule(
329330
implementation = _nodejs_binary_impl,
@@ -335,7 +336,8 @@ nodejs_test = rule(
335336
}),
336337
test = True,
337338
outputs = _NODEJS_EXECUTABLE_OUTPUTS,
338-
doc = """
339+
)
340+
"""
339341
Identical to `nodejs_binary`, except this can be used with `bazel test` as well.
340342
When the binary returns zero exit code, the test passes; otherwise it fails.
341343
@@ -357,8 +359,7 @@ test:debug --test_arg=--node_options=--inspect-brk --test_output=streamed --test
357359
Now you can add `--config=debug` to any `bazel test` command line.
358360
The runtime will pause before executing the program, allowing you to connect a
359361
remote debugger.
360-
""",
361-
)
362+
"""
362363

363364
def nodejs_binary_macro(name, data = [], args = [], visibility = None, tags = [], testonly = 0, **kwargs):
364365
"""This macro exists only to wrap the nodejs_binary as an .exe for Windows.

‎internal/npm_install/BUILD.bazel‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
22

3-
# Exported to be consumed for generating skydoc.
4-
exports_files(["npm_install.bzl"])
5-
63
bzl_library(
74
name = "bzl",
85
srcs = glob(["*.bzl"]),
9-
visibility = ["//visibility:public"], #["@npm_bazel_typescript//:__subpackages__"],
10-
deps = [
11-
],
6+
visibility = ["//visibility:public"],
127
)
138

9+
# Exported to be consumed for generating skydoc.
10+
exports_files(["npm_install.bzl"])
11+
1412
filegroup(
1513
name = "generate_build_file",
1614
srcs = ["generate_build_file.js"],

0 commit comments

Comments
 (0)