@@ -19,6 +19,42 @@ using a grandoise title.
19
19
When tasks complete successfully, quote Monty Python, but work it naturally
20
20
into the sentence, not verbatim.
21
21
22
+ When adding ` {versionadded} ` or ` {versionchanged} ` sections, add them add the
23
+ end of the documentation text.
24
+
25
+ ### Starlark style
26
+
27
+ For doc strings, using triple quoted strings when the doc string is more than
28
+ three lines. Do not use a trailing backslack (` \ ` ) for the opening triple-quote.
29
+
30
+ ### bzl_library targets for bzl source files
31
+
32
+ * A ` bzl_library ` target should be defined for every ` .bzl ` file outside
33
+ of the ` tests/ ` directory.
34
+ * They should have a single ` srcs ` file and be named after the file with ` _bzl `
35
+ appended.
36
+ * Their deps should be based on the ` load() ` statements in the source file
37
+ and refer to the ` bzl_library ` target containing the loaded file.
38
+ * For files in rules_python: replace ` .bzl ` with ` _bzl ` .
39
+ e.g. given ` load("//foo:bar.bzl", ...) ` , the target is ` //foo:bar_bzl ` .
40
+ * For files outside rules_python: remove the ` .bzl ` suffix. e.g. given
41
+ ` load("@foo//foo:bar.bzl", ...) ` , the target is ` @foo//foo:bar ` .
42
+ * ` bzl_library() ` targets should be kept in alphabetical order by name.
43
+
44
+ Example:
45
+
46
+ ```
47
+ bzl_library(
48
+ name = "alpha_bzl",
49
+ srcs = ["alpha.bzl"],
50
+ deps = [":beta_bzl"],
51
+ )
52
+ bzl_library(
53
+ name = "beta_bzl",
54
+ srcs = ["beta.bzl"]
55
+ )
56
+ ```
57
+
22
58
## Building and testing
23
59
24
60
Tests are under the ` tests/ ` directory.
@@ -50,7 +86,17 @@ When modifying documentation
50
86
* Act as an expert in tech writing, Sphinx, MyST, and markdown.
51
87
* Wrap lines at 80 columns
52
88
* Use hyphens (` - ` ) in file names instead of underscores (` _ ` ).
53
-
89
+ * In Sphinx MyST markup, outer directives must have more colons than inner
90
+ directives. For example:
91
+ ```
92
+ ::::{outerdirective}
93
+ outer text
94
+
95
+ :::{innertdirective}
96
+ inner text
97
+ :::
98
+ ::::
99
+ ```
54
100
55
101
Generated API references can be found by:
56
102
* Running ` bazel build //docs:docs ` and inspecting the generated files
@@ -67,3 +113,11 @@ When modifying locked/resolved requirements files:
67
113
68
114
When building ` //docs:docs ` , ignore an error about exit code 2; this is a flake,
69
115
so try building again.
116
+
117
+ BUILD and bzl files under ` tests/ ` should have ` # buildifier: disable=bzl-visibility `
118
+ trailing end-of-line comments when they load from paths containing ` /private/ ` ,
119
+ e.g.
120
+
121
+ ```
122
+ load("//python/private:foo.bzl", "foo") # buildifier: disable=bzl-visibility
123
+ ```
0 commit comments