@t8/docsgen 0.1.24 → 0.1.26
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 +9 -12
- package/dist/css/base.css +1 -2
- package/dist/css/section.css +0 -2
- package/package.json +1 -1
- package/schema.json +1 -1
- package/src/bin/getConfig.ts +2 -0
- package/src/bin/getInjectedContent.ts +1 -1
- package/src/bin/setContent.ts +9 -12
- package/src/css/base.css +1 -2
- package/src/css/section.css +0 -2
- package/src/types/Config.ts +1 -0
- package/src/types/ContentInjectionTarget.ts +1 -1
- package/src/types/EntryConfig.ts +1 -1
package/dist/bin.js
CHANGED
|
@@ -176,6 +176,7 @@ async function getConfig() {
|
|
|
176
176
|
localConfig = JSON.parse(
|
|
177
177
|
await fetchText("./docsgen.config.json")
|
|
178
178
|
);
|
|
179
|
+
delete localConfig.$schema;
|
|
179
180
|
} catch {
|
|
180
181
|
}
|
|
181
182
|
let targetId;
|
|
@@ -573,6 +574,12 @@ async function setContent(ctx) {
|
|
|
573
574
|
let packageVersion = (await exec(`npm view ${packageName} version`)).stdout.trim().split(".").slice(0, 2).join(".");
|
|
574
575
|
let packageUrl = `https://unpkg.com/${packageName}@${packageVersion}`;
|
|
575
576
|
let rootAttrs = "";
|
|
577
|
+
let defaultCodeStyleContent = `
|
|
578
|
+
<link rel="stylesheet" href="https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/base16/material.min.css">
|
|
579
|
+
<link rel="stylesheet" href="${packageUrl}/dist/css/code.css">
|
|
580
|
+
<script src="https://unpkg.com/@highlightjs/cdn-assets@11.11.1/highlight.min.js"></script>
|
|
581
|
+
<script>hljs.highlightAll()</script>
|
|
582
|
+
`.trim();
|
|
576
583
|
if (theme) rootAttrs += ` data-theme="${escapeHTML(theme)}"`;
|
|
577
584
|
if (baseColor) rootAttrs += ` style="--base-color: ${escapeHTML(baseColor)}"`;
|
|
578
585
|
let icon = getIcon(ctx);
|
|
@@ -659,12 +666,7 @@ ${navContent.replace(
|
|
|
659
666
|
</div>
|
|
660
667
|
</div>
|
|
661
668
|
|
|
662
|
-
${content.includes("<pre><code ") ?
|
|
663
|
-
<link rel="stylesheet" href="https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/base16/material.min.css">
|
|
664
|
-
<link rel="stylesheet" href="${packageUrl}/dist/css/code.css">
|
|
665
|
-
<script src="https://unpkg.com/@highlightjs/cdn-assets@11.11.1/highlight.min.js"></script>
|
|
666
|
-
<script>hljs.highlightAll()</script>
|
|
667
|
-
`.trim() : ""}
|
|
669
|
+
${content.includes("<pre><code ") ? getInjectedContent(ctx, "section", ":has-code") || defaultCodeStyleContent : ""}
|
|
668
670
|
${counterContent}
|
|
669
671
|
${getInjectedContent(ctx, "section", "body")}
|
|
670
672
|
</body>
|
|
@@ -720,12 +722,7 @@ ${features ? `
|
|
|
720
722
|
</main>
|
|
721
723
|
</div>
|
|
722
724
|
|
|
723
|
-
${[description, features].some((s) => s.includes("<pre><code ")) ?
|
|
724
|
-
<link rel="stylesheet" href="https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/base16/material.min.css">
|
|
725
|
-
<link rel="stylesheet" href="${packageUrl}/dist/css/code.css">
|
|
726
|
-
<script src="https://unpkg.com/@highlightjs/cdn-assets@11.11.1/highlight.min.js"></script>
|
|
727
|
-
<script>hljs.highlightAll()</script>
|
|
728
|
-
`.trim() : ""}
|
|
725
|
+
${[description, features].some((s) => s.includes("<pre><code ")) ? getInjectedContent(ctx, "index", ":has-code") || defaultCodeStyleContent : ""}
|
|
729
726
|
${counterContent}
|
|
730
727
|
${getInjectedContent(ctx, "index", "body")}
|
|
731
728
|
</body>
|
package/dist/css/base.css
CHANGED
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
--max-content-width: 64em;
|
|
31
31
|
--content-padding-x: 1.75rem;
|
|
32
32
|
--content-padding-y: 1.75rem;
|
|
33
|
-
--content-border-radius: 1rem;
|
|
34
33
|
--space-x: var(--content-padding-x);
|
|
35
34
|
--block-margin-y: 1em;
|
|
36
35
|
--hr-border: 0.15rem solid var(--b1-medium);
|
|
@@ -207,7 +206,7 @@ pre,
|
|
|
207
206
|
pre.highlight {
|
|
208
207
|
line-height: 1.25;
|
|
209
208
|
color: inherit;
|
|
210
|
-
border-radius:
|
|
209
|
+
border-radius: 0.5em;
|
|
211
210
|
overflow: auto;
|
|
212
211
|
}
|
|
213
212
|
pre > code {
|
package/dist/css/section.css
CHANGED
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
align-self: flex-start;
|
|
19
19
|
font-size: 0.9em;
|
|
20
20
|
background: var(--b1-light);
|
|
21
|
-
border-radius: var(--content-border-radius);
|
|
22
21
|
padding: 0.5rem var(--content-padding-x) 0.65rem;
|
|
23
22
|
margin: 0 0 0 var(--space-x);
|
|
24
23
|
box-sizing: border-box;
|
|
@@ -28,7 +27,6 @@
|
|
|
28
27
|
width: 100%;
|
|
29
28
|
font-size: inherit;
|
|
30
29
|
border-top: 0.35em solid var(--b1);
|
|
31
|
-
border-radius: 0;
|
|
32
30
|
padding: 0.25rem var(--content-padding-x) 0.35rem;
|
|
33
31
|
margin: 0;
|
|
34
32
|
}
|
package/package.json
CHANGED
package/schema.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"$ref":"#/definitions/Config","$schema":"http://json-schema.org/draft-07/schema#","definitions":{"Config":{"additionalProperties":false,"properties":{"append":{"$ref":"#/definitions/ContentInjectionMap%3C(%22head%22%7C%22body%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"]},"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"},"targetId":{"type":"string"},"theme":{"type":"string"},"title":{"type":"string"},"version":{"type":"string"},"ymid":{"type":["number","string"]}},"type":"object"},"ContentInjectionMap<(\"head\"|\"body\")>":{"additionalProperties":false,"properties":{"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)%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"]},"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"}}}
|
|
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"]},"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"},"targetId":{"type":"string"},"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"]},"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
|
@@ -14,7 +14,7 @@ export function getInjectedContent(
|
|
|
14
14
|
|
|
15
15
|
return (
|
|
16
16
|
Array.isArray(injectedContent) ? injectedContent : [injectedContent]
|
|
17
|
-
).reduce((s, item) => {
|
|
17
|
+
).reduce<string>((s, item) => {
|
|
18
18
|
if (item === undefined) return s;
|
|
19
19
|
|
|
20
20
|
if (typeof item === "string") return `${s}${s ? "\n" : ""}${item}`;
|
package/src/bin/setContent.ts
CHANGED
|
@@ -44,6 +44,13 @@ export async function setContent(ctx: Context) {
|
|
|
44
44
|
let packageUrl = `https://unpkg.com/${packageName}@${packageVersion}`;
|
|
45
45
|
let rootAttrs = "";
|
|
46
46
|
|
|
47
|
+
let defaultCodeStyleContent = `
|
|
48
|
+
<link rel="stylesheet" href="https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/base16/material.min.css">
|
|
49
|
+
<link rel="stylesheet" href="${packageUrl}/dist/css/code.css">
|
|
50
|
+
<script src="https://unpkg.com/@highlightjs/cdn-assets@11.11.1/highlight.min.js"></script>
|
|
51
|
+
<script>hljs.highlightAll()</script>
|
|
52
|
+
`.trim();
|
|
53
|
+
|
|
47
54
|
if (theme) rootAttrs += ` data-theme="${escapeHTML(theme)}"`;
|
|
48
55
|
|
|
49
56
|
if (baseColor) rootAttrs += ` style="--base-color: ${escapeHTML(baseColor)}"`;
|
|
@@ -145,12 +152,7 @@ ${navContent.replace(
|
|
|
145
152
|
|
|
146
153
|
${
|
|
147
154
|
content.includes("<pre><code ")
|
|
148
|
-
?
|
|
149
|
-
<link rel="stylesheet" href="https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/base16/material.min.css">
|
|
150
|
-
<link rel="stylesheet" href="${packageUrl}/dist/css/code.css">
|
|
151
|
-
<script src="https://unpkg.com/@highlightjs/cdn-assets@11.11.1/highlight.min.js"></script>
|
|
152
|
-
<script>hljs.highlightAll()</script>
|
|
153
|
-
`.trim()
|
|
155
|
+
? (getInjectedContent(ctx, "section", ":has-code") || defaultCodeStyleContent)
|
|
154
156
|
: ""
|
|
155
157
|
}
|
|
156
158
|
${counterContent}
|
|
@@ -214,12 +216,7 @@ ${
|
|
|
214
216
|
|
|
215
217
|
${
|
|
216
218
|
[description, features].some((s) => s.includes("<pre><code "))
|
|
217
|
-
?
|
|
218
|
-
<link rel="stylesheet" href="https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/base16/material.min.css">
|
|
219
|
-
<link rel="stylesheet" href="${packageUrl}/dist/css/code.css">
|
|
220
|
-
<script src="https://unpkg.com/@highlightjs/cdn-assets@11.11.1/highlight.min.js"></script>
|
|
221
|
-
<script>hljs.highlightAll()</script>
|
|
222
|
-
`.trim()
|
|
219
|
+
? (getInjectedContent(ctx, "index", ":has-code") || defaultCodeStyleContent)
|
|
223
220
|
: ""
|
|
224
221
|
}
|
|
225
222
|
${counterContent}
|
package/src/css/base.css
CHANGED
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
--max-content-width: 64em;
|
|
31
31
|
--content-padding-x: 1.75rem;
|
|
32
32
|
--content-padding-y: 1.75rem;
|
|
33
|
-
--content-border-radius: 1rem;
|
|
34
33
|
--space-x: var(--content-padding-x);
|
|
35
34
|
--block-margin-y: 1em;
|
|
36
35
|
--hr-border: 0.15rem solid var(--b1-medium);
|
|
@@ -207,7 +206,7 @@ pre,
|
|
|
207
206
|
pre.highlight {
|
|
208
207
|
line-height: 1.25;
|
|
209
208
|
color: inherit;
|
|
210
|
-
border-radius:
|
|
209
|
+
border-radius: 0.5em;
|
|
211
210
|
overflow: auto;
|
|
212
211
|
}
|
|
213
212
|
pre > code {
|
package/src/css/section.css
CHANGED
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
align-self: flex-start;
|
|
19
19
|
font-size: 0.9em;
|
|
20
20
|
background: var(--b1-light);
|
|
21
|
-
border-radius: var(--content-border-radius);
|
|
22
21
|
padding: 0.5rem var(--content-padding-x) 0.65rem;
|
|
23
22
|
margin: 0 0 0 var(--space-x);
|
|
24
23
|
box-sizing: border-box;
|
|
@@ -28,7 +27,6 @@
|
|
|
28
27
|
width: 100%;
|
|
29
28
|
font-size: inherit;
|
|
30
29
|
border-top: 0.35em solid var(--b1);
|
|
31
|
-
border-radius: 0;
|
|
32
30
|
padding: 0.25rem var(--content-padding-x) 0.35rem;
|
|
33
31
|
margin: 0;
|
|
34
32
|
}
|
package/src/types/Config.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type ContentInjectionTarget = "head" | "body";
|
|
1
|
+
export type ContentInjectionTarget = "head" | "body" | ":has-code";
|
package/src/types/EntryConfig.ts
CHANGED