Skip to content

Commit a331232

Browse files
committed
Enable extraction from '# Commands' block, add fixtures/tests for tabular command data
1 parent 01e7053 commit a331232

3 files changed

Lines changed: 39 additions & 1 deletion

File tree

hdi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ DIR="."
3434

3535
# ── Keyword groups ───────────────────────────────────────────────────────────
3636
KW_INSTALL="prerequisite|require|depend|install|setup|set.up|set-up|getting.started|quick.start|quickstart"
37-
KW_RUN="usage|running|run|start|develop|dev.server|launch"
37+
KW_RUN="usage|running|run|start|develop|dev.server|launch|command"
3838
KW_TEST="test|spec"
3939
KW_EXTRA="build|configuration|config|environment|deploy"
4040

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# my-astro-site
2+
3+
Code for my website.
4+
5+
## Commands
6+
7+
| Command | Action |
8+
| :------------------ | :----------------------------------------------- |
9+
| `npm i` | Installs dependencies |
10+
| `npm run dev` | Starts local dev server at `localhost:4321` |
11+
| `npm run build` | Build your production site to `./dist/` |
12+
| `npm run preview` | Preview your build locally, before deploying |
13+
| `npm run lint` | Lint code with eslint |
14+
| `npm run format` | Format with Prettier |
15+
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |

test/hdi.bats

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,29 @@ setup() {
617617
[[ "$output" == *"npm install"* ]]
618618
}
619619

620+
# ── Table commands ───────────────────────────────────────────────────────────
621+
622+
@test "table: extracts backtick commands from table rows" {
623+
run "$HDI" --raw "$FIXTURES/table-commands"
624+
[ "$status" -eq 0 ]
625+
[[ "$output" == *"npm i"* ]]
626+
[[ "$output" == *"npm run dev"* ]]
627+
[[ "$output" == *"npm run build"* ]]
628+
}
629+
630+
@test "table: 'Commands' heading matches run mode" {
631+
run "$HDI" run --raw "$FIXTURES/table-commands"
632+
[ "$status" -eq 0 ]
633+
[[ "$output" == *"npm run dev"* ]]
634+
}
635+
636+
@test "table: does not extract non-command text from table cells" {
637+
run "$HDI" --raw "$FIXTURES/table-commands"
638+
[ "$status" -eq 0 ]
639+
[[ "$output" != *"localhost"* ]]
640+
[[ "$output" != *"Installs dependencies"* ]]
641+
}
642+
620643
# ── Interactive: copy to clipboard ───────────────────────────────────────────
621644

622645
@test "interactive: 'c' copies highlighted command to clipboard" {

0 commit comments

Comments
 (0)