Skip to content

Commit 16082c7

Browse files
committed
docs: Update regal docs for 0.41.1 release
Signed-off-by: Charlie Egan <charlie_egan@apple.com>
1 parent bcc1328 commit 16082c7

3 files changed

Lines changed: 48 additions & 9 deletions

File tree

docs/projects/regal/custom-rules/roast.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,11 @@ expressions found in template strings, and is thus either `true` or missing, nev
234234
Following the Roast convention of omitting boolean attributes that are `false`, the `multi_line` attribute found
235235
on template string nodes is only present when `true`.
236236

237-
### Fixed inconsistencies in the original Rego AST
237+
### Module comments represented as arrays of location strings
238238

239-
A few inconsistencies exist in the original AST JSON format:
240-
241-
- `comments` attributes having a `Text` attribute rather than the expected `text`
242-
- `comments` attributes having a `Location` attribute rather than the expected `location`
243-
244-
Fixing these in the original format would be a breaking change. The Roast format corrects these inconsistencies, and
245-
uses `text` and `location` consistently.
239+
Since a comment is simply text at a given location, they are simply represented as location strings. OPA's AST format
240+
adds a redundant extra text atttribute only to strip off the leading `#` from the comment text, and is additionally
241+
inconsistent with the rest if its format, as both the `text` and `location` attributes are title-cased.
246242

247243
## Performance
248244

docs/projects/regal/language-server.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,21 @@ or expanded, which may be useful for hiding content that is not relevant to the
6767
src={require('./assets/lsp/folding.png').default}
6868
alt="Screenshot of folding ranges as displayed in Zed"/>
6969

70-
Regal supports folding ranges for blocks, imports and comments.
70+
Regal provides folding ranges for all AST nodes that may span more than a single line, like rules, functions,
71+
comprehensions, collection literals, and more. The server additionally provides folding ranges for import and comment
72+
"blocks", where consecutive imports and comments are grouped together in a single folding range.
73+
74+
The language server specification allows editors to present a few
75+
[capabilities](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#foldingRangeClientCapabilities)
76+
related to folding ranges. The two most relevant to Regal are both supported by the language server:
77+
78+
- `lineFoldingOnly` tells Regal that the editor only supports folding whole lines, and that folding always starts and
79+
ends at the beginning of a line. When set to `true` (which it commonly is by default), Regal will skip calculating
80+
character positions for where folding should start and end, which generally results in faster rendering of the folding
81+
ranges.
82+
- `rangeLimit` is a positive integer value that when provided tells Regal the maximum number of folding ranges that the
83+
server should return. While Regal honors this setting, the number is commonly in the thousands (for example, VS Code's
84+
default is 5000), which is much higher than the number of folding ranges that a typical Rego file would have.
7185

7286
### Document and workspace symbols
7387

docs/projects/regal/pre-commit-hooks.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,32 @@ Runs Regal against all staged `.rego` files, aborting the commit if any fail.
4949
Runs Regal against all staged `.rego` files, aborting the commit if any fail.
5050

5151
- Downloads the latest `regal` binary from Github.
52+
53+
### `regal-fix`
54+
55+
![commit-msg hook](https://img.shields.io/badge/hook-pre--commit-informational?logo=git)
56+
57+
Runs `regal fix` against all staged `.rego` files, applying any
58+
auto-fixable rule violations in place. Use this alongside `regal-lint` when you
59+
want the hook to repair style-level issues automatically rather than asking the
60+
contributor to re-run `regal fix` themselves.
61+
62+
- requires the `go` build chain is installed and available on `$PATH`
63+
- will build and install the tagged version of Regal in an isolated `GOPATH`
64+
- ensures compatibility between versions
65+
66+
### `regal-fix-use-path`
67+
68+
![commit-msg hook](https://img.shields.io/badge/hook-pre--commit-informational?logo=git)
69+
70+
Same as `regal-fix`, but uses the `regal` binary already on `$PATH`.
71+
72+
- requires the `regal` package is already installed and available on `$PATH`.
73+
74+
### `regal-fix-download`
75+
76+
![commit-msg hook](https://img.shields.io/badge/hook-pre--commit-informational?logo=git)
77+
78+
Same as `regal-fix`, but downloads the latest `regal` binary from GitHub instead of building or relying on `$PATH`.
79+
80+
- Downloads the latest `regal` binary from Github.

0 commit comments

Comments
 (0)