Skip to content

Commit b9394f5

Browse files
docs: verified usage examples and Context7 config (#46)
Adds a Context7 indexing config, tightens README usage examples to source-verified behaviour, and adds an isolated docs-tests package that compiles/runs the marked README example against the released package in CI (Node 22).
1 parent 73ef3b6 commit b9394f5

8 files changed

Lines changed: 167 additions & 1 deletion

File tree

‎.github/workflows/docs-check.yml‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Documentation checks
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'README.md'
7+
- 'context7.json'
8+
- 'docs-tests/**'
9+
- '.github/workflows/docs-check.yml'
10+
push:
11+
branches: [prod]
12+
paths:
13+
- 'README.md'
14+
- 'context7.json'
15+
- 'docs-tests/**'
16+
- '.github/workflows/docs-check.yml'
17+
18+
permissions:
19+
contents: read
20+
21+
jobs:
22+
docs:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: actions/setup-node@v4
27+
with:
28+
node-version: 22
29+
- run: npm ci --ignore-scripts --legacy-peer-deps
30+
working-directory: docs-tests
31+
- run: npm test
32+
working-directory: docs-tests

‎context7.json‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
{
22
"url": "https://context7.com/lomray-software/react-mobx-manager",
3-
"public_key": "pk_9IAtRK9ehH9s9ktsgMjAJ"
3+
"public_key": "pk_9IAtRK9ehH9s9ktsgMjAJ",
4+
"$schema": "https://context7.com/schema/context7.json",
5+
"branch": "prod",
6+
"folders": [
7+
"docs"
8+
],
9+
"excludeFolders": [
10+
"node_modules",
11+
"lib",
12+
"src",
13+
"__tests__",
14+
"__type_tests__",
15+
"docs-tests",
16+
".github",
17+
"docs/.vitepress"
18+
],
19+
"excludeFiles": [
20+
"CHANGELOG.md",
21+
"LICENSE.md",
22+
"CODE_OF_CONDUCT.md"
23+
]
424
}

‎docs-tests/.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
.generated/

‎docs-tests/README.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Documentation checks
2+
3+
From this directory:
4+
5+
```sh
6+
npm ci --ignore-scripts --legacy-peer-deps
7+
npm test
8+
```
9+
10+
The isolated fixture pins released dependencies, not local source. It validates
11+
context7.json against the fetched official schema. For repositories with a marked
12+
README example it extracts that block, runs a strict TypeScript check (skipping
13+
external declaration checking), then runs a targeted smoke test. It is not the
14+
full package suite, an exhaustive peer compatibility matrix, or an index refresh.
15+
The registry lockfile records transitive versions. Peer auto-installation is
16+
disabled so the tested combination stays explicit. Public network access is
17+
needed for npm installation and the Context7 schema read.

‎docs-tests/check.mjs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import assert from 'node:assert/strict';
2+
import { readFile } from 'node:fs/promises';
3+
import Ajv from 'ajv';
4+
5+
const root = new URL('../', import.meta.url);
6+
const config = JSON.parse(await readFile(new URL('context7.json', root), 'utf8'));
7+
const schemaResponse = await fetch('https://context7.com/schema/context7.json');
8+
assert.equal(schemaResponse.status, 200);
9+
const schema = await schemaResponse.json();
10+
const ajv = new Ajv({ strict: false, formats: { uri: true } });
11+
const validate = ajv.compile(schema);
12+
assert.ok(validate(config), JSON.stringify(validate.errors));
13+
assert.equal(config.branch, 'prod');
14+
assert.ok(config.excludeFolders.includes('docs-tests'));
15+
assert.deepEqual(config.folders, ['docs']);
16+
assert.ok(config.url && config.public_key, 'Preserve existing ownership fields');
17+
console.log('PASS: Context7 schema, stable branch, docs path and existing ownership');

‎docs-tests/package-lock.json‎

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

‎docs-tests/package.json‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "react-mobx-manager-docs-tests",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"test": "node check.mjs"
7+
},
8+
"devDependencies": {
9+
"ajv": "8.17.1"
10+
}
11+
}

‎tsconfig.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
},
4040
"exclude": [
4141
"node_modules",
42+
"docs-tests",
4243
"lib",
4344
"commitlint.config.js",
4445
"nyc.config.js",

0 commit comments

Comments
 (0)