Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4b934d2

Browse filesBrowse files
committed
docs: enforce that api docs are up-to-date
Previously we just suggested you run a shell script to update, but there was no clue when that was needed in a PR
1 parent 8e2b6de commit 4b934d2
Copy full SHA for 4b934d2

File tree

4 files changed

+49
-40
lines changed
Filter options

4 files changed

+49
-40
lines changed

‎CONTRIBUTING.md

Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,14 @@ merged.
4343

4444
### Documentation
4545

46-
To regenerate the content under the `docs/` directory, run this script in the
47-
repository root:
46+
To regenerate the content under the `docs/` directory, run this command:
4847

4948
```shell
50-
./update_docs.sh
49+
bazel run //docs:update
5150
```
5251

5352
This needs to be done whenever the docstrings in the corresponding .bzl files
54-
are changed; see `docs/BUILD`.
53+
are changed; a test failure will remind you to run this command when needed.
5554

5655
### Precompiled tools
5756

‎docs/BUILD

Copy file name to clipboardExpand all lines: docs/BUILD
+41-8Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,22 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
###############################################################################
16-
# To regenerate documentation, run the top-level update_docs.sh script. #
17-
###############################################################################
18-
1915
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
16+
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
17+
load("@bazel_skylib//rules:write_file.bzl", "write_file")
2018
load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
2119

2220
package(default_visibility = ["//visibility:public"])
2321

2422
licenses(["notice"]) # Apache 2.0
2523

24+
_DOCS = {
25+
"packaging": "//docs:packaging-docs",
26+
"pip": "//docs:pip-docs",
27+
"python": "//docs:core-docs",
28+
"whl": "//docs:whl-docs",
29+
}
30+
2631
# We define these bzl_library targets here rather than in the //python package
2732
# because they're only used for doc generation. This way, we avoid requiring
2833
# our users to depend on Skylib.
@@ -68,7 +73,7 @@ bzl_library(
6873

6974
stardoc(
7075
name = "core-docs",
71-
out = "python.md",
76+
out = "python.md_",
7277
input = "//python:defs.bzl",
7378
deps = [":defs"],
7479
)
@@ -79,7 +84,7 @@ stardoc(
7984

8085
stardoc(
8186
name = "pip-docs",
82-
out = "pip.md",
87+
out = "pip.md_",
8388
input = "//python:pip.bzl",
8489
deps = [
8590
":bazel_repo_tools",
@@ -90,12 +95,40 @@ stardoc(
9095

9196
stardoc(
9297
name = "whl-docs",
93-
out = "whl.md",
98+
out = "whl.md_",
9499
input = "//python:whl.bzl",
95100
)
96101

97102
stardoc(
98103
name = "packaging-docs",
99-
out = "packaging.md",
104+
out = "packaging.md_",
100105
input = "//python:packaging.bzl",
101106
)
107+
108+
[
109+
diff_test(
110+
name = "check_" + k,
111+
failure_message = "Please run: bazel run //docs:update",
112+
file1 = k + ".md",
113+
file2 = k + ".md_",
114+
)
115+
for k in _DOCS.keys()
116+
]
117+
118+
write_file(
119+
name = "gen_update",
120+
out = "update.sh",
121+
content = [
122+
"#!/usr/bin/env bash",
123+
"cd $BUILD_WORKSPACE_DIRECTORY",
124+
] + [
125+
"cp -fv bazel-bin/docs/{0}.md_ docs/{0}.md".format(k)
126+
for k in _DOCS.keys()
127+
],
128+
)
129+
130+
sh_binary(
131+
name = "update",
132+
srcs = ["update.sh"],
133+
data = _DOCS.values(),
134+
)

‎internal_deps.bzl

Copy file name to clipboardExpand all lines: internal_deps.bzl
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ def rules_python_internal_deps():
1111
maybe(
1212
http_archive,
1313
name = "bazel_skylib",
14-
strip_prefix = "bazel-skylib-1.0.2",
15-
url = "https://github.com/bazelbuild/bazel-skylib/archive/1.0.2.zip",
16-
type = "zip",
17-
sha256 = "64ad2728ccdd2044216e4cec7815918b7bb3bb28c95b7e9d951f9d4eccb07625",
14+
sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d",
15+
urls = [
16+
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
17+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
18+
],
1819
)
1920

2021
maybe(

‎update_docs.sh

Copy file name to clipboardExpand all lines: update_docs.sh
-24Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.