Skip to content

Commit

Permalink
Bump bazel dep and add docstring dedenting test cases (#170)
Browse files Browse the repository at this point in the history
We want bazelbuild/bazel@b71b2df in order to dedent and trim doc strings from all sources (not just functions, but also rules, providers, attributes, etc.).
  • Loading branch information
tetromino authored Aug 2, 2023
1 parent 056ba3b commit b8856b4
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 20 deletions.
13 changes: 12 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
# Needed for generating the Stardoc release binary.
git_repository(
name = "io_bazel",
commit = "c2394ca2d201bdc72887b3920680ca119d46a26e", # 2023-05-10
commit = "b71b2df2b22e052f8540a23051b589c6ef870d0a", # 2023-08-01
remote = "https://github.com/bazelbuild/bazel.git",
)

Expand Down Expand Up @@ -172,6 +172,17 @@ rules_proto_dependencies()

rules_proto_toolchains()

# Needed as a transitive dependency of @io_bazel
http_archive(
name = "blake3",
build_file = "@io_bazel//third_party:blake3/blake3.BUILD",
sha256 = "bb529ba133c0256df49139bd403c17835edbf60d2ecd6463549c6a5fe279364d",
strip_prefix = "BLAKE3-1.3.3",
urls = [
"https://github.com/BLAKE3-team/BLAKE3/archive/refs/tags/1.3.3.zip",
],
)

### END INTERNAL ONLY
# protobuf_deps() must not be called before @rules_python are loaded (if they are loaded).
protobuf_deps()
Binary file modified stardoc/stardoc_binary.jar
Binary file not shown.
2 changes: 0 additions & 2 deletions test/testdata/angle_bracket_test/legacy_golden.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ the backslash itself must be escaped for use in a Starlark docstring
(`\\<` becomes \<), or by using HTML entities (`&lt;` becomes &lt;).
Angle brackets are also preserved in inline code blocks (`#include <vector>`).


<a id="my_anglebrac"></a>

## my_anglebrac
Expand Down Expand Up @@ -106,7 +105,6 @@ foo = "<brackets>"
```
which includes angle brackets.


**ASPECT ATTRIBUTES**


Expand Down
4 changes: 3 additions & 1 deletion test/testdata/aspect_test/golden.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ my_aspect_impl(<a href="#my_aspect_impl-ctx">ctx</a>)
my_aspect(<a href="#my_aspect-name">name</a>, <a href="#my_aspect-first">first</a>, <a href="#my_aspect-second">second</a>)
</pre>

This is my aspect. It does stuff.
This is my aspect.

It does stuff.

**ASPECT ATTRIBUTES**

Expand Down
6 changes: 5 additions & 1 deletion test/testdata/aspect_test/input.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ def my_aspect_impl(ctx):

my_aspect = aspect(
implementation = my_aspect_impl,
doc = "This is my aspect. It does stuff.",
doc = """
This is my aspect.
It does stuff.
""",
attr_aspects = ["deps", "attr_aspect"],
attrs = {
"first": attr.bool(mandatory = True),
Expand Down
4 changes: 3 additions & 1 deletion test/testdata/aspect_test/legacy_golden.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ my_aspect_impl(<a href="#my_aspect_impl-ctx">ctx</a>)
my_aspect(<a href="#my_aspect-name">name</a>, <a href="#my_aspect-first">first</a>, <a href="#my_aspect-second">second</a>)
</pre>

This is my aspect. It does stuff.
This is my aspect.

It does stuff.

**ASPECT ATTRIBUTES**

Expand Down
4 changes: 3 additions & 1 deletion test/testdata/attribute_types_test/golden.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
my_rule(<a href="#my_rule-name">name</a>, <a href="#my_rule-a">a</a>, <a href="#my_rule-b">b</a>, <a href="#my_rule-c">c</a>, <a href="#my_rule-d">d</a>, <a href="#my_rule-e">e</a>, <a href="#my_rule-f">f</a>, <a href="#my_rule-g">g</a>, <a href="#my_rule-h">h</a>, <a href="#my_rule-i">i</a>, <a href="#my_rule-j">j</a>, <a href="#my_rule-k">k</a>, <a href="#my_rule-l">l</a>)
</pre>

This is my rule. It does stuff.
This is my rule.

It does stuff.

**ATTRIBUTES**

Expand Down
6 changes: 5 additions & 1 deletion test/testdata/attribute_types_test/input.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ def my_rule_impl(ctx):

my_rule = rule(
implementation = my_rule_impl,
doc = "This is my rule. It does stuff.",
doc = """
This is my rule.
It does stuff.
""",
attrs = {
"a": attr.bool(mandatory = True, doc = "Some bool"),
"b": attr.int(mandatory = True, doc = "Some int"),
Expand Down
4 changes: 3 additions & 1 deletion test/testdata/attribute_types_test/legacy_golden.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
my_rule(<a href="#my_rule-name">name</a>, <a href="#my_rule-a">a</a>, <a href="#my_rule-b">b</a>, <a href="#my_rule-c">c</a>, <a href="#my_rule-d">d</a>, <a href="#my_rule-e">e</a>, <a href="#my_rule-f">f</a>, <a href="#my_rule-g">g</a>, <a href="#my_rule-h">h</a>, <a href="#my_rule-i">i</a>, <a href="#my_rule-j">j</a>, <a href="#my_rule-k">k</a>, <a href="#my_rule-l">l</a>)
</pre>

This is my rule. It does stuff.
This is my rule.

It does stuff.

**ATTRIBUTES**

Expand Down
Binary file modified test/testdata/proto_format_test/legacy_golden.binaryproto
Binary file not shown.
3 changes: 2 additions & 1 deletion test/testdata/provider_basic_test/golden.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ MyVeryDocumentedInfo(<a href="#MyVeryDocumentedInfo-favorite_food">favorite_food
</pre>

A provider with some really neat documentation.

Look on my works, ye mighty, and despair!

**FIELDS**


| Name | Description |
| :------------- | :------------- |
| <a id="MyVeryDocumentedInfo-favorite_food"></a>favorite_food | A string representing my favorite food |
| <a id="MyVeryDocumentedInfo-favorite_food"></a>favorite_food | A string representing my favorite food<br><br>Expected to be delicious. |
| <a id="MyVeryDocumentedInfo-favorite_color"></a>favorite_color | A string representing my favorite color |


13 changes: 9 additions & 4 deletions test/testdata/provider_basic_test/input.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ MyFooInfo = provider(
# buildifier: disable=unsorted-dict-items
MyVeryDocumentedInfo = provider(
doc = """
A provider with some really neat documentation.
Look on my works, ye mighty, and despair!
""",
A provider with some really neat documentation.
Look on my works, ye mighty, and despair!
""",
fields = {
"favorite_food": "A string representing my favorite food",
"favorite_food": """
A string representing my favorite food
Expected to be delicious.
""",
"favorite_color": "A string representing my favorite color",
},
)
Expand Down
5 changes: 2 additions & 3 deletions test/testdata/provider_basic_test/legacy_golden.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,16 @@ MyPoorlyDocumentedInfo()
MyVeryDocumentedInfo(<a href="#MyVeryDocumentedInfo-favorite_food">favorite_food</a>, <a href="#MyVeryDocumentedInfo-favorite_color">favorite_color</a>)
</pre>


A provider with some really neat documentation.
Look on my works, ye mighty, and despair!

Look on my works, ye mighty, and despair!

**FIELDS**


| Name | Description |
| :------------- | :------------- |
| <a id="MyVeryDocumentedInfo-favorite_food"></a>favorite_food | A string representing my favorite food |
| <a id="MyVeryDocumentedInfo-favorite_food"></a>favorite_food | A string representing my favorite food<br><br> Expected to be delicious. |
| <a id="MyVeryDocumentedInfo-favorite_color"></a>favorite_color | A string representing my favorite color |


2 changes: 1 addition & 1 deletion test/testdata/repo_rules_test/golden.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Minimal example of a repository rule.
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="my_repo-name"></a>name | A unique name for this repository. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
| <a id="my_repo-repo_mapping"></a>repo_mapping | In `WORKSPACE` context only: a dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<br><br>For example, an entry `"@foo": "@bar"` declares that, for any time this repository depends on `@foo` (such as a dependency on `@foo//some:target`, it should actually resolve that dependency within globally-declared `@bar` (`@bar//some:target`).<br><br>This attribute is _not_ supported in `MODULE.bazel` context (when invoking a repository rule inside a module extension's implementation function). | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | |
| <a id="my_repo-useless"></a>useless | This argument will be ignored. You don't have to specify it, but you may. | String | optional | `"ignoreme"` |
| <a id="my_repo-useless"></a>useless | This argument will be ignored.<br><br>You don't have to specify it, but you may. | String | optional | `"ignoreme"` |

**ENVIRONMENT VARIABLES**

Expand Down
5 changes: 4 additions & 1 deletion test/testdata/repo_rules_test/input.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ my_repo = repository_rule(
doc = "Minimal example of a repository rule.",
attrs = {
"useless": attr.string(
doc = "This argument will be ignored. You don't have to specify it, but you may.",
doc = """This argument will be ignored.
You don't have to specify it, but you may.
""",
default = "ignoreme",
),
},
Expand Down
2 changes: 1 addition & 1 deletion test/testdata/repo_rules_test/legacy_golden.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ Minimal example of a repository rule.
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="my_repo-name"></a>name | A unique name for this repository. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
| <a id="my_repo-repo_mapping"></a>repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>For example, an entry `"@foo": "@bar"` declares that, for any time this repository depends on `@foo` (such as a dependency on `@foo//some:target`, it should actually resolve that dependency within globally-declared `@bar` (`@bar//some:target`). | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | required | |
| <a id="my_repo-useless"></a>useless | This argument will be ignored. You don't have to specify it, but you may. | String | optional | `"ignoreme"` |
| <a id="my_repo-useless"></a>useless | This argument will be ignored.<br><br>You don't have to specify it, but you may. | String | optional | `"ignoreme"` |


0 comments on commit b8856b4

Please sign in to comment.