Skip to content

Commit e3655c2

Browse files
authored
docs(gazelle): Migrate Gazelle docs to ReadTheDocs, part 6/5: development (#3149)
Fixes #3082 6th of 5 PRs. + Migrate gazelle development docs from `gazelle/README.md` to `gazelle/docs/development.md` + Add information on writing tests + Mechanical updates: + Wrap at ~80 chars + Use MyST directives and roles.
1 parent ae2fee1 commit e3655c2

File tree

3 files changed

+59
-17
lines changed

3 files changed

+59
-17
lines changed

gazelle/README.md

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
11
# Python Gazelle plugin
22

33
:::{note}
4-
The gazelle plugin docs are being migrated to our primary documentation on
4+
The gazelle plugin docs have been migrated to our primary documentation on
55
ReadTheDocs. Please see https://rules-python.readthedocs.io/gazelle/docs/index.html.
66
:::
7-
8-
9-
## Developer Notes
10-
11-
Gazelle extensions are written in Go.
12-
See the gazelle documentation https://github.com/bazelbuild/bazel-gazelle/blob/master/extend.md
13-
for more information on extending Gazelle.
14-
15-
If you add new Go dependencies to the plugin source code, you need to "tidy" the go.mod file.
16-
After changing that file, run `go mod tidy` or `bazel run @go_sdk//:bin/go -- mod tidy`
17-
to update the go.mod and go.sum files. Then run `bazel run //:gazelle_update_repos` to have gazelle
18-
add the new dependenies to the deps.bzl file. The deps.bzl file is used as defined in our /WORKSPACE
19-
to include the external repos Bazel loads Go dependencies from.
20-
21-
Then after editing Go code, run `bazel run //:gazelle` to generate/update the rules in the
22-
BUILD.bazel files in our repo.

gazelle/docs/development.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Development
2+
3+
Gazelle extensions are written in Go.
4+
5+
See the [Gazelle documentation][gazelle-extend] for more information on
6+
extending Gazelle.
7+
8+
[gazelle-extend]: https://github.com/bazel-contrib/bazel-gazelle/blob/master/extend.md
9+
10+
11+
## Dependencies
12+
13+
If you add new Go dependencies to the plugin source code, you need to "tidy"
14+
the go.mod file. After changing that file, run `go mod tidy` or
15+
`bazel run @go_sdk//:bin/go -- mod tidy` to update the `go.mod` and `go.sum`
16+
files. Then run `bazel run //:gazelle_update_repos` to have gazelle add the
17+
new dependencies to the `deps.bzl` file. The `deps.bzl` file is used as
18+
defined in our `/WORKSPACE` to include the external repos Bazel loads Go
19+
dependencies from.
20+
21+
Then after editing Go code, run `bazel run //:gazelle` to generate/update
22+
the rules in the `BUILD.bazel` files in our repo.
23+
24+
25+
## Tests
26+
27+
:::{seealso}
28+
{gh-path}`gazelle/python/testdata/README.md`
29+
:::
30+
31+
To run tests, {command}`cd` into the {gh-path}`gazelle` directory and run
32+
`bazel test //...`.
33+
34+
Test cases are found at {gh-path}`gazelle/python/testdata`. To make a new
35+
test case, create a directory in that folder with the following files:
36+
37+
+ `README.md` with a short blurb describing the test case(s).
38+
+ `test.yaml`, either empty (with just the docstart `---` line) or with
39+
the expected `stderr` and exit codes of the test case.
40+
+ and empty `WORKSPACE` file
41+
42+
You will also need `BUILD.in` and `BUILD.out` files somewhere within the test
43+
case directory. These can be in the test case root, in subdirectories, or
44+
both.
45+
46+
+ `BUILD.in` files are populated with the "before" information - typically
47+
things like Gazelle directives or pre-existing targets. This is how the
48+
`BUILD.bazel` file looks before running Gazelle.
49+
+ `BUILD.out` files are the expected result after running Gazelle within
50+
the test case.
51+
52+
:::{tip}
53+
The easiest way to create a new test is to look at one of the existing test
54+
cases.
55+
:::
56+
57+
The source code for running tests is {gh-path}`gazelle/python/python_test.go`.

gazelle/docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ the `update` command (the default) does anything for Python code.
4545
installation_and_usage
4646
directives
4747
annotations
48+
development
4849
```

0 commit comments

Comments
 (0)