@t8/docsgen 0.3.12 → 0.3.14

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")?.innerHTML.trim().match(/(\S\s*)?(npm (i|install) .*)/)?.[2];
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, 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
- intro.push(outerHTML);
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>
@@ -1,3 +1,6 @@
1
+ :root {
2
+ --max-content-width: 38em;
3
+ }
1
4
  body {
2
5
  min-height: 100vh;
3
6
  }
@@ -112,7 +115,7 @@ section .section-content {
112
115
  }
113
116
  section.intro-title {
114
117
  display: flex;
115
- width: 36%;
118
+ width: 40%;
116
119
  flex-direction: column;
117
120
  align-items: flex-end;
118
121
  text-align: right;
@@ -139,7 +142,7 @@ section.intro-title:last-of-type .section-content {
139
142
  }
140
143
  section.intro {
141
144
  display: flex;
142
- width: 64%;
145
+ width: 60%;
143
146
  flex-direction: column;
144
147
  justify-content: center;
145
148
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t8/docsgen",
3
- "version": "0.3.12",
3
+ "version": "0.3.14",
4
4
  "description": "",
5
5
  "main": "dist/bin.js",
6
6
  "type": "module",
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"}}}
@@ -1,6 +1,6 @@
1
1
  export function getInstallationCode(element: Element) {
2
2
  return element
3
3
  .querySelector("code")
4
- ?.innerHTML.trim()
4
+ ?.textContent.trim()
5
5
  .match(/(\S\s*)?(npm (i|install) .*)/)?.[2];
6
6
  }
@@ -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, 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
- intro.push(outerHTML);
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));
@@ -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/css/index.css CHANGED
@@ -1,3 +1,6 @@
1
+ :root {
2
+ --max-content-width: 38em;
3
+ }
1
4
  body {
2
5
  min-height: 100vh;
3
6
  }
@@ -112,7 +115,7 @@ section .section-content {
112
115
  }
113
116
  section.intro-title {
114
117
  display: flex;
115
- width: 36%;
118
+ width: 40%;
116
119
  flex-direction: column;
117
120
  align-items: flex-end;
118
121
  text-align: right;
@@ -139,7 +142,7 @@ section.intro-title:last-of-type .section-content {
139
142
  }
140
143
  section.intro {
141
144
  display: flex;
142
- width: 64%;
145
+ width: 60%;
143
146
  flex-direction: column;
144
147
  justify-content: center;
145
148
  }
@@ -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;