Skip to content

Commit 3f5c6ab

Browse files
Copilothawkeyexl
andauthored
Add Docker command examples to all Doc Detective guides (#113)
* Initial plan * Add Docker instructions to all guides with Doc Detective commands Co-authored-by: hawkeyexl <[email protected]> * Fix Vale linting issues in MDX files Co-authored-by: hawkeyexl <[email protected]> * Revert Vale config and add Docker example for remote tests Co-authored-by: hawkeyexl <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: hawkeyexl <[email protected]>
1 parent b271dcb commit 3f5c6ab

File tree

13 files changed

+406
-35
lines changed

13 files changed

+406
-35
lines changed

docs/get-started/actions/checkLink.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ grand_parent: Tests,
77
description: Check if a URL returns an acceptable status code from a GET request.
88
---
99

10+
import Tabs from '@theme/Tabs';
11+
import TabItem from '@theme/TabItem';
1012
import { schemas } from "doc-detective-common";
1113
import JSONSchemaViewer from "@theme/JSONSchemaViewer";
1214

@@ -175,10 +177,27 @@ Consider the following test configuration, which checks the validity of `https:/
175177

176178
To run the test, use the following command:
177179

180+
<Tabs>
181+
<TabItem value="npx" label="NPX" default>
182+
178183
```bash
179184
npx doc-detective -i bad-certificate.json
180185
```
181186

187+
</TabItem>
188+
<TabItem value="docker" label="Docker">
189+
190+
```bash
191+
docker run -v .:/app docdetective/docdetective -i /app/bad-certificate.json
192+
```
193+
194+
:::note
195+
The `-v` argument mounts your current directory (`.`) to `/app` in the container.
196+
:::
197+
198+
</TabItem>
199+
</Tabs>
200+
182201
This command executes the test, but it fails, returning the following response:
183202

184203
```json

docs/get-started/create-your-first-test.md renamed to docs/get-started/create-your-first-test.mdx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
sidebar_label: Create your first test
33
---
44

5+
import Tabs from '@theme/Tabs';
6+
import TabItem from '@theme/TabItem';
7+
58
# Create your first test
69

710
In this tutorial, you will create a basic test that navigates to a webpage, validates the presence of specific elements, and captures a screenshot. This will introduce you to fundamental Doc Detective actions that are essential for creating more advanced tests in the future.
@@ -77,11 +80,28 @@ To create your first test, follow these steps:
7780

7881
5. In your terminal, enter the following command to run the test:
7982

83+
<Tabs>
84+
<TabItem value="npx" label="NPX" default>
85+
8086
```bash
8187
npx doc-detective --input homepage-check.spec.json
8288
```
8389

84-
By default, Doc Detective scans the current directory for valid tests, but you can specify your test file using the `--input` argument. For more information, see [Run tests](/docs/get-started/sample-tests.md#run-tests).
90+
</TabItem>
91+
<TabItem value="docker" label="Docker">
92+
93+
```bash
94+
docker run -v .:/app docdetective/docdetective --input /app/homepage-check.spec.json
95+
```
96+
97+
:::note
98+
The `-v` argument mounts your current directory (`.`) to `/app` in the container, giving Doc Detective access to your test specification and enabling it to output results and screenshots.
99+
:::
100+
101+
</TabItem>
102+
</Tabs>
103+
104+
By default, Doc Detective scans the current directory for valid tests, but you can specify your test file using the `--input` argument. For more information, see [Run tests](/docs/get-started/sample-tests#run-tests).
85105

86106
## Outcome
87107

docs/get-started/inputs/custom.mdx

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ title: Custom inputs
44
description: Define custom input formats and markup patterns for your documentation.
55
---
66

7+
import Tabs from '@theme/Tabs';
8+
import TabItem from '@theme/TabItem';
9+
710
# Custom input formats
811

912
You can define custom input formats and extend existing formats by modifying your [configuration file](/docs/references/schemas/config). This allows you to support new file types or customize test detection for your specific documentation patterns.
@@ -39,12 +42,12 @@ To define a custom file type, add an entry to the `fileTypes` array in your conf
3942

4043
**Optional properties for inline tests:**
4144

42-
- `testStartStatementOpen`: Pattern that starts a test declaration (e.g., `"<!-- test "`)
43-
- `testStartStatementClose`: Pattern that ends a test declaration (e.g., `" -->"`)
44-
- `testEndStatementOpen`: Pattern that marks the end of a test (e.g., `"<!-- test end"`)
45-
- `testEndStatementClose`: Pattern that closes the test end marker (e.g., `" -->"`)
46-
- `stepStatementOpen`: Pattern that starts a step declaration (e.g., `"<!-- step "`)
47-
- `stepStatementClose`: Pattern that ends a step declaration (e.g., `" -->"`)
45+
- `testStartStatementOpen`: Pattern that starts a test declaration (for example, `"<!-- test "`)
46+
- `testStartStatementClose`: Pattern that ends a test declaration (for example, `" -->"`)
47+
- `testEndStatementOpen`: Pattern that marks the end of a test (for example, `"<!-- test end"`)
48+
- `testEndStatementClose`: Pattern that closes the test end marker (for example, `" -->"`)
49+
- `stepStatementOpen`: Pattern that starts a step declaration (for example, `"<!-- step "`)
50+
- `stepStatementClose`: Pattern that ends a step declaration (for example, `" -->"`)
4851
- `testIgnoreStatement`: Pattern for ignoring blocks
4952

5053
**Optional properties for detected tests:**
@@ -261,10 +264,27 @@ To test your custom patterns:
261264
3. Run Doc Detective with the `--input` flag pointing to your file
262265
4. Check the generated test results to verify patterns were detected correctly
263266

267+
<Tabs>
268+
<TabItem value="npx" label="NPX" default>
269+
264270
```bash
265271
npx doc-detective --input sample.cdoc --config custom-config.json
266272
```
267273

274+
</TabItem>
275+
<TabItem value="docker" label="Docker">
276+
277+
```bash
278+
docker run -v .:/app docdetective/docdetective --input /app/sample.cdoc --config /app/custom-config.json
279+
```
280+
281+
:::note
282+
The `-v` argument mounts your current directory (`.`) to `/app` in the container.
283+
:::
284+
285+
</TabItem>
286+
</Tabs>
287+
268288
## Best practices
269289

270290
- **Start with basics**: Begin with basic patterns and add complexity as needed

docs/get-started/intro.md renamed to docs/get-started/intro.mdx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,35 @@ title: Introduction
33
sidebar_label: Introduction
44
---
55

6+
import Tabs from '@theme/Tabs';
7+
import TabItem from '@theme/TabItem';
8+
69
# Doc Detective
710

811
Validate your content with Doc Detective:
912

13+
<Tabs>
14+
<TabItem value="npx" label="NPX" default>
15+
1016
```bash
1117
npx doc-detective
1218
```
1319

14-
Want to use the Docker image? [Check it out](https://github.com/doc-detective/docker-image).
20+
</TabItem>
21+
<TabItem value="docker" label="Docker">
22+
23+
```bash
24+
docker run -v .:/app docdetective/docdetective
25+
```
26+
27+
:::note
28+
The `-v` argument mounts your current directory (`.`) to `/app` in the container, giving Doc Detective access to your test specifications.
29+
:::
30+
31+
</TabItem>
32+
</Tabs>
1533

16-
See the [Installation](/docs/get-started/installation) guide to get started. Come chat on [Discord](https://discord.gg/uAfSjVH7yr)!
34+
See the [Installation](/docs/get-started/installation) guide to get started. Come chat on [Discord](https://discord.gg/uAfSjVH7yr).
1735

1836
## What's Doc Detective?
1937

docs/get-started/sample-tests.md renamed to docs/get-started/sample-tests.mdx

Lines changed: 91 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import Tabs from '@theme/Tabs';
2+
import TabItem from '@theme/TabItem';
3+
14
# Explore sample tests
25

3-
Use the sample test files provided to experiment with Doc Detectives capabilities and see how it handles different scenarios.
6+
Use the sample test files provided to experiment with Doc Detective's capabilities and see how it handles different scenarios.
47

58
## Get sample files
69

@@ -14,46 +17,131 @@ npm i
1417

1518
## Run tests
1619

20+
<Tabs>
21+
<TabItem value="npx" label="NPX" default>
22+
1723
```bash
1824
npx doc-detective
1925
```
2026

27+
</TabItem>
28+
<TabItem value="docker" label="Docker">
29+
30+
```bash
31+
docker run -v .:/app docdetective/docdetective
32+
```
33+
34+
:::note
35+
The `-v` argument mounts your current directory (`.`) to `/app` in the container, giving Doc Detective access to your test specifications.
36+
:::
37+
38+
</TabItem>
39+
</Tabs>
40+
2141
By default, Doc Detective scans the current directory for valid tests, but you can specify your test file with the `--input` argument. For example, to run tests in a file named `doc-content-inline-tests.md`, run the following command:
2242

43+
<Tabs>
44+
<TabItem value="npx" label="NPX" default>
45+
2346
```bash
2447
npx doc-detective --input doc-content-inline-tests.md
2548
```
2649

50+
</TabItem>
51+
<TabItem value="docker" label="Docker">
52+
53+
```bash
54+
docker run -v .:/app docdetective/docdetective --input /app/doc-content-inline-tests.md
55+
```
56+
57+
</TabItem>
58+
</Tabs>
59+
2760
If you have test files in multiple directories or want to specify multiple files, then enter them separated with commas:
2861

62+
<Tabs>
63+
<TabItem value="npx" label="NPX" default>
64+
2965
```bash
3066
npx doc-detective --input doc-content-inline-tests.md,/apis/api-tests.md
3167
```
3268

69+
</TabItem>
70+
<TabItem value="docker" label="Docker">
71+
72+
```bash
73+
docker run -v .:/app docdetective/docdetective --input /app/doc-content-inline-tests.md,/app/apis/api-tests.md
74+
```
75+
76+
</TabItem>
77+
</Tabs>
78+
3379
To customize your test, file type, and directory options, create a `.doc-detective.json` [config](/docs/references/schemas/config) file. If a `.doc-detective.json` file exists in the directory when you run the comment, Doc Detective loads the config. Otherwise, you can specify a config path with the `--config` argument.
3480

81+
<Tabs>
82+
<TabItem value="npx" label="NPX" default>
83+
3584
```bash
3685
npx doc-detective --config .doc-detective.json
3786
```
3887

88+
</TabItem>
89+
<TabItem value="docker" label="Docker">
90+
91+
```bash
92+
docker run -v .:/app docdetective/docdetective --config /app/.doc-detective.json
93+
```
94+
95+
</TabItem>
96+
</Tabs>
97+
3998
**Note**: All paths are relative to the current working directory, regardless of the config file's location.
4099

41100
You can override config options with command-line arguments. For example, to run tests in a file named `tests.spec.json`, even if that isn't included in your config, run the following command:
42101

102+
<Tabs>
103+
<TabItem value="npx" label="NPX" default>
104+
43105
```bash
44106
npx doc-detective --config .doc-detective.json --input tests.spec.json
45107
```
46108

47-
<!-- ### Run remotely hosted tests
109+
</TabItem>
110+
<TabItem value="docker" label="Docker">
111+
112+
```bash
113+
docker run -v .:/app docdetective/docdetective --config /app/.doc-detective.json --input /app/tests.spec.json
114+
```
115+
116+
</TabItem>
117+
</Tabs>
118+
119+
### Remotely hosted tests
48120

49121
You can run tests hosted remotely by specifying the URL of the test file with the `--input` argument. For example, to run tests from a file hosted at `https://doc-detective.com/sample.spec.json`, run the following command:
50122

123+
<Tabs>
124+
<TabItem value="npx" label="NPX" default>
125+
51126
```bash
52127
npx doc-detective --input https://doc-detective.com/sample.spec.json
53128
```
54129

130+
</TabItem>
131+
<TabItem value="docker" label="Docker">
132+
133+
```bash
134+
docker run docdetective/docdetective --input https://doc-detective.com/sample.spec.json
135+
```
136+
137+
:::note
138+
The `-v` argument is not necessary for remotely hosted tests since Docker doesn't need access to local files.
139+
:::
140+
141+
</TabItem>
142+
</Tabs>
143+
55144
These tests run the same way as local tests, but Doc Detective fetches the test file from the specified URL and stores it in a temporary directory. The URL must be accessible to the machine running the tests.
56-
-->
57145

58146
## Next steps
59147

0 commit comments

Comments
 (0)