@t8/docsgen 0.1.12 → 0.1.13
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 +13 -1
- package/dist/css/base.css +20 -0
- package/package.json +36 -36
- package/src/bin/getParsedContent.ts +19 -1
- package/src/css/base.css +20 -0
package/dist/bin.js
CHANGED
|
@@ -413,6 +413,18 @@ function getSectionPostprocess(linkMap) {
|
|
|
413
413
|
return s;
|
|
414
414
|
};
|
|
415
415
|
}
|
|
416
|
+
function postprocessBadges(content) {
|
|
417
|
+
let { document } = new import_jsdom2.JSDOM(content).window;
|
|
418
|
+
for (let img of document.querySelectorAll("img")) {
|
|
419
|
+
let parent = img.parentElement;
|
|
420
|
+
if (!parent) continue;
|
|
421
|
+
let container = document.createElement("span");
|
|
422
|
+
container.className = "badge";
|
|
423
|
+
parent.insertBefore(container, img);
|
|
424
|
+
container.append(img);
|
|
425
|
+
}
|
|
426
|
+
return document.body.innerHTML;
|
|
427
|
+
}
|
|
416
428
|
async function getParsedContent(ctx) {
|
|
417
429
|
let { singlePage } = ctx;
|
|
418
430
|
let rawContent = await fetchText(getLocation(ctx, "README.md", ctx.source));
|
|
@@ -465,7 +477,7 @@ async function getParsedContent(ctx) {
|
|
|
465
477
|
if (section.length !== 0) sections.push(joinLines(section));
|
|
466
478
|
let postprocess = getSectionPostprocess(linkMap);
|
|
467
479
|
return {
|
|
468
|
-
badges: joinLines(badges),
|
|
480
|
+
badges: postprocessBadges(joinLines(badges)),
|
|
469
481
|
title,
|
|
470
482
|
description: joinLines(description),
|
|
471
483
|
features: joinLines(features),
|
package/dist/css/base.css
CHANGED
|
@@ -227,3 +227,23 @@ html.blank .layout {
|
|
|
227
227
|
justify-content: center;
|
|
228
228
|
overflow: hidden;
|
|
229
229
|
}
|
|
230
|
+
|
|
231
|
+
.badges .badge {
|
|
232
|
+
display: inline-flex;
|
|
233
|
+
min-width: 60px;
|
|
234
|
+
min-height: 20px;
|
|
235
|
+
font-size: 11px;
|
|
236
|
+
font-family: Verdana, sans-serif;
|
|
237
|
+
text-align: center;
|
|
238
|
+
white-space: nowrap;
|
|
239
|
+
place-content: center;
|
|
240
|
+
color: #fff;
|
|
241
|
+
background: #345;
|
|
242
|
+
box-sizing: border-box;
|
|
243
|
+
}
|
|
244
|
+
.badges img {
|
|
245
|
+
vertical-align: top;
|
|
246
|
+
}
|
|
247
|
+
.badges a {
|
|
248
|
+
text-decoration: none;
|
|
249
|
+
}
|
package/package.json
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@t8/docsgen",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "dist/bin.js",
|
|
6
|
-
"bin": {
|
|
7
|
-
"docsgen": "dist/bin.js"
|
|
8
|
-
},
|
|
9
|
-
"scripts": {
|
|
10
|
-
"build": "npx npm-run-all clean build-bin -s build-css",
|
|
11
|
-
"build-bin": "npx esbuild ./src/bin/run.ts --bundle --outfile=dist/bin.js --platform=node --external:jsdom --external:markdown-it",
|
|
12
|
-
"build-css": "node -e \"require('node:fs').cpSync('src/css', 'dist/css', { force: true, recursive: true });\"",
|
|
13
|
-
"clean": "node -e \"require('node:fs').rmSync('dist', { force: true, recursive: true });\"",
|
|
14
|
-
"prepublishOnly": "npm run build",
|
|
15
|
-
"preversion": "npx npm-run-all typecheck shape build",
|
|
16
|
-
"shape": "npx codeshape",
|
|
17
|
-
"typecheck": "tsc --noEmit"
|
|
18
|
-
},
|
|
19
|
-
"repository": {
|
|
20
|
-
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/t8js/docsgen.git"
|
|
22
|
-
},
|
|
23
|
-
"license": "ISC",
|
|
24
|
-
"author": "axtk",
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"@types/jsdom": "^27.0.0",
|
|
27
|
-
"@types/markdown-it": "^14.1.2",
|
|
28
|
-
"@types/node": "^24.7.0",
|
|
29
|
-
"typescript": "^5.9.3"
|
|
30
|
-
},
|
|
31
|
-
"dependencies": {
|
|
32
|
-
"args-json": "^1.2.4",
|
|
33
|
-
"jsdom": "^27.0.0",
|
|
34
|
-
"markdown-it": "^14.1.0"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@t8/docsgen",
|
|
3
|
+
"version": "0.1.13",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/bin.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"docsgen": "dist/bin.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "npx npm-run-all clean build-bin -s build-css",
|
|
11
|
+
"build-bin": "npx esbuild ./src/bin/run.ts --bundle --outfile=dist/bin.js --platform=node --external:jsdom --external:markdown-it",
|
|
12
|
+
"build-css": "node -e \"require('node:fs').cpSync('src/css', 'dist/css', { force: true, recursive: true });\"",
|
|
13
|
+
"clean": "node -e \"require('node:fs').rmSync('dist', { force: true, recursive: true });\"",
|
|
14
|
+
"prepublishOnly": "npm run build",
|
|
15
|
+
"preversion": "npx npm-run-all typecheck shape build",
|
|
16
|
+
"shape": "npx codeshape",
|
|
17
|
+
"typecheck": "tsc --noEmit"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/t8js/docsgen.git"
|
|
22
|
+
},
|
|
23
|
+
"license": "ISC",
|
|
24
|
+
"author": "axtk",
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/jsdom": "^27.0.0",
|
|
27
|
+
"@types/markdown-it": "^14.1.2",
|
|
28
|
+
"@types/node": "^24.7.0",
|
|
29
|
+
"typescript": "^5.9.3"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"args-json": "^1.2.4",
|
|
33
|
+
"jsdom": "^27.0.0",
|
|
34
|
+
"markdown-it": "^14.1.0"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -103,6 +103,24 @@ function getSectionPostprocess(linkMap: Record<string, string>) {
|
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
function postprocessBadges(content: string) {
|
|
107
|
+
let { document } = new JSDOM(content).window;
|
|
108
|
+
|
|
109
|
+
for (let img of document.querySelectorAll("img")) {
|
|
110
|
+
let parent = img.parentElement;
|
|
111
|
+
|
|
112
|
+
if (!parent) continue;
|
|
113
|
+
|
|
114
|
+
let container = document.createElement("span");
|
|
115
|
+
container.className = "badge";
|
|
116
|
+
|
|
117
|
+
parent.insertBefore(container, img);
|
|
118
|
+
container.append(img);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return document.body.innerHTML;
|
|
122
|
+
}
|
|
123
|
+
|
|
106
124
|
export async function getParsedContent(ctx: Context) {
|
|
107
125
|
let { singlePage } = ctx;
|
|
108
126
|
let rawContent = await fetchText(getLocation(ctx, "README.md", ctx.source));
|
|
@@ -170,7 +188,7 @@ export async function getParsedContent(ctx: Context) {
|
|
|
170
188
|
let postprocess = getSectionPostprocess(linkMap);
|
|
171
189
|
|
|
172
190
|
return {
|
|
173
|
-
badges: joinLines(badges),
|
|
191
|
+
badges: postprocessBadges(joinLines(badges)),
|
|
174
192
|
title,
|
|
175
193
|
description: joinLines(description),
|
|
176
194
|
features: joinLines(features),
|
package/src/css/base.css
CHANGED
|
@@ -227,3 +227,23 @@ html.blank .layout {
|
|
|
227
227
|
justify-content: center;
|
|
228
228
|
overflow: hidden;
|
|
229
229
|
}
|
|
230
|
+
|
|
231
|
+
.badges .badge {
|
|
232
|
+
display: inline-flex;
|
|
233
|
+
min-width: 60px;
|
|
234
|
+
min-height: 20px;
|
|
235
|
+
font-size: 11px;
|
|
236
|
+
font-family: Verdana, sans-serif;
|
|
237
|
+
text-align: center;
|
|
238
|
+
white-space: nowrap;
|
|
239
|
+
place-content: center;
|
|
240
|
+
color: #fff;
|
|
241
|
+
background: #345;
|
|
242
|
+
box-sizing: border-box;
|
|
243
|
+
}
|
|
244
|
+
.badges img {
|
|
245
|
+
vertical-align: top;
|
|
246
|
+
}
|
|
247
|
+
.badges a {
|
|
248
|
+
text-decoration: none;
|
|
249
|
+
}
|