@jfdevelops/docs 0.0.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +108 -1
- package/dist/check.d.ts +70 -0
- package/dist/check.js +595 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +84 -0
- package/dist/config.d.ts +17 -0
- package/dist/config.js +51 -0
- package/dist/generate.d.ts +7 -0
- package/dist/generate.js +102 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/manifest.d.ts +112 -0
- package/dist/manifest.js +214 -0
- package/package.json +44 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 JF Develops
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,110 @@
|
|
|
1
1
|
# @jfdevelops/docs
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Generate and check versioned library docs. Pages are plain Markdown under `docs/framework/<framework>/v<major>/`. This package writes everything else: `docs/docs.json`, a `meta.json` in every directory, and a TypeDoc API reference for the current major.
|
|
4
|
+
|
|
5
|
+
## Set up
|
|
6
|
+
|
|
7
|
+
In a project managed by `@jfdevelops/cli`, add the docs addon:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npx jfdevelops add addon docs
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
That installs this package, records its options in `jfdevelops.json`, adds the `docs:generate` and `docs:check` scripts, ignores the generated files, and adds a docs workflow that runs only when the docs or the documented package change.
|
|
14
|
+
|
|
15
|
+
To use it without the CLI, install it and pass the options as flags:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
pnpm add --save-dev @jfdevelops/docs
|
|
19
|
+
pnpm exec jfdevelops-docs generate --package packages/core --name "React Layout"
|
|
20
|
+
pnpm exec jfdevelops-docs check --package packages/core
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Commands
|
|
24
|
+
|
|
25
|
+
| Command | Does |
|
|
26
|
+
| --- | --- |
|
|
27
|
+
| `jfdevelops-docs generate` | Writes the API reference for the current major, `docs/docs.json` and every `meta.json`. `--skip-reference` writes navigation only. |
|
|
28
|
+
| `jfdevelops-docs check` | Validates frontmatter, layout, Markdown, links, anchors, install commands, page order and example fixtures. Exits 1 on any problem. |
|
|
29
|
+
|
|
30
|
+
`--root <dir>` runs against another directory. It defaults to the current one.
|
|
31
|
+
|
|
32
|
+
## Options
|
|
33
|
+
|
|
34
|
+
Options are read from the `docs` addon in `jfdevelops.json`. A flag with the same name overrides them.
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"addons": [
|
|
39
|
+
{
|
|
40
|
+
"name": "docs",
|
|
41
|
+
"options": { "package": "packages/core", "name": "React Layout" }
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
| Option | Default | Meaning |
|
|
48
|
+
| --- | --- | --- |
|
|
49
|
+
| `package` | `.` | Directory of the documented package. Its `package.json` sets the current major, and its `CHANGELOG.md` sets the last release of each earlier major. |
|
|
50
|
+
| `name` | The package name, title-cased | Library name in `docs.json`. |
|
|
51
|
+
| `entry` | `<package>/src/index.ts` | Entry point for the API reference. |
|
|
52
|
+
| `tsconfig` | `<package>/tsconfig.json` | tsconfig for the API reference. |
|
|
53
|
+
| `examples` | none | Directory of type-checked fixtures that `example=<path>` fences must match. |
|
|
54
|
+
|
|
55
|
+
## Generated files
|
|
56
|
+
|
|
57
|
+
None of these are committed:
|
|
58
|
+
|
|
59
|
+
- `docs/docs.json`, the manifest a docs site reads (`schemaVersion: 2`)
|
|
60
|
+
- `meta.json` in each docs directory, with the page order from frontmatter `order`
|
|
61
|
+
- `docs/framework/<framework>/v<current>/reference/`, which carries its own `.gitignore`
|
|
62
|
+
|
|
63
|
+
## Docs layout
|
|
64
|
+
|
|
65
|
+
```text
|
|
66
|
+
docs/
|
|
67
|
+
README.md the only file at the root
|
|
68
|
+
framework/<framework>/
|
|
69
|
+
v<major>/ one directory per documented major
|
|
70
|
+
overview.md
|
|
71
|
+
guides/*.md
|
|
72
|
+
reference/ generated for the current major
|
|
73
|
+
assets/* images only
|
|
74
|
+
maintainers/ never public
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Version status comes from the package major: that major is `current`, earlier ones are `previous`, `v0` is `legacy`, and later ones are `next`. Install commands in earlier majors must pin exact versions, with the documented package at that major's last release.
|
|
78
|
+
|
|
79
|
+
Each install command is written once per package manager, in consecutive fences labeled `npm`, `pnpm`, `yarn` and `bun`:
|
|
80
|
+
|
|
81
|
+
````markdown
|
|
82
|
+
```npm
|
|
83
|
+
npm i @acme/widgets
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```pnpm
|
|
87
|
+
pnpm add @acme/widgets
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```yarn
|
|
91
|
+
yarn add @acme/widgets
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
```bun
|
|
95
|
+
bun add @acme/widgets
|
|
96
|
+
```
|
|
97
|
+
````
|
|
98
|
+
|
|
99
|
+
The check validates versions in all four, and rejects install commands in an `sh` or `bash` fence. A docs site can render the four fences as tabs.
|
|
100
|
+
|
|
101
|
+
Writing guidance lives in the `jf-docs` skill from `@jfdevelops/skills`.
|
|
102
|
+
|
|
103
|
+
## Development
|
|
104
|
+
|
|
105
|
+
Requires Node.js 22.12.0 or newer and pnpm 10.28.1.
|
|
106
|
+
|
|
107
|
+
```sh
|
|
108
|
+
pnpm install --frozen-lockfile
|
|
109
|
+
pnpm check
|
|
110
|
+
```
|
package/dist/check.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type DocsConfig } from './config.js';
|
|
2
|
+
import { parseFrontmatter } from './manifest.js';
|
|
3
|
+
export type DocsIssue = {
|
|
4
|
+
code: string;
|
|
5
|
+
file: string;
|
|
6
|
+
message: string;
|
|
7
|
+
};
|
|
8
|
+
export type DocsStats = {
|
|
9
|
+
versions: number;
|
|
10
|
+
pages: number;
|
|
11
|
+
links: number;
|
|
12
|
+
examples: number;
|
|
13
|
+
};
|
|
14
|
+
export type Heading = {
|
|
15
|
+
level: number;
|
|
16
|
+
text: string;
|
|
17
|
+
slug: string;
|
|
18
|
+
line: number;
|
|
19
|
+
};
|
|
20
|
+
export type Link = {
|
|
21
|
+
image: boolean;
|
|
22
|
+
text: string;
|
|
23
|
+
target: string;
|
|
24
|
+
line: number;
|
|
25
|
+
};
|
|
26
|
+
export type Fence = {
|
|
27
|
+
marker: string;
|
|
28
|
+
language: string;
|
|
29
|
+
info: string;
|
|
30
|
+
example: string | undefined;
|
|
31
|
+
line: number;
|
|
32
|
+
lines: string[];
|
|
33
|
+
content: string;
|
|
34
|
+
};
|
|
35
|
+
export type MarkdownScan = {
|
|
36
|
+
headings: Heading[];
|
|
37
|
+
links: Link[];
|
|
38
|
+
fences: Fence[];
|
|
39
|
+
problems: Array<{
|
|
40
|
+
code: string;
|
|
41
|
+
line: number;
|
|
42
|
+
message: string;
|
|
43
|
+
}>;
|
|
44
|
+
};
|
|
45
|
+
export { parseFrontmatter };
|
|
46
|
+
/**
|
|
47
|
+
* Validates every public page against the docs content contract. docs.json
|
|
48
|
+
* and meta.json are generated
|
|
49
|
+
* from the same tree, so the checker builds them in memory instead of reading
|
|
50
|
+
* them. It uses Node builtins only.
|
|
51
|
+
*/
|
|
52
|
+
export declare const PACKAGE_MANAGERS: string[];
|
|
53
|
+
export declare const FENCE_LANGUAGES: string[];
|
|
54
|
+
export declare const IMAGE_EXTENSIONS: string[];
|
|
55
|
+
export declare const FRONTMATTER_KEYS: string[];
|
|
56
|
+
/** GitHub-style heading slug without the duplicate suffix. */
|
|
57
|
+
export declare function slugifyHeading(text: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Walks a Markdown body and returns its headings, links, images, code fences
|
|
60
|
+
* and any construct the contract rejects.
|
|
61
|
+
*/
|
|
62
|
+
export declare function scanMarkdown(body: string): MarkdownScan;
|
|
63
|
+
/** Runs every check. `root` is the repository root. */
|
|
64
|
+
export declare function checkDocs({ root, config }: {
|
|
65
|
+
root: string;
|
|
66
|
+
config?: DocsConfig;
|
|
67
|
+
}): {
|
|
68
|
+
errors: DocsIssue[];
|
|
69
|
+
stats: DocsStats;
|
|
70
|
+
};
|