@@ -19,6 +19,42 @@ using a grandoise title.
1919When tasks complete successfully, quote Monty Python, but work it naturally
2020into the sentence, not verbatim.
2121
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+
2258## Building and testing
2359
2460Tests are under the ` tests/ ` directory.
@@ -50,7 +86,17 @@ When modifying documentation
5086 * Act as an expert in tech writing, Sphinx, MyST, and markdown.
5187 * Wrap lines at 80 columns
5288 * 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+ ```
54100
55101Generated API references can be found by:
56102* Running ` bazel build //docs:docs ` and inspecting the generated files
@@ -67,3 +113,11 @@ When modifying locked/resolved requirements files:
67113
68114When building ` //docs:docs ` , ignore an error about exit code 2; this is a flake,
69115so 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