Skip to content

Commit

Permalink
Add more situations to the angle bracket test.
Browse files Browse the repository at this point in the history
Examples to demonstrate
bazelbuild#137.
  • Loading branch information
adam-azarchs committed Oct 11, 2022
1 parent 50cb915 commit bd01780
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 11 deletions.
34 changes: 28 additions & 6 deletions test/testdata/angle_bracket_test/golden.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@

Input file to test <angle bracket bugs>

See https://github.com/bazelbuild/skydoc/issues/186
and https://github.com/bazelbuild/stardoc/issues/132
See https://github.com/bazelbuild/skydoc/issues/186,
https://github.com/bazelbuild/stardoc/issues/132,
and https://github.com/bazelbuild/stardoc/issues/137.

<Angle brackets> need to be escaped in some contexts.
They also need to _not_ be escaped when they're enclosed
in a `<code block>`.


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

## my_anglebrac

<pre>
my_anglebrac(<a href="#my_anglebrac-name">name</a>, <a href="#my_anglebrac-useless">useless</a>)
my_anglebrac(<a href="#my_anglebrac-name">name</a>, <a href="#my_anglebrac-also_useless">also_useless</a>, <a href="#my_anglebrac-useless">useless</a>)
</pre>

Rule with &lt;brackets&gt;
Expand All @@ -21,6 +27,7 @@ Rule with &lt;brackets&gt;
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="my_anglebrac-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
| <a id="my_anglebrac-also_useless"></a>also_useless | Args with some formatted tags: <code>&lt;tag&gt;</code> | String | optional | <code>"1&lt;&lt;5"</code> |
| <a id="my_anglebrac-useless"></a>useless | Args with some tags: &lt;tag1&gt;, &lt;tag2&gt; | String | optional | <code>"Find &lt;brackets&gt;"</code> |


Expand Down Expand Up @@ -49,28 +56,36 @@ Information with &lt;brackets&gt;
## bracket_function

<pre>
bracket_function(<a href="#bracket_function-param">param</a>)
bracket_function(<a href="#bracket_function-param">param</a>, <a href="#bracket_function-md_string">md_string</a>)
</pre>

Dummy docstring with &lt;brackets&gt;.

This rule runs checks on &lt;angle brackets&gt;.

Sometimes, we have such things on their own, but they may
also appear in code blocks, like

```starlark
foo = "<thing>"
```


**PARAMETERS**


| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="bracket_function-param"></a>param | an arg with **formatted** docstring, &lt;default&gt; by default. | <code>"&lt;default&gt;"</code> |
| <a id="bracket_function-md_string"></a>md_string | A markdown string. | <code>"&#96;1&lt;&lt;10&#96;"</code> |

**RETURNS**

some &lt;angled&gt; brackets

**DEPRECATED**

deprecated for &lt;reasons&gt;
deprecated for &lt;reasons&gt; as well as `<reasons>`.


<a id="bracket_aspect"></a>
Expand All @@ -81,7 +96,14 @@ deprecated for &lt;reasons&gt;
bracket_aspect(<a href="#bracket_aspect-name">name</a>, <a href="#bracket_aspect-brackets">brackets</a>)
</pre>

Aspect with &lt;brackets&gt;
Aspect.

Sometimes, we want a code block like
```starlark
foo = "<brackets>"
```
which includes angle brackets.


**ASPECT ATTRIBUTES**

Expand Down
35 changes: 30 additions & 5 deletions test/testdata/angle_bracket_test/input.bzl
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
"""Input file to test <angle bracket bugs>
See https://github.com/bazelbuild/skydoc/issues/186
and https://github.com/bazelbuild/stardoc/issues/132"""
See https://github.com/bazelbuild/skydoc/issues/186,
https://github.com/bazelbuild/stardoc/issues/132,
and https://github.com/bazelbuild/stardoc/issues/137.
def bracket_function(param = "<default>"):
<Angle brackets> need to be escaped in some contexts.
They also need to _not_ be escaped when they're enclosed
in a `<code block>`.
"""

def bracket_function(param = "<default>", md_string = "`1<<10`"):
"""Dummy docstring with <brackets>.
This rule runs checks on <angle brackets>.
Sometimes, we have such things on their own, but they may
also appear in code blocks, like
```starlark
foo = "<thing>"
```
Args:
param: an arg with **formatted** docstring, <default> by default.
md_string: A markdown string.
Returns:
some <angled> brackets
Deprecated:
deprecated for <reasons>
deprecated for <reasons> as well as `<reasons>`.
"""
return param

Expand All @@ -41,6 +55,10 @@ my_anglebrac = rule(
doc = "Args with some tags: <tag1>, <tag2>",
default = "Find <brackets>",
),
"also_useless": attr.string(
doc = "Args with some formatted tags: `<tag>`",
default = "1<<5",
),
},
)

Expand All @@ -50,7 +68,14 @@ def _bracket_aspect_impl(ctx):

bracket_aspect = aspect(
implementation = _bracket_aspect_impl,
doc = "Aspect with <brackets>",
doc = """Aspect.
Sometimes, we want a code block like
```starlark
foo = "<brackets>"
```
which includes angle brackets.
""",
attr_aspects = ["deps"],
attrs = {
"brackets": attr.string(
Expand Down

0 comments on commit bd01780

Please sign in to comment.