Skip to content

Commit 6de9bc9

Browse files
docs: Update README and examples
1 parent 01858c1 commit 6de9bc9

File tree

3 files changed

+44
-6
lines changed

3 files changed

+44
-6
lines changed

README.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,41 @@
11
# Typst rules based on [ast-grep](https://ast-grep.github.io)
22

3+
## Usage
4+
5+
```shell
6+
$ just scan glossarium/0.5.8
7+
ast-grep scan …/preview/glossarium/0.5.8
8+
warning[show-function]:
9+
┌─ …/preview/glossarium/0.5.8/themes/default.typ:1361:5
10+
11+
1361 │ show ref: refrule.with(update: false)
12+
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13+
14+
warning[show-function]:
15+
┌─ …/preview/glossarium/0.5.8/themes/default.typ:901:3
16+
17+
901 │ ╭ show figure.where(kind: __glossarium_figure): it => {
18+
│ │ ╭─────────────────────────────────────────────────'
19+
902 │ │ │ align(start, it.body)
20+
903 │ │ │ }
21+
│ ╰─│───^
22+
│ ╰───'
23+
24+
note[context]:
25+
┌─ …/preview/glossarium/0.5.8\themes\default.typ:568:35
26+
27+
568 │ #let style-entries(attr, style) = context _style-entries(attr, style)
28+
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
29+
30+
note[stateful]:
31+
┌─ …/preview/glossarium/0.5.8/themes/default.typ:18:27
32+
33+
18 │ #let __glossary_entries = state("__glossary_entries", (:))
34+
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
35+
36+
37+
```
38+
339
## Development
440
541
### Online
@@ -33,7 +69,6 @@ Download `tree-sitter-typst.{so,dll}` and put it at the root directory of this p
3369
After that, you can use `ast-grep`. Please refer to [Quick Start | ast-grep](https://ast-grep.github.io/guide/quick-start.html) for more information.
3470
3571
```shell
36-
ast-grep test --skip-snapshot-tests
37-
ast-grep test --update-all
3872
ast-grep test
73+
# Or just add-test
3974
```

justfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@ typst_preview := replace(cache_directory(), '\', '/') + "/typst/packages/preview
44
@list:
55
just --list
66

7-
# Scan code by rules, e.g., `just scan headcount`, `just scan i-figured/0.2.4 --off=hard-coded-str`, `just scan tidy/0.3.0 --filter=eval`
7+
# Scan code by rules, e.g., `just scan headcount`, `just scan tidy/0.3.0 --filter=eval`, `just scan physica/0.9.5 --hint=hard-coded-str --filter=hard-coded-str`
88
scan PREVIEW_PACKAGE_PATH *OPTIONS:
99
ast-grep scan {{ OPTIONS }} {{ typst_preview }}/{{ PREVIEW_PACKAGE_PATH }}
1010

1111
# Normal procedure after adding new tests; see also https://ast-grep.github.io/guide/test-rule.html
12-
add-test:
12+
add-test: && test
1313
ast-grep test --skip-snapshot-tests
1414
ast-grep test --interactive
15-
ast-grep test
15+
16+
[private]
17+
test:
18+
ast-grep test --include-off
1619

1720
# Check rule files match their IDs and tests
1821
check:

rules/hard-coded-str.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
id: hard-coded-str
22
language: typst
3-
severity: hint # Low severity because too common
3+
severity: "off" # Low severity because too common
44
rule:
55
kind: string
66
regex: >-

0 commit comments

Comments
 (0)