Skip to content

Commit 48b8068

Browse files
authored
docs: fix links (#37)
* doc: fixing github doc links * fix: add rehype plugin to fix website links * fix: update rehype md extension handler pattern * doc: update link
1 parent bc63bd3 commit 48b8068

File tree

10 files changed

+58
-26
lines changed

10 files changed

+58
-26
lines changed

docs/api.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ The most important feature of render is that the queries from
9696
[CLI Testing Library](https://github.com/crutchcorn/cli-testing-library) are
9797
automatically returned with their first argument bound to the testInstance.
9898

99-
See [Queries](./queries) to learn more about how to use these queries and the
99+
See [Queries](./queries.md) to learn more about how to use these queries and the
100100
philosophy behind them.
101101

102102
### ByText
@@ -122,7 +122,7 @@ Queries for test instance `stdout` results with the given text (and it also
122122
accepts a TextMatch).
123123

124124
These options are all standard for text matching. To learn more, see our
125-
[Queries page](./queries).
125+
[Queries page](./queries.md).
126126

127127
## `userEvent[eventName]`
128128

@@ -132,11 +132,11 @@ userEvent[eventName](...eventProps)
132132

133133
> While `userEvent` isn't usually returned on `render` in, say,
134134
> `React Testing Library`, we're able to do so because of our differences in
135-
> implementation with upstream. See our [Differences](./differences) doc for
135+
> implementation with upstream. See our [Differences](./differences.md) doc for
136136
> more.
137137

138138
This object is the same as described with
139-
[`userEvent` documentation](./user-event) with the key difference that
139+
[`userEvent` documentation](./user-event.md) with the key difference that
140140
`instance` is not expected to be passed when bound to `render`.
141141

142142
## `debug`
@@ -158,7 +158,7 @@ debug()
158158
```
159159

160160
This is a simple wrapper around `prettyCLI` which is also exposed and comes from
161-
[CLI Testing Library](./debug).
161+
[CLI Testing Library](./debug.md).
162162

163163
## `hasExit`
164164

@@ -184,7 +184,7 @@ so you can call `process.pid` etc. to inspect the process.
184184
## `stdoutArr`/`stderrArr`
185185

186186
Each of these is an array of what's output by their respective `std`\* pipe.
187-
This is used internally to create the [`debug`methods](./debug) and more.
187+
This is used internally to create the [`debug`methods](./debug.md) and more.
188188
They're defined as:
189189

190190
```typescript

docs/configure.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ to `waitFor`.
2525

2626
### `throwSuggestions` (experimental)
2727

28-
When enabled, if [better queries](./queries) are available the test will fail
28+
When enabled, if [better queries](./queries.md) are available the test will fail
2929
and provide a suggested query to use instead. Default to `false`.
3030

3131
To disable a suggestion for a single query just add `{suggest:false}` as an
@@ -51,7 +51,7 @@ to 1000ms.
5151
By default, we wait for the CLI to `spawn` the command from `render`. If we
5252
immediately resolve the promise to allow users to query, however, we lose the
5353
ability to `getByText` immediately after rendering. This
54-
[differs greatly from upstream Testing Library](./differences) and makes for
54+
[differs greatly from upstream Testing Library](./differences.md) and makes for
5555
a poor testing experience.
5656

5757
As a result, we wait this duration before resolving the promise after the

docs/fire-event.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: "Firing Events"
55
> **Note**
66
>
77
> Most projects have a few use cases for `fireEvent`, but the majority of the
8-
> time you should probably use [`userEvent`](./user-event).
8+
> time you should probably use [`userEvent`](./user-event.md).
99
1010
## `fireEvent`
1111

@@ -26,5 +26,5 @@ fireEvent[eventName](instance: TestInstance, eventProperties?: Object)
2626
```
2727

2828
Convenience methods for firing CLI events. Check out
29-
[src/event-map.js](../src/event-map.ts) for a full list as well as default
29+
[src/event-map.js](../packages/cli-testing-library/src/event-map.ts) for a full list as well as default
3030
`eventProperties`.

docs/introduction.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ will work when a real user uses it.
5151

5252
# Further Reading
5353

54-
- [API reference for `render` and friends](./api)
55-
- [Jest and Vitest matchers](./matchers)
56-
- [Mock user input](./user-event)
57-
- [Manually fire input events](./fire-event)
58-
- [Output matching queries](./queries)
59-
- [Debugging "CLI Testing Library" tests](./debug)
60-
- [Configure library options](./configure)
61-
- [Differences between us and other "Testing Library" projects](./differences)
54+
- [API reference for `render` and friends](./api.md)
55+
- [Jest and Vitest matchers](./matchers.md)
56+
- [Mock user input](./user-event.md)
57+
- [Manually fire input events](./fire-event.md)
58+
- [Output matching queries](./queries.md)
59+
- [Debugging "CLI Testing Library" tests](./debug.md)
60+
- [Configure library options](./configure.md)
61+
- [Differences between us and other "Testing Library" projects](./differences.md)

docs/queries.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if no CLI instance is found or if it will return a Promise and retry. Depending
99
on what app content you are selecting, different queries may be more or less
1010
appropriate.
1111

12-
While our APIs [differ slightly](./differences) from upstream Testing
12+
While our APIs [differ slightly](./differences.md) from upstream Testing
1313
Library's,
1414
[their "About Queries" page summarizes the goals and intentions of this project's queries quite well](https://testing-library.com/docs/queries/about/).
1515

@@ -176,7 +176,7 @@ getByText(
176176
```
177177

178178
This will search the instance to see if there's an `stdout` output matching the
179-
given [`TextMatch`](queries/about.mdx#textmatch).
179+
given [`TextMatch`](#textmatch).
180180

181181
```html
182182
Input your name:
@@ -211,7 +211,7 @@ getByText(
211211
```
212212

213213
This will search the instance to see if there's an `stderr` output matching the
214-
given [`TextMatch`](queries/about.mdx#textmatch).
214+
given [`TextMatch`](#textmatch).
215215

216216
```html
217217
Could not find file

docs/user-event.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "User Event"
33
---
44

55
[`user-event`][gh] is a helper that provides more advanced simulation of CLI
6-
interactions than the [`fireEvent`](./fire-event) method.
6+
interactions than the [`fireEvent`](./fire-event.md) method.
77

88
## Import
99

@@ -66,7 +66,7 @@ Keystrokes can be described:
6666
userEvent.keyboard('a[[') // translates to: a, [
6767
```
6868

69-
- Per [special key mapping](../src/user-event/keyboard/keyMap.ts) with the `[`
69+
- Per [special key mapping](../packages/cli-testing-library/src/user-event/keyboard/keyMap.ts) with the `[`
7070
symbol
7171

7272
```js
@@ -77,7 +77,7 @@ Keystrokes can be described:
7777
`f`.
7878

7979
The mapping of special character strings are performed by a
80-
[default key map](../src/user-event/keyboard/keyMap.ts) portraying a "default"
80+
[default key map](../packages/cli-testing-library/src/user-event/keyboard/keyMap.ts) portraying a "default"
8181
US-keyboard. You can provide your own local keyboard mapping per option.
8282

8383
```js
@@ -106,6 +106,6 @@ mentioned previously. Here are some of the ones that are supported:
106106
| `[End]` | End |
107107

108108
A full list of supported special characters that can be input can be found
109-
[in our key mapping file](../src/user-event/keyboard/keyMap.ts).
109+
[in our key mapping file](../packages/cli-testing-library/src/user-event/keyboard/keyMap.ts).
110110

111111
[gh]: https://github.com/testing-library/user-event

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/astro.config.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ import { defineConfig } from "astro/config";
33
import starlight from "@astrojs/starlight";
44
import react from "@astrojs/react";
55

6+
import { rehypeHandleMdExtension } from "./rehype-plugin";
7+
68
// https://astro.build/config
79
export default defineConfig({
10+
markdown: {
11+
rehypePlugins: [rehypeHandleMdExtension]
12+
},
813
integrations: [
914
react(),
1015
starlight({

website/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"astro": "^5.0.2",
1717
"react": "^19.0.0",
1818
"react-dom": "^19.0.0",
19-
"sharp": "^0.33.5"
19+
"sharp": "^0.33.5",
20+
"unist-util-visit": "^5.0.0"
2021
},
2122
"devDependencies": {
2223
"@types/react": "^19.0.2",

website/rehype-plugin.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { visit } from "unist-util-visit";
2+
3+
export const rehypeHandleMdExtension = () => {
4+
const pattern = /^(\..+)\.md(.*)/;
5+
6+
const canBeProcessed = (node) => (
7+
node.tagName === "a" &&
8+
node.properties.href &&
9+
pattern.test(node.properties.href)
10+
)
11+
12+
const processNode = (node) => {
13+
const href = node.properties.href;
14+
const results = href.match(pattern)
15+
node.properties.href = `${results[1]}${results[2]}`;
16+
}
17+
18+
return (tree) => {
19+
visit(tree, "element", (node) => {
20+
canBeProcessed(node) && processNode(node)
21+
})
22+
}
23+
}

0 commit comments

Comments
 (0)