@t8/docsgen 0.1.25 → 0.1.27

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
@@ -574,6 +574,12 @@ async function setContent(ctx) {
574
574
  let packageVersion = (await exec(`npm view ${packageName} version`)).stdout.trim().split(".").slice(0, 2).join(".");
575
575
  let packageUrl = `https://unpkg.com/${packageName}@${packageVersion}`;
576
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();
577
583
  if (theme) rootAttrs += ` data-theme="${escapeHTML(theme)}"`;
578
584
  if (baseColor) rootAttrs += ` style="--base-color: ${escapeHTML(baseColor)}"`;
579
585
  let icon = getIcon(ctx);
@@ -660,12 +666,7 @@ ${navContent.replace(
660
666
  </div>
661
667
  </div>
662
668
 
663
- ${content.includes("<pre><code ") ? `
664
- <link rel="stylesheet" href="https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/base16/material.min.css">
665
- <link rel="stylesheet" href="${packageUrl}/dist/css/code.css">
666
- <script src="https://unpkg.com/@highlightjs/cdn-assets@11.11.1/highlight.min.js"></script>
667
- <script>hljs.highlightAll()</script>
668
- `.trim() : ""}
669
+ ${content.includes("<pre><code ") ? getInjectedContent(ctx, "section", ":has-code") || defaultCodeStyleContent : ""}
669
670
  ${counterContent}
670
671
  ${getInjectedContent(ctx, "section", "body")}
671
672
  </body>
@@ -721,12 +722,7 @@ ${features ? `
721
722
  </main>
722
723
  </div>
723
724
 
724
- ${[description, features].some((s) => s.includes("<pre><code ")) ? `
725
- <link rel="stylesheet" href="https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/base16/material.min.css">
726
- <link rel="stylesheet" href="${packageUrl}/dist/css/code.css">
727
- <script src="https://unpkg.com/@highlightjs/cdn-assets@11.11.1/highlight.min.js"></script>
728
- <script>hljs.highlightAll()</script>
729
- `.trim() : ""}
725
+ ${[description, features].some((s) => s.includes("<pre><code ")) ? getInjectedContent(ctx, "index", ":has-code") || defaultCodeStyleContent : ""}
730
726
  ${counterContent}
731
727
  ${getInjectedContent(ctx, "index", "body")}
732
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);
@@ -145,18 +144,16 @@ h2,
145
144
  h3,
146
145
  h4 {
147
146
  line-height: 1.1;
147
+ margin: 1.3em 0 0.65em 0;
148
148
  }
149
149
  h2 {
150
- font-size: 1.6em;
151
- margin: 1em 0 0.65em 0;
150
+ font-size: 1.5em;
152
151
  }
153
152
  h3 {
154
153
  font-size: 1.3em;
155
- margin: 1em 0 0.65em 0;
156
154
  }
157
155
  h4 {
158
156
  font-size: 1.15em;
159
- margin: 1em 0 0.65em 0;
160
157
  }
161
158
 
162
159
  header,
@@ -207,7 +204,7 @@ pre,
207
204
  pre.highlight {
208
205
  line-height: 1.25;
209
206
  color: inherit;
210
- border-radius: 1em;
207
+ border-radius: 0.5em;
211
208
  overflow: auto;
212
209
  }
213
210
  pre > code {
@@ -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
  }
@@ -141,7 +139,7 @@ main h1 + h2 {
141
139
  margin-top: 0.75rem;
142
140
  }
143
141
  main h2 {
144
- border-bottom: var(--hr-border);
142
+ border-bottom: .3rem solid var(--b1-light);
145
143
  padding-bottom: 0.1em;
146
144
  }
147
145
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t8/docsgen",
3
- "version": "0.1.25",
3
+ "version": "0.1.27",
4
4
  "description": "",
5
5
  "main": "dist/bin.js",
6
6
  "bin": {
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)%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"}}}
@@ -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}`;
@@ -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);
@@ -145,18 +144,16 @@ h2,
145
144
  h3,
146
145
  h4 {
147
146
  line-height: 1.1;
147
+ margin: 1.3em 0 0.65em 0;
148
148
  }
149
149
  h2 {
150
- font-size: 1.6em;
151
- margin: 1em 0 0.65em 0;
150
+ font-size: 1.5em;
152
151
  }
153
152
  h3 {
154
153
  font-size: 1.3em;
155
- margin: 1em 0 0.65em 0;
156
154
  }
157
155
  h4 {
158
156
  font-size: 1.15em;
159
- margin: 1em 0 0.65em 0;
160
157
  }
161
158
 
162
159
  header,
@@ -207,7 +204,7 @@ pre,
207
204
  pre.highlight {
208
205
  line-height: 1.25;
209
206
  color: inherit;
210
- border-radius: 1em;
207
+ border-radius: 0.5em;
211
208
  overflow: auto;
212
209
  }
213
210
  pre > code {
@@ -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
  }
@@ -141,7 +139,7 @@ main h1 + h2 {
141
139
  margin-top: 0.75rem;
142
140
  }
143
141
  main h2 {
144
- border-bottom: var(--hr-border);
142
+ border-bottom: .3rem solid var(--b1-light);
145
143
  padding-bottom: 0.1em;
146
144
  }
147
145
 
@@ -1 +1 @@
1
- export type ContentInjectionTarget = "head" | "body";
1
+ export type ContentInjectionTarget = "head" | "body" | ":has-code";
@@ -59,5 +59,5 @@ export type EntryConfig = {
59
59
  */
60
60
  jsorg?: boolean | string;
61
61
  ymid?: number | string;
62
- append?: ContentInjectionMap<"head" | "body">;
62
+ append?: ContentInjectionMap<"head" | "body" | ":has-code">;
63
63
  };