@t8/docsgen 0.1.56 → 0.1.58
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 +46 -0
- package/dist/bin.js +19 -24
- package/package.json +3 -3
- package/schema.json +1 -1
- package/src/bin/getConfig.ts +13 -5
- package/src/bin/run.ts +13 -20
- package/src/types/Config.ts +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Alexander Tkačenko
|
|
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
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# @t8/docsgen
|
|
2
|
+
|
|
3
|
+
*Generates docs from READMEs*
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
# with specified docs entries (e.g. in docsgen.config.json)
|
|
7
|
+
npx @t8/docsgen [...<entry id or dir>]
|
|
8
|
+
|
|
9
|
+
# without entries
|
|
10
|
+
npx @t8/docsgen <dir path> <repo URL>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
<details>
|
|
14
|
+
<summary>Example of <i>docsgen.config.json</i></summary>
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
{
|
|
18
|
+
"$schema": "https://unpkg.com/@t8/docsgen/schema.json",
|
|
19
|
+
"baseColor": "purple",
|
|
20
|
+
"favicon": "/assets/favicon.png",
|
|
21
|
+
"append": {
|
|
22
|
+
"body": "<script src=\"/assets/stats.js\"></script>"
|
|
23
|
+
},
|
|
24
|
+
"linkMap": {
|
|
25
|
+
"https://github.com/org/package1": "/package1"
|
|
26
|
+
"https://github.com/org/package2": "/package2"
|
|
27
|
+
},
|
|
28
|
+
"entries": [
|
|
29
|
+
{
|
|
30
|
+
"dir": "package1",
|
|
31
|
+
"htmlTitle": "<a href=\"/\">Org</a> / Package 1",
|
|
32
|
+
"repo": "https://github.com/org/package1",
|
|
33
|
+
"nav": "/assets/nav_links.html"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"dir": "package2",
|
|
37
|
+
"htmlTitle": "<a href=\"/\">Org</a> / Package 2",
|
|
38
|
+
"repo": "https://github.com/org/package2",
|
|
39
|
+
"nav": "/assets/nav_links.html",
|
|
40
|
+
"singlePage": true
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
</details>
|
package/dist/bin.js
CHANGED
|
@@ -212,20 +212,26 @@ async function getConfig() {
|
|
|
212
212
|
delete localConfig.$schema;
|
|
213
213
|
} catch {
|
|
214
214
|
}
|
|
215
|
-
let targetId;
|
|
216
215
|
let args = process.argv.slice(2);
|
|
217
|
-
|
|
216
|
+
let targetArgs = [];
|
|
217
|
+
while (args[0] && !args[0].startsWith("--")) targetArgs.push(args.shift());
|
|
218
218
|
config = {
|
|
219
|
-
targetId,
|
|
220
219
|
mainBranch: "main",
|
|
221
220
|
root: "/",
|
|
222
221
|
contentDir: "x",
|
|
223
222
|
...localConfig,
|
|
224
223
|
...parseArgs(args)
|
|
225
224
|
};
|
|
226
|
-
if (config.entries)
|
|
225
|
+
if (config.entries) {
|
|
226
|
+
config.targetIds = targetArgs;
|
|
227
227
|
config.entries = await Promise.all(config.entries.map(reviseConfig));
|
|
228
|
-
else
|
|
228
|
+
} else {
|
|
229
|
+
if (!config.dir)
|
|
230
|
+
config.dir = targetArgs.find((arg) => !/^https?:\/\//.test(arg));
|
|
231
|
+
if (!config.repo)
|
|
232
|
+
config.repo = targetArgs.find((arg) => /^https?:\/\//.test(arg));
|
|
233
|
+
config = await reviseConfig(config);
|
|
234
|
+
}
|
|
229
235
|
return config;
|
|
230
236
|
}
|
|
231
237
|
|
|
@@ -895,25 +901,14 @@ async function runEntry(ctx) {
|
|
|
895
901
|
|
|
896
902
|
// src/bin/run.ts
|
|
897
903
|
async function run() {
|
|
898
|
-
let {
|
|
899
|
-
if (!entries)
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
({ id, dir }) => id === targetId || dir === targetId
|
|
907
|
-
);
|
|
908
|
-
if (entryCtx) runEntry({ ...rootCtx, ...entryCtx });
|
|
909
|
-
else console.warn(`Specified config entry not found: '${targetId}'`);
|
|
910
|
-
} else {
|
|
911
|
-
await Promise.all(
|
|
912
|
-
entries.map((entryCtx) => {
|
|
913
|
-
return runEntry({ ...rootCtx, ...entryCtx });
|
|
914
|
-
})
|
|
915
|
-
);
|
|
916
|
-
}
|
|
904
|
+
let { targetIds, entries, ...rootCtx } = await getConfig();
|
|
905
|
+
if (!entries) return await runEntry(rootCtx);
|
|
906
|
+
let targetEntries = targetIds && targetIds.length !== 0 ? entries.filter(({ id, dir }) => {
|
|
907
|
+
return id && targetIds.includes(id) || dir && targetIds.includes(dir);
|
|
908
|
+
}) : entries;
|
|
909
|
+
await Promise.all(
|
|
910
|
+
targetEntries.map((entryCtx) => runEntry({ ...rootCtx, ...entryCtx }))
|
|
911
|
+
);
|
|
917
912
|
}
|
|
918
913
|
(async () => {
|
|
919
914
|
await run();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t8/docsgen",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.58",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/bin.js",
|
|
6
6
|
"bin": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"type": "git",
|
|
22
22
|
"url": "git+https://github.com/t8js/docsgen.git"
|
|
23
23
|
},
|
|
24
|
-
"license": "
|
|
24
|
+
"license": "MIT",
|
|
25
25
|
"author": "axtk",
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/jsdom": "^27.0.0",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"typescript": "^5.9.3"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"args-json": "^1.2.
|
|
33
|
+
"args-json": "^1.2.6",
|
|
34
34
|
"jsdom": "^27.0.0",
|
|
35
35
|
"markdown-it": "^14.1.0"
|
|
36
36
|
}
|
package/schema.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"$ref":"#/definitions/Config","$schema":"http://json-schema.org/draft-07/schema#","definitions":{"Config":{"additionalProperties":false,"properties":{"$schema":{"type":"string"},"append":{"$ref":"#/definitions/ContentInjectionMap%3C(%22head%22%7C%22body%22%7C%22%3Ahas-code%22)%3E"},"backstory":{"description":"Backstory link URL to be added to the front page.","type":"string"},"baseColor":{"type":"string"},"cname":{"description":"Content of the './CNAME' file.","type":"string"},"contentDir":{"description":"Generated section content directory.","type":"string"},"description":{"type":"string"},"dir":{"type":"string"},"entries":{"items":{"$ref":"#/definitions/EntryConfig"},"type":"array"},"favicon":{"description":"Favicon URL.","type":"string"},"faviconType":{"type":"string"},"htmlTitle":{"type":"string"},"id":{"type":"string"},"jsorg":{"description":"As a boolean, it means whether to add the '<package_name>.js.org' domain to the './CNAME' file.\n\nAs a string, it sets the '<jsorg_value>.js.org' domain to the './CNAME' file.","type":["boolean","string"]},"linkMap":{"additionalProperties":{"anyOf":[{"type":"string"},{"not":{}}]},"description":"Link substitution map.","type":"object"},"mainBranch":{"type":"string"},"name":{"type":"string"},"nav":{"description":"URL of an HTML file inserted into the navigation bar.","type":"string"},"npm":{"type":"string"},"redirect":{"description":"Redirection URL.","type":"string"},"remove":{"description":"Whether to remove the GitHub Pages branch and quit.","type":"boolean"},"repo":{"type":"string"},"root":{"description":"Main page root path.","type":"string"},"scope":{"description":"Scope URL.","type":"string"},"singlePage":{"description":"Whether to show all sections on a single page.","type":"boolean"},"source":{"type":"string"},"targetBranch":{"description":"Target branch.","examples":["gh-pages"],"type":"string"},"
|
|
1
|
+
{"$ref":"#/definitions/Config","$schema":"http://json-schema.org/draft-07/schema#","definitions":{"Config":{"additionalProperties":false,"properties":{"$schema":{"type":"string"},"append":{"$ref":"#/definitions/ContentInjectionMap%3C(%22head%22%7C%22body%22%7C%22%3Ahas-code%22)%3E"},"backstory":{"description":"Backstory link URL to be added to the front page.","type":"string"},"baseColor":{"type":"string"},"cname":{"description":"Content of the './CNAME' file.","type":"string"},"contentDir":{"description":"Generated section content directory.","type":"string"},"description":{"type":"string"},"dir":{"type":"string"},"entries":{"items":{"$ref":"#/definitions/EntryConfig"},"type":"array"},"favicon":{"description":"Favicon URL.","type":"string"},"faviconType":{"type":"string"},"htmlTitle":{"type":"string"},"id":{"type":"string"},"jsorg":{"description":"As a boolean, it means whether to add the '<package_name>.js.org' domain to the './CNAME' file.\n\nAs a string, it sets the '<jsorg_value>.js.org' domain to the './CNAME' file.","type":["boolean","string"]},"linkMap":{"additionalProperties":{"anyOf":[{"type":"string"},{"not":{}}]},"description":"Link substitution map.","type":"object"},"mainBranch":{"type":"string"},"name":{"type":"string"},"nav":{"description":"URL of an HTML file inserted into the navigation bar.","type":"string"},"npm":{"type":"string"},"redirect":{"description":"Redirection URL.","type":"string"},"remove":{"description":"Whether to remove the GitHub Pages branch and quit.","type":"boolean"},"repo":{"type":"string"},"root":{"description":"Main page root path.","type":"string"},"scope":{"description":"Scope URL.","type":"string"},"singlePage":{"description":"Whether to show all sections on a single page.","type":"boolean"},"source":{"type":"string"},"targetBranch":{"description":"Target branch.","examples":["gh-pages"],"type":"string"},"targetIds":{"items":{"type":"string"},"type":"array"},"theme":{"type":"string"},"title":{"type":"string"},"version":{"type":"string"},"ymid":{"type":["number","string"]}},"type":"object"},"ContentInjectionMap<(\"head\"|\"body\"|\":has-code\")>":{"additionalProperties":false,"properties":{":has-code":{"anyOf":[{"type":"string"},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"},{"items":{"anyOf":[{"type":"string"},{"not":{}},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"}]},"type":"array"}]},"body":{"anyOf":[{"type":"string"},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"},{"items":{"anyOf":[{"type":"string"},{"not":{}},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"}]},"type":"array"}]},"head":{"anyOf":[{"type":"string"},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"},{"items":{"anyOf":[{"type":"string"},{"not":{}},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"}]},"type":"array"}]}},"type":"object"},"EntryConfig":{"additionalProperties":false,"properties":{"append":{"$ref":"#/definitions/ContentInjectionMap%3C(%22head%22%7C%22body%22%7C%22%3Ahas-code%22)%3E"},"backstory":{"description":"Backstory link URL to be added to the front page.","type":"string"},"baseColor":{"type":"string"},"cname":{"description":"Content of the './CNAME' file.","type":"string"},"contentDir":{"description":"Generated section content directory.","type":"string"},"description":{"type":"string"},"dir":{"type":"string"},"favicon":{"description":"Favicon URL.","type":"string"},"faviconType":{"type":"string"},"htmlTitle":{"type":"string"},"id":{"type":"string"},"jsorg":{"description":"As a boolean, it means whether to add the '<package_name>.js.org' domain to the './CNAME' file.\n\nAs a string, it sets the '<jsorg_value>.js.org' domain to the './CNAME' file.","type":["boolean","string"]},"linkMap":{"additionalProperties":{"anyOf":[{"type":"string"},{"not":{}}]},"description":"Link substitution map.","type":"object"},"mainBranch":{"type":"string"},"name":{"type":"string"},"nav":{"description":"URL of an HTML file inserted into the navigation bar.","type":"string"},"npm":{"type":"string"},"redirect":{"description":"Redirection URL.","type":"string"},"remove":{"description":"Whether to remove the GitHub Pages branch and quit.","type":"boolean"},"repo":{"type":"string"},"root":{"description":"Main page root path.","type":"string"},"scope":{"description":"Scope URL.","type":"string"},"singlePage":{"description":"Whether to show all sections on a single page.","type":"boolean"},"source":{"type":"string"},"targetBranch":{"description":"Target branch.","examples":["gh-pages"],"type":"string"},"theme":{"type":"string"},"title":{"type":"string"},"version":{"type":"string"},"ymid":{"type":["number","string"]}},"type":"object"},"Page":{"enum":["index","start","section","redirect"],"type":"string"}}}
|
package/src/bin/getConfig.ts
CHANGED
|
@@ -56,13 +56,12 @@ export async function getConfig(): Promise<Config> {
|
|
|
56
56
|
delete localConfig.$schema;
|
|
57
57
|
} catch {}
|
|
58
58
|
|
|
59
|
-
let targetId: string | undefined;
|
|
60
59
|
let args = process.argv.slice(2);
|
|
60
|
+
let targetArgs: string[] = [];
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
while (args[0] && !args[0].startsWith("--")) targetArgs.push(args.shift()!);
|
|
63
63
|
|
|
64
64
|
config = {
|
|
65
|
-
targetId,
|
|
66
65
|
mainBranch: "main",
|
|
67
66
|
root: "/",
|
|
68
67
|
contentDir: "x",
|
|
@@ -70,9 +69,18 @@ export async function getConfig(): Promise<Config> {
|
|
|
70
69
|
...parseArgs<Config>(args),
|
|
71
70
|
};
|
|
72
71
|
|
|
73
|
-
if (config.entries)
|
|
72
|
+
if (config.entries) {
|
|
73
|
+
config.targetIds = targetArgs;
|
|
74
74
|
config.entries = await Promise.all(config.entries.map(reviseConfig));
|
|
75
|
-
else
|
|
75
|
+
} else {
|
|
76
|
+
if (!config.dir)
|
|
77
|
+
config.dir = targetArgs.find((arg) => !/^https?:\/\//.test(arg));
|
|
78
|
+
|
|
79
|
+
if (!config.repo)
|
|
80
|
+
config.repo = targetArgs.find((arg) => /^https?:\/\//.test(arg));
|
|
81
|
+
|
|
82
|
+
config = await reviseConfig(config);
|
|
83
|
+
}
|
|
76
84
|
|
|
77
85
|
return config;
|
|
78
86
|
}
|
package/src/bin/run.ts
CHANGED
|
@@ -3,29 +3,22 @@ import { getConfig } from "./getConfig";
|
|
|
3
3
|
import { runEntry } from "./runEntry";
|
|
4
4
|
|
|
5
5
|
async function run() {
|
|
6
|
-
let {
|
|
6
|
+
let { targetIds, entries, ...rootCtx } = await getConfig();
|
|
7
7
|
|
|
8
|
-
if (!entries)
|
|
9
|
-
if (!targetId || targetId === rootCtx.id) return await runEntry(rootCtx);
|
|
8
|
+
if (!entries) return await runEntry(rootCtx);
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
let targetEntries =
|
|
11
|
+
targetIds && targetIds.length !== 0
|
|
12
|
+
? entries.filter(({ id, dir }) => {
|
|
13
|
+
return (
|
|
14
|
+
(id && targetIds.includes(id)) || (dir && targetIds.includes(dir))
|
|
15
|
+
);
|
|
16
|
+
})
|
|
17
|
+
: entries;
|
|
14
18
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
if (entryCtx) runEntry({ ...rootCtx, ...entryCtx });
|
|
21
|
-
else console.warn(`Specified config entry not found: '${targetId}'`);
|
|
22
|
-
} else {
|
|
23
|
-
await Promise.all(
|
|
24
|
-
entries.map((entryCtx) => {
|
|
25
|
-
return runEntry({ ...rootCtx, ...entryCtx });
|
|
26
|
-
}),
|
|
27
|
-
);
|
|
28
|
-
}
|
|
19
|
+
await Promise.all(
|
|
20
|
+
targetEntries.map((entryCtx) => runEntry({ ...rootCtx, ...entryCtx })),
|
|
21
|
+
);
|
|
29
22
|
}
|
|
30
23
|
|
|
31
24
|
(async () => {
|