@t8/docsgen 0.3.13 → 0.3.15
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/dist/bin.js
CHANGED
|
@@ -511,7 +511,7 @@ function buildNav(ctx, dom) {
|
|
|
511
511
|
|
|
512
512
|
// src/bin/parsing/getInstallationCode.ts
|
|
513
513
|
function getInstallationCode(element) {
|
|
514
|
-
return element.querySelector("code")?.
|
|
514
|
+
return element.querySelector("code")?.textContent.trim().match(/(\S\s*)?(npm (i|install) .*)/)?.[2];
|
|
515
515
|
}
|
|
516
516
|
|
|
517
517
|
// src/bin/parsing/getSectionPostprocess.ts
|
|
@@ -569,7 +569,7 @@ var md = new Markdown({
|
|
|
569
569
|
html: true
|
|
570
570
|
});
|
|
571
571
|
async function getParsedContent(ctx) {
|
|
572
|
-
let { singlePage, firstLineDescription, linkMap } = ctx;
|
|
572
|
+
let { singlePage, firstLineDescription, hasCoverIntro = true, linkMap } = ctx;
|
|
573
573
|
let rawContent = await fetchContent(
|
|
574
574
|
getLocation(ctx, "README.md", ctx.source)
|
|
575
575
|
);
|
|
@@ -628,7 +628,11 @@ async function getParsedContent(ctx) {
|
|
|
628
628
|
description.push(outerHTML);
|
|
629
629
|
continue;
|
|
630
630
|
}
|
|
631
|
-
|
|
631
|
+
if (hasCoverIntro) {
|
|
632
|
+
intro.push(outerHTML);
|
|
633
|
+
continue;
|
|
634
|
+
}
|
|
635
|
+
indexComplete = true;
|
|
632
636
|
}
|
|
633
637
|
if (section.length !== 0) sections.push(joinLines(section));
|
|
634
638
|
let postprocess = getSectionPostprocess({
|
|
@@ -695,6 +699,7 @@ async function setContent(ctx) {
|
|
|
695
699
|
title,
|
|
696
700
|
htmlTitle,
|
|
697
701
|
description: packageDescription,
|
|
702
|
+
isDevDep,
|
|
698
703
|
backstory,
|
|
699
704
|
redirect
|
|
700
705
|
} = ctx;
|
|
@@ -760,6 +765,8 @@ ${getInjectedContent(ctx, "redirect", "body", "append")}
|
|
|
760
765
|
);
|
|
761
766
|
let coverTitle = htmlTitle || parsedTitle || plainTitle;
|
|
762
767
|
let descriptionContent = tweakTypography(description) || (escapedPackageDescription ? `<p>${tweakTypography(escapedPackageDescription)}<p>` : "");
|
|
768
|
+
if (!installation || isDevDep !== void 0)
|
|
769
|
+
installation = `npm i${isDevDep ? " -D" : ""} ${name}`;
|
|
763
770
|
let navContent = await getNav(ctx, nav);
|
|
764
771
|
let dirs = [contentDir];
|
|
765
772
|
await Promise.all(
|
|
@@ -862,7 +869,7 @@ ${getInjectedContent(ctx, "index", "body", "prepend")}
|
|
|
862
869
|
${getRepoLink(ctx)}
|
|
863
870
|
</p>
|
|
864
871
|
${backstory ? `<p class="ref"><a href="${backstory}">Backstory</a></p>` : ""}
|
|
865
|
-
<p class="installation"><code>${installation}</code></p>
|
|
872
|
+
<p class="installation"><code>${escapeHTML(installation)}</code></p>
|
|
866
873
|
${getInjectedContent(ctx, "index", "cover", "append")}
|
|
867
874
|
</div>
|
|
868
875
|
</section>
|
package/package.json
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@t8/docsgen",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "dist/bin.js",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"bin": {
|
|
8
|
-
"docsgen": "dist/bin.js"
|
|
9
|
-
},
|
|
10
|
-
"scripts": {
|
|
11
|
-
"build": "npx npm-run-all clean build-bin build-css",
|
|
12
|
-
"build-bin": "npx esbuild ./src/bin/run.ts --bundle --outfile=dist/bin.js --platform=node --external:jsdom --external:markdown-it --format=esm",
|
|
13
|
-
"build-css": "node -e \"require('node:fs').cpSync('src/css', 'dist/css', { force: true, recursive: true });\"",
|
|
14
|
-
"clean": "node -e \"require('node:fs').rmSync('dist', { force: true, recursive: true });\"",
|
|
15
|
-
"patch": "node src/scripts/patch.ts",
|
|
16
|
-
"preversion": "npx npm-run-all shape build",
|
|
17
|
-
"schema": "npx ts-json-schema-generator -p src/types/Config.ts -t Config -o schema.json --minify",
|
|
18
|
-
"shape": "npx codeshape --check"
|
|
19
|
-
},
|
|
20
|
-
"repository": {
|
|
21
|
-
"type": "git",
|
|
22
|
-
"url": "git+https://github.com/t8js/docsgen.git"
|
|
23
|
-
},
|
|
24
|
-
"license": "MIT",
|
|
25
|
-
"author": "axtk",
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"@types/jsdom": "^27.0.0",
|
|
28
|
-
"@types/markdown-it": "^14.1.2",
|
|
29
|
-
"@types/node": "^25.0.2"
|
|
30
|
-
},
|
|
31
|
-
"dependencies": {
|
|
32
|
-
"args-json": "^1.2.9",
|
|
33
|
-
"jsdom": "^27.3.0",
|
|
34
|
-
"markdown-it": "^14.1.0"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@t8/docsgen",
|
|
3
|
+
"version": "0.3.15",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/bin.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"docsgen": "dist/bin.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "npx npm-run-all clean build-bin build-css",
|
|
12
|
+
"build-bin": "npx esbuild ./src/bin/run.ts --bundle --outfile=dist/bin.js --platform=node --external:jsdom --external:markdown-it --format=esm",
|
|
13
|
+
"build-css": "node -e \"require('node:fs').cpSync('src/css', 'dist/css', { force: true, recursive: true });\"",
|
|
14
|
+
"clean": "node -e \"require('node:fs').rmSync('dist', { force: true, recursive: true });\"",
|
|
15
|
+
"patch": "node src/scripts/patch.ts",
|
|
16
|
+
"preversion": "npx npm-run-all shape build",
|
|
17
|
+
"schema": "npx ts-json-schema-generator -p src/types/Config.ts -t Config -o schema.json --minify",
|
|
18
|
+
"shape": "npx codeshape --check"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/t8js/docsgen.git"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"author": "axtk",
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/jsdom": "^27.0.0",
|
|
28
|
+
"@types/markdown-it": "^14.1.2",
|
|
29
|
+
"@types/node": "^25.0.2"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"args-json": "^1.2.9",
|
|
33
|
+
"jsdom": "^27.3.0",
|
|
34
|
+
"markdown-it": "^14.1.0"
|
|
35
|
+
}
|
|
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"},"assetsDir":{"description":"Directory path for assets, relative to `dir`. If not provided, the assets will be added via the package URLs.","type":"string"},"backstory":{"description":"Backstory link URL to be added to the front page.","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"},"firstLineDescription":{"description":"Whether the first line following the main title is the package description.","type":"boolean"},"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"},"prepend":{"$ref":"#/definitions/ContentInjectionMap"},"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"},"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"},"title":{"type":"string"},"version":{"type":"string"},"ymid":{"type":["number","string"]}},"type":"object"},"ContentInjectionMap":{"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"}]},"cover":{"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"},"assetsDir":{"description":"Directory path for assets, relative to `dir`. If not provided, the assets will be added via the package URLs.","type":"string"},"backstory":{"description":"Backstory link URL to be added to the front page.","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"},"firstLineDescription":{"description":"Whether the first line following the main title is the package description.","type":"boolean"},"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"},"prepend":{"$ref":"#/definitions/ContentInjectionMap"},"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"},"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"},"title":{"type":"string"},"version":{"type":"string"},"ymid":{"type":["number","string"]}},"type":"object"},"Page":{"enum":["index","start","section","redirect"],"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"},"assetsDir":{"description":"Directory path for assets, relative to `dir`. If not provided, the assets will be added via the package URLs.","type":"string"},"backstory":{"description":"Backstory link URL to be added to the front page.","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"},"firstLineDescription":{"description":"Whether the first line following the main title is the package description.","type":"boolean"},"hasCoverIntro":{"type":"boolean"},"htmlTitle":{"type":"string"},"id":{"type":"string"},"isDevDep":{"description":"Whether the package installation instruction should include the \"-D\" flag.","type":"boolean"},"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"},"prepend":{"$ref":"#/definitions/ContentInjectionMap"},"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"},"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"},"title":{"type":"string"},"version":{"type":"string"},"ymid":{"type":["number","string"]}},"type":"object"},"ContentInjectionMap":{"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"}]},"cover":{"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"},"assetsDir":{"description":"Directory path for assets, relative to `dir`. If not provided, the assets will be added via the package URLs.","type":"string"},"backstory":{"description":"Backstory link URL to be added to the front page.","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"},"firstLineDescription":{"description":"Whether the first line following the main title is the package description.","type":"boolean"},"hasCoverIntro":{"type":"boolean"},"htmlTitle":{"type":"string"},"id":{"type":"string"},"isDevDep":{"description":"Whether the package installation instruction should include the \"-D\" flag.","type":"boolean"},"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"},"prepend":{"$ref":"#/definitions/ContentInjectionMap"},"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"},"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"},"title":{"type":"string"},"version":{"type":"string"},"ymid":{"type":["number","string"]}},"type":"object"},"Page":{"enum":["index","start","section","redirect"],"type":"string"}}}
|
|
@@ -15,7 +15,7 @@ const md = new Markdown({
|
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
export async function getParsedContent(ctx: Context) {
|
|
18
|
-
let { singlePage, firstLineDescription, linkMap } = ctx;
|
|
18
|
+
let { singlePage, firstLineDescription, hasCoverIntro = true, linkMap } = ctx;
|
|
19
19
|
let rawContent = await fetchContent(
|
|
20
20
|
getLocation(ctx, "README.md", ctx.source),
|
|
21
21
|
);
|
|
@@ -97,7 +97,12 @@ export async function getParsedContent(ctx: Context) {
|
|
|
97
97
|
continue;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
if (hasCoverIntro) {
|
|
101
|
+
intro.push(outerHTML);
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
indexComplete = true;
|
|
101
106
|
}
|
|
102
107
|
|
|
103
108
|
if (section.length !== 0) sections.push(joinLines(section));
|
package/src/bin/setContent.ts
CHANGED
|
@@ -47,6 +47,7 @@ export async function setContent(ctx: Context) {
|
|
|
47
47
|
title,
|
|
48
48
|
htmlTitle,
|
|
49
49
|
description: packageDescription,
|
|
50
|
+
isDevDep,
|
|
50
51
|
backstory,
|
|
51
52
|
redirect,
|
|
52
53
|
} = ctx;
|
|
@@ -136,6 +137,9 @@ ${getInjectedContent(ctx, "redirect", "body", "append")}
|
|
|
136
137
|
? `<p>${tweakTypography(escapedPackageDescription)}<p>`
|
|
137
138
|
: "");
|
|
138
139
|
|
|
140
|
+
if (!installation || isDevDep !== undefined)
|
|
141
|
+
installation = `npm i${isDevDep ? " -D" : ""} ${name}`;
|
|
142
|
+
|
|
139
143
|
let navContent = await getNav(ctx, nav);
|
|
140
144
|
let dirs = [contentDir];
|
|
141
145
|
|
|
@@ -246,7 +250,7 @@ ${getInjectedContent(ctx, "index", "body", "prepend")}
|
|
|
246
250
|
${getRepoLink(ctx)}
|
|
247
251
|
</p>
|
|
248
252
|
${backstory ? `<p class="ref"><a href="${backstory}">Backstory</a></p>` : ""}
|
|
249
|
-
<p class="installation"><code>${installation}</code></p>
|
|
253
|
+
<p class="installation"><code>${escapeHTML(installation)}</code></p>
|
|
250
254
|
${getInjectedContent(ctx, "index", "cover", "append")}
|
|
251
255
|
</div>
|
|
252
256
|
</section>
|
package/src/types/EntryConfig.ts
CHANGED
|
@@ -18,6 +18,12 @@ export type EntryConfig = {
|
|
|
18
18
|
* description.
|
|
19
19
|
*/
|
|
20
20
|
firstLineDescription?: boolean;
|
|
21
|
+
hasCoverIntro?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the package installation instruction should include the
|
|
24
|
+
* "-D" flag.
|
|
25
|
+
*/
|
|
26
|
+
isDevDep?: boolean;
|
|
21
27
|
version?: string;
|
|
22
28
|
repo?: string;
|
|
23
29
|
npm?: string;
|