@t8/docsgen 0.4.2 → 0.4.4

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
@@ -39,6 +39,9 @@ var require_dist = __commonJS({
39
39
  if (x.startsWith("-") && x.length === 2) return toCamelCase(x.slice(1));
40
40
  }
41
41
  }
42
+ function isKey(x) {
43
+ return Boolean(toKey(x));
44
+ }
42
45
  function split(x) {
43
46
  let words = [], word = "";
44
47
  let hasOpenSingleQuote = false;
@@ -74,7 +77,10 @@ var require_dist = __commonJS({
74
77
  let normalizedItem = item.trim();
75
78
  let k = normalizedItem.indexOf("=");
76
79
  if (k === -1) return normalizedItem;
77
- return [normalizedItem.slice(0, k), normalizedItem.slice(k + 1)];
80
+ let key2 = normalizedItem.slice(0, k);
81
+ let value = normalizedItem.slice(k + 1);
82
+ if (!isKey(key2)) return normalizedItem;
83
+ return [key2, value];
78
84
  });
79
85
  if (map) normalizedMap = map;
80
86
  let key = "";
@@ -99,7 +105,7 @@ var require_dist = __commonJS({
99
105
  else parsedValue = true;
100
106
  let prevValue = parsedArgs[key];
101
107
  let value;
102
- if (prevValue === void 0) value = parsedValue;
108
+ if (prevValue === void 0) value = key === "" ? [parsedValue] : parsedValue;
103
109
  else if (Array.isArray(prevValue)) value = [...prevValue, parsedValue];
104
110
  else value = [prevValue, parsedValue];
105
111
  parsedArgs[key] = value;
@@ -818,7 +824,7 @@ function tweakTypography(s = "") {
818
824
  // src/bin/content/getSectionContent.ts
819
825
  async function getSectionContent(ctx, index) {
820
826
  let { root, contentDir = "" } = ctx;
821
- let escapedPackageDescription = escapeHTML(tweakTypography(ctx.description));
827
+ let descriptionContent = escapeHTML(tweakTypography(ctx.description));
822
828
  let cssRoot = await getCSSRoot(ctx, "content");
823
829
  let { sections, nav } = await getParsedContent(ctx);
824
830
  let content = sections[index];
@@ -847,7 +853,7 @@ ${getInjectedContent(ctx, "section", "body", "prepend")}
847
853
  <header class="aux">
848
854
  <h1>${mainTitle}</h1>
849
855
  <div class="description">
850
- <p>${escapedPackageDescription}</p>
856
+ <p>${descriptionContent}</p>
851
857
  </div>
852
858
  </header>
853
859
  <div class="${navContent ? "" : "no-nav "}body">
@@ -868,7 +874,7 @@ ${content}
868
874
  <div class="header" hidden>
869
875
  <h1>${mainTitle}</h1>
870
876
  <div class="description">
871
- <p>${escapedPackageDescription}</p>
877
+ <p>${descriptionContent}</p>
872
878
  <p class="installation">${await getInstallationContent(ctx)}</p>
873
879
  </div>
874
880
  </div>
@@ -11,8 +11,8 @@ footer {
11
11
  header {
12
12
  display: none;
13
13
  text-align: center;
14
- padding-top: 0.5em;
15
- padding-bottom: 0.5em;
14
+ padding-top: 0.7em;
15
+ padding-bottom: 0.75em;
16
16
  }
17
17
  header h1 {
18
18
  font-size: 1.3rem;
@@ -33,8 +33,10 @@ header h1 sup {
33
33
  font-size: 0.5em;
34
34
  }
35
35
  header .description {
36
+ max-width: 36em;
36
37
  font-size: 0.8em;
37
- margin-top: 0.15em;
38
+ line-height: 1.2;
39
+ margin: 0.35em auto 0;
38
40
  }
39
41
  header .description p {
40
42
  margin: 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t8/docsgen",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "",
5
5
  "main": "dist/bin.js",
6
6
  "type": "module",
@@ -26,11 +26,11 @@
26
26
  "devDependencies": {
27
27
  "@types/jsdom": "^27.0.0",
28
28
  "@types/markdown-it": "^14.1.2",
29
- "@types/node": "^25.0.2"
29
+ "@types/node": "^25.2.1"
30
30
  },
31
31
  "dependencies": {
32
- "args-json": "^1.2.9",
33
- "jsdom": "^27.3.0",
32
+ "args-json": "^1.2.12",
33
+ "jsdom": "^28.0.0",
34
34
  "markdown-it": "^14.1.0"
35
35
  }
36
36
  }
@@ -2,6 +2,7 @@ import type { Context } from "../../types/Context.ts";
2
2
  import { escapeHTML } from "../../utils/escapeHTML.ts";
3
3
  import { escapeRegExp } from "../../utils/escapeRegExp.ts";
4
4
  import { getRepoLink } from "../getRepoLink.ts";
5
+ // import { getRepoMetadata } from "../getRepoMetadata.ts";
5
6
  import { getParsedContent } from "../parsing/getParsedContent.ts";
6
7
  import { stripHTML } from "../stripHTML.ts";
7
8
  import { getCounterContent } from "./getCounterContent.ts";
@@ -18,7 +19,9 @@ import { tweakTypography } from "./tweakTypography.ts";
18
19
 
19
20
  export async function getSectionContent(ctx: Context, index: number) {
20
21
  let { root, contentDir = "" } = ctx;
21
- let escapedPackageDescription = escapeHTML(tweakTypography(ctx.description));
22
+ // let repoDescription =
23
+ // index === 0 ? (await getRepoMetadata(ctx)).description : "";
24
+ let descriptionContent = escapeHTML(tweakTypography(ctx.description));
22
25
 
23
26
  let cssRoot = await getCSSRoot(ctx, "content");
24
27
  let { sections, nav } = await getParsedContent(ctx);
@@ -51,7 +54,7 @@ ${getInjectedContent(ctx, "section", "body", "prepend")}
51
54
  <header class="aux">
52
55
  <h1>${mainTitle}</h1>
53
56
  <div class="description">
54
- <p>${escapedPackageDescription}</p>
57
+ <p>${descriptionContent}</p>
55
58
  </div>
56
59
  </header>
57
60
  <div class="${navContent ? "" : "no-nav "}body">
@@ -72,7 +75,7 @@ ${content}
72
75
  <div class="header" hidden>
73
76
  <h1>${mainTitle}</h1>
74
77
  <div class="description">
75
- <p>${escapedPackageDescription}</p>
78
+ <p>${descriptionContent}</p>
76
79
  <p class="installation">${await getInstallationContent(ctx)}</p>
77
80
  </div>
78
81
  </div>
@@ -0,0 +1,19 @@
1
+ import type { Context } from "../types/Context.ts";
2
+ import type { RepoMetadata } from "../types/RepoMetadata.ts";
3
+ import { fetchContent } from "./fetchContent.ts";
4
+
5
+ export async function getRepoMetadata({
6
+ repo,
7
+ }: Context): Promise<RepoMetadata> {
8
+ if (repo?.startsWith("https://github.com/")) {
9
+ try {
10
+ let repoMetadata = await fetchContent(
11
+ repo.replace("https://github.com/", "https://api.github.com/repos/"),
12
+ );
13
+
14
+ return JSON.parse(repoMetadata) as RepoMetadata;
15
+ } catch {}
16
+ }
17
+
18
+ return {};
19
+ }
@@ -11,8 +11,8 @@ footer {
11
11
  header {
12
12
  display: none;
13
13
  text-align: center;
14
- padding-top: 0.5em;
15
- padding-bottom: 0.5em;
14
+ padding-top: 0.7em;
15
+ padding-bottom: 0.75em;
16
16
  }
17
17
  header h1 {
18
18
  font-size: 1.3rem;
@@ -33,8 +33,10 @@ header h1 sup {
33
33
  font-size: 0.5em;
34
34
  }
35
35
  header .description {
36
+ max-width: 36em;
36
37
  font-size: 0.8em;
37
- margin-top: 0.15em;
38
+ line-height: 1.2;
39
+ margin: 0.35em auto 0;
38
40
  }
39
41
  header .description p {
40
42
  margin: 0;
@@ -0,0 +1,3 @@
1
+ export type RepoMetadata = {
2
+ description?: string | undefined;
3
+ };