docgen-tool 5.3.0 → 6.0.2
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/app/app.tsx +18 -0
- package/dist/app/common/markdown/markdown.ts +27 -0
- package/dist/app/favicon.svg +4 -0
- package/dist/app/index.html +13 -0
- package/dist/app/pdf/react-pdf/pdf-page/pdf-footer/pdf-footer.tsx +35 -0
- package/dist/app/pdf/react-pdf/pdf-page/pdf-html-block/custom-renderers/custom-renderers.tsx +45 -0
- package/dist/app/pdf/react-pdf/pdf-page/pdf-html-block/pdf-html-block.tsx +19 -0
- package/dist/app/pdf/react-pdf/pdf-page/pdf-page.tsx +22 -0
- package/dist/app/pdf/react-pdf/pdf-styles/pdf-admonitions-styles.ts +37 -0
- package/dist/app/pdf/react-pdf/pdf-styles/pdf-docs-styles.ts +94 -0
- package/dist/app/pdf/react-pdf/pdf-styles/pdf-styles.ts +154 -0
- package/dist/app/pdf/react-pdf/pdf-styles/pdf-table-styles.ts +21 -0
- package/dist/app/pdf/react-pdf/react-pdf.tsx +107 -0
- package/dist/app/style-variables/css/style-variables.css +80 -0
- package/dist/app/style-variables/js/style-variables.js +78 -0
- package/dist/app/views/assets/styles/fonts/archivo-600-italic.ttf +0 -0
- package/dist/app/views/assets/styles/fonts/archivo-600-italic.woff2 +0 -0
- package/dist/app/views/assets/styles/fonts/archivo-600.ttf +0 -0
- package/dist/app/views/assets/styles/fonts/archivo-600.woff2 +0 -0
- package/dist/app/views/assets/styles/fonts/archivo-italic.ttf +0 -0
- package/dist/app/views/assets/styles/fonts/archivo-italic.woff2 +0 -0
- package/dist/app/views/assets/styles/fonts/archivo-regular.ttf +0 -0
- package/dist/app/views/assets/styles/fonts/archivo-regular.woff2 +0 -0
- package/dist/app/views/assets/styles/fonts/space-grotesk-600.ttf +0 -0
- package/dist/app/views/assets/styles/fonts/space-grotesk-600.woff2 +0 -0
- package/dist/app/views/assets/styles/fonts/space-grotesk-regular.ttf +0 -0
- package/dist/app/views/assets/styles/fonts/space-grotesk-regular.woff2 +0 -0
- package/dist/app/views/assets/styles/fonts/space-mono-700-italic.ttf +0 -0
- package/dist/app/views/assets/styles/fonts/space-mono-700-italic.woff2 +0 -0
- package/dist/app/views/assets/styles/fonts/space-mono-700.ttf +0 -0
- package/dist/app/views/assets/styles/fonts/space-mono-700.woff2 +0 -0
- package/dist/app/views/assets/styles/fonts/space-mono-italic.ttf +0 -0
- package/dist/app/views/assets/styles/fonts/space-mono-italic.woff2 +0 -0
- package/dist/app/views/assets/styles/fonts/space-mono-regular.ttf +0 -0
- package/dist/app/views/assets/styles/fonts/space-mono-regular.woff2 +0 -0
- package/dist/{include/require → app/views/assets}/styles/framework.css +69 -36
- package/dist/app/views/components/copyright/copyright.tsx +16 -0
- package/dist/app/views/components/footer/footer.tsx +37 -0
- package/dist/app/views/components/logo/logo.tsx +13 -0
- package/dist/app/views/components/page/page.tsx +15 -0
- package/dist/app/views/components/pdf-footer/pdf-footer.tsx +29 -0
- package/dist/app/views/components/pdf-header/pdf-header.tsx +12 -0
- package/dist/app/views/components/pdf-toggle-button/pdf-toggle-button.tsx +41 -0
- package/dist/app/views/components/side-bar/side-bar.tsx +89 -0
- package/dist/app/views/components/top-bar/top-bar.tsx +62 -0
- package/dist/app/views/content/markdown.tsx +60 -0
- package/dist/app/views/content/page.tsx +6 -0
- package/dist/app/views/html.tsx +5 -0
- package/dist/app/views/load-pages.ts +27 -0
- package/dist/app/views/pages/cover/cover.css +39 -0
- package/dist/app/views/pages/cover/cover.tsx +99 -0
- package/dist/app/views/pages/main/main.tsx +42 -0
- package/dist/app/views/pages/main/pdf-viewer.tsx +18 -0
- package/dist/app/views/router.tsx +142 -0
- package/dist/cli/cli.js +293 -0
- package/package.json +25 -19
- package/dist/cli.js +0 -1253
- package/dist/include/require/styles/fonts/DroidSansMono.woff +0 -0
- package/dist/include/require/styles/fonts/Montserrat-Italic.woff +0 -0
- package/dist/include/require/styles/fonts/Montserrat-Regular.woff +0 -0
- package/dist/include/require/styles/fonts/Montserrat-SemiBold.woff +0 -0
- package/dist/include/require/styles/fonts/Montserrat-SemiBoldItalic.woff +0 -0
- package/dist/include/require/styles/framework.js +0 -39
- package/dist/include/require/styles/icons.js +0 -9
- package/dist/include/templates/main.html +0 -14
- package/dist/include/templates/redirect.html +0 -10
- /package/dist/{include/require → app/views/assets}/print.css +0 -0
- /package/dist/{include/example → template}/contents.json +0 -0
- /package/dist/{include/example → template}/files/images/logo.svg +0 -0
- /package/dist/{include/example → template}/index.md +0 -0
- /package/dist/{include/example → template}/parameters.json +0 -0
- /package/dist/{include/example → template}/release-notes.md +0 -0
package/dist/cli.js
DELETED
|
@@ -1,1253 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { program } from 'commander';
|
|
3
|
-
import pico from 'picocolors';
|
|
4
|
-
import path, { join } from 'path';
|
|
5
|
-
import { promises } from 'fs';
|
|
6
|
-
import fs from 'fs-extra';
|
|
7
|
-
import schemaValidator from 'z-schema';
|
|
8
|
-
import * as cheerio from 'cheerio';
|
|
9
|
-
import MarkdownIt from 'markdown-it';
|
|
10
|
-
import markdownItAdmon from 'markdown-it-admon';
|
|
11
|
-
import React, { Fragment } from 'react';
|
|
12
|
-
import ReactPDF, { Image, Text, View, StyleSheet, Page as Page$2, Document } from '@react-pdf/renderer';
|
|
13
|
-
import Html from 'react-pdf-html';
|
|
14
|
-
import pkg from 'lodash';
|
|
15
|
-
import ReactDOMServer from 'react-dom/server';
|
|
16
|
-
|
|
17
|
-
const readFile = async (filePath) => {
|
|
18
|
-
const normalized = path.normalize(filePath);
|
|
19
|
-
try {
|
|
20
|
-
return (await promises.readFile(normalized, { encoding: "utf8" }))?.replace(
|
|
21
|
-
/^\uFEFF/,
|
|
22
|
-
""
|
|
23
|
-
);
|
|
24
|
-
} catch (error) {
|
|
25
|
-
console.log(pico.red("Error reading file: " + normalized));
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
const writeFile = async (filePath, data) => {
|
|
29
|
-
const normalized = path.normalize(filePath);
|
|
30
|
-
try {
|
|
31
|
-
await promises.writeFile(normalized, data, { encoding: "utf8" });
|
|
32
|
-
} catch (error) {
|
|
33
|
-
console.log(pico.red("Error writing file: " + normalized));
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
const copyDirectory = async (source, destination, verbose) => {
|
|
37
|
-
const normalizedSource = path.normalize(source);
|
|
38
|
-
const normalizedDestination = path.normalize(destination);
|
|
39
|
-
try {
|
|
40
|
-
await fs.copySync(normalizedSource, normalizedDestination);
|
|
41
|
-
} catch (error) {
|
|
42
|
-
console.log(
|
|
43
|
-
pico.red(
|
|
44
|
-
"Error copying directory: " + normalizedSource + " to " + normalizedDestination
|
|
45
|
-
)
|
|
46
|
-
);
|
|
47
|
-
if (verbose === true) {
|
|
48
|
-
console.log(pico.red(error));
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
const cleanDirectory = async (directoryPath, verbose) => {
|
|
53
|
-
const normalized = path.normalize(directoryPath);
|
|
54
|
-
try {
|
|
55
|
-
await fs.removeSync(normalized);
|
|
56
|
-
await fs.mkdirpSync(normalized);
|
|
57
|
-
} catch (error) {
|
|
58
|
-
console.log(pico.red("Error recreating directory: " + normalized));
|
|
59
|
-
if (verbose === true) {
|
|
60
|
-
console.log(pico.red(error));
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const schemas = {
|
|
66
|
-
parameters: {
|
|
67
|
-
title: "DocGen Parameters Schema",
|
|
68
|
-
type: "object",
|
|
69
|
-
required: [
|
|
70
|
-
"title",
|
|
71
|
-
"name",
|
|
72
|
-
"version",
|
|
73
|
-
"date",
|
|
74
|
-
"organization",
|
|
75
|
-
"author",
|
|
76
|
-
"owner",
|
|
77
|
-
"contributors",
|
|
78
|
-
"website",
|
|
79
|
-
"module",
|
|
80
|
-
"id",
|
|
81
|
-
"summary",
|
|
82
|
-
"marking",
|
|
83
|
-
"legalese"
|
|
84
|
-
],
|
|
85
|
-
properties: {
|
|
86
|
-
title: { type: "string" },
|
|
87
|
-
name: { type: "string" },
|
|
88
|
-
version: { type: "string" },
|
|
89
|
-
date: { type: "string" },
|
|
90
|
-
organization: {
|
|
91
|
-
type: "object",
|
|
92
|
-
required: ["name", "url"],
|
|
93
|
-
properties: {
|
|
94
|
-
name: { type: "string" },
|
|
95
|
-
url: { type: "string" }
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
author: {
|
|
99
|
-
type: "object",
|
|
100
|
-
required: ["name", "url"],
|
|
101
|
-
properties: {
|
|
102
|
-
name: { type: "string" },
|
|
103
|
-
url: { type: "string" }
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
owner: {
|
|
107
|
-
type: "object",
|
|
108
|
-
required: ["name", "url"],
|
|
109
|
-
properties: {
|
|
110
|
-
name: { type: "string" },
|
|
111
|
-
url: { type: "string" }
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
contributors: {
|
|
115
|
-
type: "array",
|
|
116
|
-
items: {
|
|
117
|
-
oneOf: [
|
|
118
|
-
{
|
|
119
|
-
type: "object",
|
|
120
|
-
required: ["name", "url"],
|
|
121
|
-
properties: {
|
|
122
|
-
name: { type: "string" },
|
|
123
|
-
url: { type: "string" }
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
]
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
website: {
|
|
130
|
-
type: "object",
|
|
131
|
-
required: ["name", "url"],
|
|
132
|
-
properties: {
|
|
133
|
-
name: { type: "string" },
|
|
134
|
-
url: { type: "string" }
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
sponsorLink: {
|
|
138
|
-
type: "object",
|
|
139
|
-
required: ["name", "url", "logo"],
|
|
140
|
-
properties: {
|
|
141
|
-
name: { type: "string" },
|
|
142
|
-
url: { type: "string" },
|
|
143
|
-
logo: { type: "string" }
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
backlink: {
|
|
147
|
-
type: "object",
|
|
148
|
-
required: ["name", "url"],
|
|
149
|
-
properties: {
|
|
150
|
-
name: { type: "string" },
|
|
151
|
-
url: { type: "string" }
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
module: { type: "string" },
|
|
155
|
-
id: { type: "string" },
|
|
156
|
-
summary: { type: "string" },
|
|
157
|
-
marking: { type: "string" },
|
|
158
|
-
legalese: { type: "string" },
|
|
159
|
-
logoPath: { type: "string" }
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
contents: {
|
|
163
|
-
title: "DocGen Table of Contents Schema",
|
|
164
|
-
type: "array",
|
|
165
|
-
items: {
|
|
166
|
-
oneOf: [
|
|
167
|
-
{
|
|
168
|
-
type: "object",
|
|
169
|
-
required: ["heading", "column", "pages"],
|
|
170
|
-
properties: {
|
|
171
|
-
name: { type: "string" },
|
|
172
|
-
column: { type: "integer", minimum: 1, maximum: 4 },
|
|
173
|
-
pages: {
|
|
174
|
-
type: "array",
|
|
175
|
-
items: {
|
|
176
|
-
oneOf: [
|
|
177
|
-
{
|
|
178
|
-
type: "object",
|
|
179
|
-
required: ["title", "source"],
|
|
180
|
-
properties: {
|
|
181
|
-
title: { type: "string" },
|
|
182
|
-
source: { type: "string" },
|
|
183
|
-
hideAutomaticPageHeading: { type: "boolean" }
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
]
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
]
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
const validateJSON = ({ key, data, verbose }) => {
|
|
196
|
-
let schema = schemas[key];
|
|
197
|
-
let validator = new schemaValidator({});
|
|
198
|
-
let valid = validator.validate(data, schema);
|
|
199
|
-
if (!valid) {
|
|
200
|
-
console.log(
|
|
201
|
-
pico.red(
|
|
202
|
-
`Error parsing required file: ${key}.json (failed schema validation)`
|
|
203
|
-
)
|
|
204
|
-
);
|
|
205
|
-
if (verbose === true) {
|
|
206
|
-
console.log(pico.red(validator.getLastError().message));
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
return valid;
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
const loadMeta = async ({
|
|
213
|
-
inputPath,
|
|
214
|
-
verbose,
|
|
215
|
-
mainProcess
|
|
216
|
-
}) => {
|
|
217
|
-
const meta = {
|
|
218
|
-
parameters: null,
|
|
219
|
-
contents: null
|
|
220
|
-
};
|
|
221
|
-
console.log(pico.green("Loading required JSON metadata files"));
|
|
222
|
-
try {
|
|
223
|
-
let files = {
|
|
224
|
-
parameters: await readFile(inputPath + "/parameters.json"),
|
|
225
|
-
contents: await readFile(inputPath + "/contents.json")
|
|
226
|
-
};
|
|
227
|
-
for (let key in files) {
|
|
228
|
-
if (files.hasOwnProperty(key)) {
|
|
229
|
-
try {
|
|
230
|
-
let file = JSON.parse(files[key]);
|
|
231
|
-
if (validateJSON({ key, data: file, verbose })) {
|
|
232
|
-
meta[key] = file;
|
|
233
|
-
} else {
|
|
234
|
-
mainProcess.exit(1);
|
|
235
|
-
}
|
|
236
|
-
} catch (error) {
|
|
237
|
-
console.log(
|
|
238
|
-
pico.red(
|
|
239
|
-
"Error parsing required file: " + key + ".json (invalid JSON)"
|
|
240
|
-
)
|
|
241
|
-
);
|
|
242
|
-
if (verbose === true) {
|
|
243
|
-
console.log(pico.red(error));
|
|
244
|
-
}
|
|
245
|
-
mainProcess.exit(1);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
const extra = {
|
|
250
|
-
heading: "Extra",
|
|
251
|
-
column: 5,
|
|
252
|
-
pages: [{ title: "Release notes", source: "release-notes.md" }]
|
|
253
|
-
};
|
|
254
|
-
meta.contents.push(extra);
|
|
255
|
-
return {
|
|
256
|
-
rawParameters: meta.parameters,
|
|
257
|
-
contents: meta.contents
|
|
258
|
-
};
|
|
259
|
-
} catch (error) {
|
|
260
|
-
console.log(pico.red("Error loading required JSON metadata files"));
|
|
261
|
-
if (verbose === true) {
|
|
262
|
-
console.log(pico.red(error));
|
|
263
|
-
}
|
|
264
|
-
mainProcess.exit(1);
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
const packageAbsolutePath = import.meta.dirname;
|
|
269
|
-
|
|
270
|
-
const loadTemplates = async ({
|
|
271
|
-
options,
|
|
272
|
-
mainProcess
|
|
273
|
-
}) => {
|
|
274
|
-
const templates = {};
|
|
275
|
-
console.log(pico.green("Loading templates"));
|
|
276
|
-
try {
|
|
277
|
-
let files = {
|
|
278
|
-
main: await readFile(
|
|
279
|
-
join(packageAbsolutePath, "include/templates/main.html")
|
|
280
|
-
),
|
|
281
|
-
redirect: await readFile(
|
|
282
|
-
join(packageAbsolutePath, "include/templates/redirect.html")
|
|
283
|
-
)
|
|
284
|
-
};
|
|
285
|
-
for (let key in files) {
|
|
286
|
-
if (files.hasOwnProperty(key)) {
|
|
287
|
-
let file = files[key];
|
|
288
|
-
let dom = cheerio.load(file);
|
|
289
|
-
templates[key] = dom;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
return templates;
|
|
293
|
-
} catch (error) {
|
|
294
|
-
console.log(pico.red("Error loading templates"));
|
|
295
|
-
if (options.verbose === true) {
|
|
296
|
-
console.log(pico.red(error));
|
|
297
|
-
}
|
|
298
|
-
mainProcess.exit(1);
|
|
299
|
-
}
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
const markdown = new MarkdownIt("commonmark").enable("table").use(markdownItAdmon);
|
|
303
|
-
markdown.validateLink = () => {
|
|
304
|
-
return true;
|
|
305
|
-
};
|
|
306
|
-
const loadMarkdown = async ({ contents, options, mainProcess }) => {
|
|
307
|
-
console.log(pico.green("Loading src files"));
|
|
308
|
-
const pages = {};
|
|
309
|
-
try {
|
|
310
|
-
let keys = [];
|
|
311
|
-
let files = [];
|
|
312
|
-
contents.forEach((section) => {
|
|
313
|
-
section.pages.forEach((page) => {
|
|
314
|
-
keys.push(page);
|
|
315
|
-
files.push(options.input + "/" + page.source);
|
|
316
|
-
});
|
|
317
|
-
});
|
|
318
|
-
keys.push("ownership");
|
|
319
|
-
files.push(options.input + "/release-notes.md");
|
|
320
|
-
files = await Promise.all(files.map((f) => readFile(f)));
|
|
321
|
-
files.forEach((page, index) => {
|
|
322
|
-
let key = keys[index];
|
|
323
|
-
try {
|
|
324
|
-
let html = markdown.render(page);
|
|
325
|
-
pages[key.source] = html;
|
|
326
|
-
} catch (error) {
|
|
327
|
-
console.log(pico.red("Error parsing Markdown file: " + key.source));
|
|
328
|
-
if (options.verbose === true) {
|
|
329
|
-
console.log(pico.red(error));
|
|
330
|
-
}
|
|
331
|
-
mainProcess.exit(1);
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
return pages;
|
|
335
|
-
} catch (error) {
|
|
336
|
-
console.log(error);
|
|
337
|
-
console.log(pico.red("Error loading src files"));
|
|
338
|
-
if (options.verbose === true) {
|
|
339
|
-
console.log(pico.red(error));
|
|
340
|
-
}
|
|
341
|
-
mainProcess.exit(1);
|
|
342
|
-
}
|
|
343
|
-
};
|
|
344
|
-
|
|
345
|
-
const ColorBackgroundSuccess = "#e8f5e9";
|
|
346
|
-
const ColorBackgroundError = "#ffebee";
|
|
347
|
-
const ColorBackgroundWarning = "#fff8e1";
|
|
348
|
-
const ColorBackgroundInfo = "rgb(222, 232, 252)";
|
|
349
|
-
const ColorBackgroundNeutral = "#f5f5f5";
|
|
350
|
-
const ColorBorder = "#999";
|
|
351
|
-
const ColorBorderSuccess = "#4caf50";
|
|
352
|
-
const ColorBorderError = "#f44336";
|
|
353
|
-
const ColorBorderWarning = "#ff9800";
|
|
354
|
-
const ColorBorderInfo = "#81a7f4";
|
|
355
|
-
const ColorBorderNeutral = "#9e9e9e";
|
|
356
|
-
const ColorText = "rgb(1, 3, 4)";
|
|
357
|
-
const ColorTableBackgroundHeaderFooterPdf = "#eee";
|
|
358
|
-
const SizeBorderWidthPdf = "0.8pt";
|
|
359
|
-
const SizeFontH1Pdf = "24pt";
|
|
360
|
-
const SizeFontH2Pdf = "20pt";
|
|
361
|
-
const SizeFontH3Pdf = "18pt";
|
|
362
|
-
const SizeFontH4Pdf = "16pt";
|
|
363
|
-
const SizeFontH5Pdf = "14pt";
|
|
364
|
-
const SizeFontH6Pdf = "12pt";
|
|
365
|
-
const SizeTableCellPaddingPdf = "2mm 2mm";
|
|
366
|
-
const SizeContentBlockMarginPdf = "2mm 0";
|
|
367
|
-
const SizeContentBlockPaddingPdf = "1mm 4mm";
|
|
368
|
-
const SizeAdmonitionBorderLeftPdf = "1mm";
|
|
369
|
-
const SizeAdmonitionTitleMarginPdf = "3mm 0 0";
|
|
370
|
-
|
|
371
|
-
const docsStyleSheet = {
|
|
372
|
-
// Features cards
|
|
373
|
-
[".features"]: {
|
|
374
|
-
padding: 0,
|
|
375
|
-
width: "100%",
|
|
376
|
-
display: "flex",
|
|
377
|
-
flexDirection: "row",
|
|
378
|
-
flexWrap: "wrap",
|
|
379
|
-
justifyContent: "flex-start",
|
|
380
|
-
gap: 20,
|
|
381
|
-
margin: "0 0 0.5cm"
|
|
382
|
-
},
|
|
383
|
-
[".features li"]: {
|
|
384
|
-
listStyleType: "none",
|
|
385
|
-
verticalAlign: "top",
|
|
386
|
-
display: "flex",
|
|
387
|
-
flexDirection: "column",
|
|
388
|
-
alignItems: "flex-start",
|
|
389
|
-
width: "5cm",
|
|
390
|
-
margin: "0.5cm 0.5cm 0 0"
|
|
391
|
-
},
|
|
392
|
-
[".features li p"]: {
|
|
393
|
-
margin: 0,
|
|
394
|
-
padding: "0 0 0.4cm 0",
|
|
395
|
-
textAlign: "left"
|
|
396
|
-
},
|
|
397
|
-
[".features li img"]: {
|
|
398
|
-
alignSelf: "flex-start",
|
|
399
|
-
height: "1cm",
|
|
400
|
-
objectFit: "contain",
|
|
401
|
-
// preserve aspect ratio
|
|
402
|
-
marginBottom: "0.4cm"
|
|
403
|
-
},
|
|
404
|
-
// Feature details container
|
|
405
|
-
[".featureDetailsContainer"]: {
|
|
406
|
-
display: "flex",
|
|
407
|
-
flexDirection: "row",
|
|
408
|
-
justifyContent: "flex-start",
|
|
409
|
-
alignItems: "flex-start",
|
|
410
|
-
gap: "0.5cm",
|
|
411
|
-
padding: "0.5cm 0"
|
|
412
|
-
},
|
|
413
|
-
[".featureDetails"]: {
|
|
414
|
-
display: "flex",
|
|
415
|
-
flexDirection: "column",
|
|
416
|
-
width: "7cm"
|
|
417
|
-
},
|
|
418
|
-
// How it works cards
|
|
419
|
-
[".dgCardContainer"]: {
|
|
420
|
-
display: "flex",
|
|
421
|
-
flexDirection: "row",
|
|
422
|
-
flexWrap: "wrap",
|
|
423
|
-
justifyContent: "flex-start",
|
|
424
|
-
gap: "0.5cm"
|
|
425
|
-
},
|
|
426
|
-
[".dgCard"]: {
|
|
427
|
-
display: "flex",
|
|
428
|
-
flexDirection: "column",
|
|
429
|
-
alignItems: "center",
|
|
430
|
-
textAlign: "left",
|
|
431
|
-
maxWidth: "5.5cm"
|
|
432
|
-
},
|
|
433
|
-
[".dgCard img"]: {
|
|
434
|
-
width: "5.5cm",
|
|
435
|
-
height: "auto",
|
|
436
|
-
borderRadius: "0.1cm"
|
|
437
|
-
},
|
|
438
|
-
[".dgCard p"]: {
|
|
439
|
-
marginTop: "0.5cm",
|
|
440
|
-
wordWrap: "break-word"
|
|
441
|
-
},
|
|
442
|
-
// Sponsor cards
|
|
443
|
-
[".inkitSponsor"]: {
|
|
444
|
-
display: "flex",
|
|
445
|
-
flexDirection: "row",
|
|
446
|
-
padding: "10 0"
|
|
447
|
-
},
|
|
448
|
-
[".inkitText"]: {
|
|
449
|
-
flex: 1,
|
|
450
|
-
justifyContent: "left"
|
|
451
|
-
},
|
|
452
|
-
[".inkitImage"]: {
|
|
453
|
-
flex: 1,
|
|
454
|
-
alignItems: "left"
|
|
455
|
-
},
|
|
456
|
-
[".inkitImage img"]: {
|
|
457
|
-
width: 200,
|
|
458
|
-
borderRadius: 8
|
|
459
|
-
}
|
|
460
|
-
};
|
|
461
|
-
|
|
462
|
-
const admonitionBaseStyle = {
|
|
463
|
-
padding: SizeContentBlockPaddingPdf,
|
|
464
|
-
margin: SizeContentBlockMarginPdf
|
|
465
|
-
};
|
|
466
|
-
const pdfAdmonitionsStyles = {
|
|
467
|
-
blockquote: {
|
|
468
|
-
...admonitionBaseStyle,
|
|
469
|
-
backgroundColor: ColorBackgroundNeutral,
|
|
470
|
-
borderLeft: `${SizeAdmonitionBorderLeftPdf} solid ${ColorBorderNeutral}`,
|
|
471
|
-
color: ColorBorderNeutral,
|
|
472
|
-
fontStyle: "italic"
|
|
473
|
-
},
|
|
474
|
-
[".admonition"]: admonitionBaseStyle,
|
|
475
|
-
[".admonition-title"]: {
|
|
476
|
-
margin: SizeAdmonitionTitleMarginPdf,
|
|
477
|
-
fontWeight: "bold"
|
|
478
|
-
},
|
|
479
|
-
[".admonition.information"]: {
|
|
480
|
-
backgroundColor: ColorBackgroundInfo,
|
|
481
|
-
borderLeft: `${SizeAdmonitionBorderLeftPdf} solid ${ColorBorderInfo}`
|
|
482
|
-
},
|
|
483
|
-
[".admonition.success"]: {
|
|
484
|
-
backgroundColor: ColorBackgroundSuccess,
|
|
485
|
-
borderLeft: `${SizeAdmonitionBorderLeftPdf} solid ${ColorBorderSuccess}`
|
|
486
|
-
},
|
|
487
|
-
[".admonition.warning"]: {
|
|
488
|
-
backgroundColor: ColorBackgroundWarning,
|
|
489
|
-
borderLeft: `${SizeAdmonitionBorderLeftPdf} solid ${ColorBorderWarning}`
|
|
490
|
-
},
|
|
491
|
-
[".admonition.error"]: {
|
|
492
|
-
backgroundColor: ColorBackgroundError,
|
|
493
|
-
borderLeft: `${SizeAdmonitionBorderLeftPdf} solid ${ColorBorderError}`
|
|
494
|
-
}
|
|
495
|
-
};
|
|
496
|
-
|
|
497
|
-
const tableCellStyle = {
|
|
498
|
-
padding: SizeTableCellPaddingPdf,
|
|
499
|
-
border: `${SizeBorderWidthPdf} solid ${ColorBorder}`
|
|
500
|
-
};
|
|
501
|
-
const tableHeaderFooterStyle = {
|
|
502
|
-
...tableCellStyle,
|
|
503
|
-
backgroundColor: ColorTableBackgroundHeaderFooterPdf,
|
|
504
|
-
fontWeight: "bold"
|
|
505
|
-
};
|
|
506
|
-
const pdfTableStyles = {
|
|
507
|
-
table: {
|
|
508
|
-
border: "1px solid #ccc"
|
|
509
|
-
},
|
|
510
|
-
td: tableCellStyle,
|
|
511
|
-
th: tableHeaderFooterStyle,
|
|
512
|
-
["tfoot td"]: tableHeaderFooterStyle
|
|
513
|
-
};
|
|
514
|
-
|
|
515
|
-
const fontSize = 10;
|
|
516
|
-
const pdfStyleSheet = {
|
|
517
|
-
page: {
|
|
518
|
-
paddingTop: 35,
|
|
519
|
-
paddingBottom: 65,
|
|
520
|
-
paddingHorizontal: 35,
|
|
521
|
-
fontSize
|
|
522
|
-
}
|
|
523
|
-
};
|
|
524
|
-
const em = (em2, relativeSize = fontSize) => em2 * relativeSize;
|
|
525
|
-
const htmlStyleSheet = {
|
|
526
|
-
"h1, h2, h3, h4, h5, h6": {
|
|
527
|
-
fontWeight: "bold"
|
|
528
|
-
},
|
|
529
|
-
h1: {
|
|
530
|
-
fontSize: SizeFontH1Pdf,
|
|
531
|
-
marginVertical: em(0.67, em(2))
|
|
532
|
-
},
|
|
533
|
-
h2: {
|
|
534
|
-
fontSize: SizeFontH2Pdf,
|
|
535
|
-
marginVertical: em(0.83, em(1.5))
|
|
536
|
-
},
|
|
537
|
-
h3: {
|
|
538
|
-
fontSize: SizeFontH3Pdf,
|
|
539
|
-
marginVertical: em(1, em(1.17))
|
|
540
|
-
},
|
|
541
|
-
h4: {
|
|
542
|
-
fontSize: SizeFontH4Pdf,
|
|
543
|
-
marginVertical: em(1.33, em(1))
|
|
544
|
-
},
|
|
545
|
-
h5: {
|
|
546
|
-
fontSize: SizeFontH5Pdf,
|
|
547
|
-
marginVertical: em(1.67, em(0.83))
|
|
548
|
-
},
|
|
549
|
-
h6: {
|
|
550
|
-
fontSize: SizeFontH6Pdf,
|
|
551
|
-
marginVertical: em(2.33, em(0.67))
|
|
552
|
-
},
|
|
553
|
-
p: {
|
|
554
|
-
color: ColorText,
|
|
555
|
-
fontSize: em(1),
|
|
556
|
-
marginVertical: em(1)
|
|
557
|
-
},
|
|
558
|
-
hr: {
|
|
559
|
-
marginVertical: em(0.5),
|
|
560
|
-
borderBottomWidth: 1,
|
|
561
|
-
borderBottomColor: "#000"
|
|
562
|
-
},
|
|
563
|
-
address: {
|
|
564
|
-
fontStyle: "italic"
|
|
565
|
-
},
|
|
566
|
-
pre: {
|
|
567
|
-
fontSize: "10pt",
|
|
568
|
-
fontFamily: "Courier",
|
|
569
|
-
backgroundColor: "#f5f5f5",
|
|
570
|
-
color: "#333333",
|
|
571
|
-
borderRadius: "4pt",
|
|
572
|
-
padding: "8pt",
|
|
573
|
-
borderLeft: "4pt solid #cccccc",
|
|
574
|
-
marginVertical: em(1),
|
|
575
|
-
whiteSpace: "pre-wrap"
|
|
576
|
-
},
|
|
577
|
-
b: {
|
|
578
|
-
fontWeight: "bold"
|
|
579
|
-
},
|
|
580
|
-
strong: {
|
|
581
|
-
fontWeight: "bold"
|
|
582
|
-
},
|
|
583
|
-
i: {
|
|
584
|
-
fontStyle: "italic"
|
|
585
|
-
},
|
|
586
|
-
em: {
|
|
587
|
-
fontStyle: "italic"
|
|
588
|
-
},
|
|
589
|
-
s: {
|
|
590
|
-
textDecoration: "line-through"
|
|
591
|
-
},
|
|
592
|
-
u: {
|
|
593
|
-
textDecoration: "underline"
|
|
594
|
-
},
|
|
595
|
-
cite: {
|
|
596
|
-
fontStyle: "italic"
|
|
597
|
-
},
|
|
598
|
-
code: {
|
|
599
|
-
// fontFamily: 'monospace',
|
|
600
|
-
},
|
|
601
|
-
a: {
|
|
602
|
-
textDecoration: "underline"
|
|
603
|
-
},
|
|
604
|
-
ul: {
|
|
605
|
-
marginVertical: em(1)
|
|
606
|
-
},
|
|
607
|
-
ol: {
|
|
608
|
-
marginVertical: em(1)
|
|
609
|
-
},
|
|
610
|
-
li: {
|
|
611
|
-
display: "flex",
|
|
612
|
-
flexDirection: "row"
|
|
613
|
-
},
|
|
614
|
-
li_bullet: {
|
|
615
|
-
width: 30,
|
|
616
|
-
textAlign: "right",
|
|
617
|
-
flexShrink: 0,
|
|
618
|
-
flexGrow: 0,
|
|
619
|
-
paddingRight: 5
|
|
620
|
-
},
|
|
621
|
-
li_content: {
|
|
622
|
-
textAlign: "left",
|
|
623
|
-
flexGrow: 1,
|
|
624
|
-
flexBasis: 1
|
|
625
|
-
},
|
|
626
|
-
table: {
|
|
627
|
-
display: "flex",
|
|
628
|
-
flexDirection: "column",
|
|
629
|
-
flexShrink: 1,
|
|
630
|
-
borderCollapse: "collapse"
|
|
631
|
-
},
|
|
632
|
-
thead: {
|
|
633
|
-
display: "flex",
|
|
634
|
-
flexDirection: "column"
|
|
635
|
-
},
|
|
636
|
-
tbody: {
|
|
637
|
-
display: "flex",
|
|
638
|
-
flexDirection: "column"
|
|
639
|
-
},
|
|
640
|
-
tr: {
|
|
641
|
-
display: "flex",
|
|
642
|
-
flexDirection: "row",
|
|
643
|
-
flexShrink: 1
|
|
644
|
-
},
|
|
645
|
-
td: {
|
|
646
|
-
flexGrow: 1,
|
|
647
|
-
flexShrink: 1
|
|
648
|
-
},
|
|
649
|
-
th: {
|
|
650
|
-
flexGrow: 1,
|
|
651
|
-
flexShrink: 1,
|
|
652
|
-
fontWeight: "bold"
|
|
653
|
-
},
|
|
654
|
-
[".button"]: {
|
|
655
|
-
textAlign: "center"
|
|
656
|
-
},
|
|
657
|
-
...pdfAdmonitionsStyles,
|
|
658
|
-
...pdfTableStyles,
|
|
659
|
-
...docsStyleSheet
|
|
660
|
-
};
|
|
661
|
-
|
|
662
|
-
const customRenderers = ({ options }) => ({
|
|
663
|
-
div: (payload) => {
|
|
664
|
-
const { children, style, element } = payload;
|
|
665
|
-
const classNames = element.classList.toString();
|
|
666
|
-
if (classNames.includes("dgPDFPageBreak")) {
|
|
667
|
-
return /* @__PURE__ */ React.createElement(View, { break: true, style }, children);
|
|
668
|
-
}
|
|
669
|
-
return /* @__PURE__ */ React.createElement(View, { style }, children);
|
|
670
|
-
},
|
|
671
|
-
pre: (payload) => {
|
|
672
|
-
const { children, element, style } = payload;
|
|
673
|
-
const $ = cheerio.load(element.content.join());
|
|
674
|
-
const code = $("code");
|
|
675
|
-
if (code.length) {
|
|
676
|
-
return /* @__PURE__ */ React.createElement(Text, { style }, code.text().trim());
|
|
677
|
-
}
|
|
678
|
-
return /* @__PURE__ */ React.createElement(Text, { style }, children);
|
|
679
|
-
},
|
|
680
|
-
img: (payload) => {
|
|
681
|
-
const { element, style } = payload;
|
|
682
|
-
const relativeSource = element.attributes.src;
|
|
683
|
-
const source = path.join(options.input, relativeSource);
|
|
684
|
-
return /* @__PURE__ */ React.createElement(Image, { style, source });
|
|
685
|
-
}
|
|
686
|
-
});
|
|
687
|
-
|
|
688
|
-
const PdfHtmlBlock = ({
|
|
689
|
-
page,
|
|
690
|
-
options
|
|
691
|
-
}) => {
|
|
692
|
-
return /* @__PURE__ */ React.createElement(
|
|
693
|
-
Html,
|
|
694
|
-
{
|
|
695
|
-
style: { fontSize },
|
|
696
|
-
stylesheet: htmlStyleSheet,
|
|
697
|
-
renderers: customRenderers({ options })
|
|
698
|
-
},
|
|
699
|
-
page
|
|
700
|
-
);
|
|
701
|
-
};
|
|
702
|
-
|
|
703
|
-
const styles = StyleSheet.create({
|
|
704
|
-
footer: {
|
|
705
|
-
position: "absolute",
|
|
706
|
-
bottom: 5,
|
|
707
|
-
left: 30,
|
|
708
|
-
right: 30,
|
|
709
|
-
height: 50,
|
|
710
|
-
flexDirection: "row",
|
|
711
|
-
justifyContent: "space-between",
|
|
712
|
-
borderTopWidth: 1,
|
|
713
|
-
borderTopColor: "black",
|
|
714
|
-
paddingTop: 10
|
|
715
|
-
},
|
|
716
|
-
column: {
|
|
717
|
-
width: "33%",
|
|
718
|
-
textAlign: "center",
|
|
719
|
-
fontSize: 10
|
|
720
|
-
}
|
|
721
|
-
});
|
|
722
|
-
const PdfFooter = ({ parameters }) => /* @__PURE__ */ React.createElement(View, { style: styles.footer, fixed: true }, /* @__PURE__ */ React.createElement(Text, { style: styles.column }, parameters.title), /* @__PURE__ */ React.createElement(Text, { style: styles.column }, `\xA9 ${parameters.year} ${parameters.name}`), /* @__PURE__ */ React.createElement(
|
|
723
|
-
Text,
|
|
724
|
-
{
|
|
725
|
-
style: styles.column,
|
|
726
|
-
render: ({ pageNumber, totalPages }) => `${pageNumber} / ${totalPages}`
|
|
727
|
-
}
|
|
728
|
-
));
|
|
729
|
-
|
|
730
|
-
const reactPdfStyles = StyleSheet.create(pdfStyleSheet);
|
|
731
|
-
const PdfPage = ({
|
|
732
|
-
page,
|
|
733
|
-
parameters,
|
|
734
|
-
options
|
|
735
|
-
}) => {
|
|
736
|
-
return /* @__PURE__ */ React.createElement(Page$2, { size: "A4", style: reactPdfStyles.page }, /* @__PURE__ */ React.createElement(View, null, /* @__PURE__ */ React.createElement(PdfHtmlBlock, { page, options })), /* @__PURE__ */ React.createElement(PdfFooter, { parameters }));
|
|
737
|
-
};
|
|
738
|
-
|
|
739
|
-
const Pdf = ({
|
|
740
|
-
parameters,
|
|
741
|
-
options,
|
|
742
|
-
pages,
|
|
743
|
-
sortedPages
|
|
744
|
-
}) => {
|
|
745
|
-
for (let key in sortedPages) {
|
|
746
|
-
if (sortedPages.hasOwnProperty(key)) {
|
|
747
|
-
sortedPages[key].forEach((section) => {
|
|
748
|
-
section.pages.forEach((page) => {
|
|
749
|
-
page.source;
|
|
750
|
-
});
|
|
751
|
-
});
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
return /* @__PURE__ */ React.createElement(Document, null, Object.values(pages).map((page, i) => /* @__PURE__ */ React.createElement(
|
|
755
|
-
PdfPage,
|
|
756
|
-
{
|
|
757
|
-
key: i,
|
|
758
|
-
page,
|
|
759
|
-
parameters,
|
|
760
|
-
options
|
|
761
|
-
}
|
|
762
|
-
)));
|
|
763
|
-
};
|
|
764
|
-
|
|
765
|
-
const generatePdf = ({
|
|
766
|
-
pages,
|
|
767
|
-
options,
|
|
768
|
-
parameters,
|
|
769
|
-
sortedPages,
|
|
770
|
-
mainProcess
|
|
771
|
-
}) => {
|
|
772
|
-
const excludedPages = ["release-notes.md", void 0];
|
|
773
|
-
const filteredPages = Object.fromEntries(
|
|
774
|
-
Object.entries(pages).filter(([key]) => key !== "undefined" && !excludedPages.includes(key))
|
|
775
|
-
);
|
|
776
|
-
const pdfName = parameters.name.toLowerCase() + ".pdf";
|
|
777
|
-
const pdfPath = path.normalize(`${options.output}/${pdfName}`);
|
|
778
|
-
console.log(pico.green("Generating the PDF"));
|
|
779
|
-
ReactPDF.render(
|
|
780
|
-
/* @__PURE__ */ React.createElement(
|
|
781
|
-
Pdf,
|
|
782
|
-
{
|
|
783
|
-
options,
|
|
784
|
-
pages: filteredPages,
|
|
785
|
-
sortedPages,
|
|
786
|
-
parameters
|
|
787
|
-
}
|
|
788
|
-
),
|
|
789
|
-
pdfPath
|
|
790
|
-
);
|
|
791
|
-
};
|
|
792
|
-
|
|
793
|
-
const scaffold$1 = async ({ outputDirectory, verbose }) => {
|
|
794
|
-
console.log(pico.green("Creating scaffold template directory"));
|
|
795
|
-
await copyDirectory(
|
|
796
|
-
join(packageAbsolutePath, "include/example"),
|
|
797
|
-
outputDirectory,
|
|
798
|
-
verbose
|
|
799
|
-
);
|
|
800
|
-
};
|
|
801
|
-
|
|
802
|
-
const sortPages = ({ contents }) => {
|
|
803
|
-
return contents.reduce(
|
|
804
|
-
(acc, section) => {
|
|
805
|
-
const { column } = section;
|
|
806
|
-
return {
|
|
807
|
-
...acc,
|
|
808
|
-
[column]: [...acc[column] || [], section]
|
|
809
|
-
};
|
|
810
|
-
},
|
|
811
|
-
{ 1: [], 2: [], 3: [], 4: [], 5: [] }
|
|
812
|
-
);
|
|
813
|
-
};
|
|
814
|
-
|
|
815
|
-
const deriveParameters = ({
|
|
816
|
-
rawParameters,
|
|
817
|
-
setVersion,
|
|
818
|
-
setReleaseDate,
|
|
819
|
-
homeLink
|
|
820
|
-
}) => {
|
|
821
|
-
const version = setVersion || rawParameters.version;
|
|
822
|
-
const releaseDate = setReleaseDate || rawParameters.date;
|
|
823
|
-
const homePagePath = `${homeLink.source.slice(
|
|
824
|
-
0,
|
|
825
|
-
homeLink.source.lastIndexOf(".")
|
|
826
|
-
)}.html`;
|
|
827
|
-
const currentDate = /* @__PURE__ */ new Date();
|
|
828
|
-
const date = currentDate.toLocaleDateString("en-GB");
|
|
829
|
-
const time = currentDate.toLocaleTimeString("en-US", { hour12: false });
|
|
830
|
-
const year = currentDate.getFullYear().toString();
|
|
831
|
-
const attribution = `Created by DocGen ${version} on ${date} at ${time}.`;
|
|
832
|
-
const webFooter = `Version ${version} released on ${releaseDate}`;
|
|
833
|
-
return {
|
|
834
|
-
...rawParameters,
|
|
835
|
-
attribution,
|
|
836
|
-
year,
|
|
837
|
-
webFooter,
|
|
838
|
-
version,
|
|
839
|
-
releaseDate,
|
|
840
|
-
homePagePath
|
|
841
|
-
};
|
|
842
|
-
};
|
|
843
|
-
|
|
844
|
-
const Copyright = ({
|
|
845
|
-
parameters
|
|
846
|
-
}) => {
|
|
847
|
-
return /* @__PURE__ */ React.createElement("span", { id: "dg-copyright" }, "\xA9 ", parameters.year, "\xA0", parameters?.organization?.url ? /* @__PURE__ */ React.createElement("a", { href: parameters.organization.url }, parameters.organization.name) : parameters?.organization?.nmee ? /* @__PURE__ */ React.createElement("span", null, "parameters.organization.name") : null);
|
|
848
|
-
};
|
|
849
|
-
|
|
850
|
-
const Footer = ({
|
|
851
|
-
parameters
|
|
852
|
-
}) => {
|
|
853
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", null, /* @__PURE__ */ React.createElement(Copyright, { parameters })), /* @__PURE__ */ React.createElement("p", null, /* @__PURE__ */ React.createElement("span", null, parameters.marking, " ", parameters.legalese, " ", parameters.attribution)));
|
|
854
|
-
};
|
|
855
|
-
const WebFooter = ({ parameters }) => {
|
|
856
|
-
return /* @__PURE__ */ React.createElement("footer", null, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("p", null, /* @__PURE__ */ React.createElement("span", { id: "dg-web-footer" }, parameters.webFooter))), /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Footer, { parameters })));
|
|
857
|
-
};
|
|
858
|
-
|
|
859
|
-
const Logo = ({ parameters }) => {
|
|
860
|
-
return parameters?.logoPath && /* @__PURE__ */ React.createElement(
|
|
861
|
-
"img",
|
|
862
|
-
{
|
|
863
|
-
style: {
|
|
864
|
-
marginRight: "25px"
|
|
865
|
-
},
|
|
866
|
-
src: parameters?.logoPath
|
|
867
|
-
}
|
|
868
|
-
);
|
|
869
|
-
};
|
|
870
|
-
const TopBar = ({ parameters }) => {
|
|
871
|
-
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: "topbar" }, /* @__PURE__ */ React.createElement("div", { className: "left" }, /* @__PURE__ */ React.createElement("a", { className: "dg-homelink", href: parameters.homePagePath }, /* @__PURE__ */ React.createElement(Logo, { parameters })), /* @__PURE__ */ React.createElement("div", { id: "headerLeftText" }, /* @__PURE__ */ React.createElement("a", { className: "dg-homelink", href: parameters.homePagePath }, /* @__PURE__ */ React.createElement("span", { id: "dg-title" }, parameters.title), /* @__PURE__ */ React.createElement("span", { id: "dg-web-title-version", style: { fontWeight: "normal" } }, "\xA0(", parameters.version, ")")), parameters?.sponsorLink?.name && /* @__PURE__ */ React.createElement("div", { id: "headerSponsor" }, /* @__PURE__ */ React.createElement("span", null, parameters.sponsorLink.name), /* @__PURE__ */ React.createElement("a", { href: parameters.sponsorLink.url }, /* @__PURE__ */ React.createElement(
|
|
872
|
-
"img",
|
|
873
|
-
{
|
|
874
|
-
id: "sponsorLogo",
|
|
875
|
-
src: parameters.sponsorLink.logo,
|
|
876
|
-
alt: "sponsor logo"
|
|
877
|
-
}
|
|
878
|
-
))))), /* @__PURE__ */ React.createElement("div", { className: "right" }, /* @__PURE__ */ React.createElement("span", { id: "dg-backlink" }, parameters.backlink.url && /* @__PURE__ */ React.createElement("a", { className: "button inverted", href: parameters.backlink.url }, parameters.backlink.name)))));
|
|
879
|
-
};
|
|
880
|
-
|
|
881
|
-
const Page$1 = ({ page }) => {
|
|
882
|
-
const name = page.source.substring(0, page.source.lastIndexOf("."));
|
|
883
|
-
const path = name + ".html";
|
|
884
|
-
return /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("a", { href: path }, page.title));
|
|
885
|
-
};
|
|
886
|
-
const SideBar = ({
|
|
887
|
-
name,
|
|
888
|
-
sortedPages,
|
|
889
|
-
pdfEnabled
|
|
890
|
-
}) => {
|
|
891
|
-
const pages = Object.values(sortedPages).flat();
|
|
892
|
-
const pdfName = name.toLowerCase() + ".pdf";
|
|
893
|
-
return /* @__PURE__ */ React.createElement("div", { id: "dgSideBar", className: "dgSideBarCollapsed" }, /* @__PURE__ */ React.createElement("button", { id: "dgSideBarButton" }, /* @__PURE__ */ React.createElement("span", { className: "dgIcon", "data-name": "menu-2" })), /* @__PURE__ */ React.createElement("div", { id: "dgSideBarInnerWrapper" }, /* @__PURE__ */ React.createElement("div", { id: "dgSideBarInner" }, /* @__PURE__ */ React.createElement("div", { id: "dgSideBarContent" }, pages.filter((p) => p?.heading !== "Extra").map((page, i) => /* @__PURE__ */ React.createElement("div", { key: i }, /* @__PURE__ */ React.createElement("div", { className: "dgSideBarHeading" }, page.heading), /* @__PURE__ */ React.createElement("ul", null, page.pages.map((subPage, i2) => /* @__PURE__ */ React.createElement(Page$1, { key: i2, page: subPage }))))), /* @__PURE__ */ React.createElement("div", { className: "dgSideBarAttribution" }, /* @__PURE__ */ React.createElement("ul", null, /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement(
|
|
894
|
-
"span",
|
|
895
|
-
{
|
|
896
|
-
className: "dgIcon",
|
|
897
|
-
"data-name": "users",
|
|
898
|
-
title: "ownership"
|
|
899
|
-
}
|
|
900
|
-
), /* @__PURE__ */ React.createElement("a", { href: "ownership.html" }, "Ownership")), /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement(
|
|
901
|
-
"span",
|
|
902
|
-
{
|
|
903
|
-
className: "dgIcon",
|
|
904
|
-
"data-name": "refresh",
|
|
905
|
-
title: "release notes"
|
|
906
|
-
}
|
|
907
|
-
), /* @__PURE__ */ React.createElement("a", { href: "release-notes.html" }, "Release Notes")))), /* @__PURE__ */ React.createElement("div", { className: "dgSideBarPDFButton" }, pdfEnabled && /* @__PURE__ */ React.createElement(
|
|
908
|
-
"a",
|
|
909
|
-
{
|
|
910
|
-
className: "button",
|
|
911
|
-
style: { textDecoration: "none" },
|
|
912
|
-
href: pdfName
|
|
913
|
-
},
|
|
914
|
-
"PDF"
|
|
915
|
-
))))));
|
|
916
|
-
};
|
|
917
|
-
|
|
918
|
-
const Page = ({ children }) => {
|
|
919
|
-
return /* @__PURE__ */ React.createElement(
|
|
920
|
-
"div",
|
|
921
|
-
{
|
|
922
|
-
className: "page"
|
|
923
|
-
},
|
|
924
|
-
children
|
|
925
|
-
);
|
|
926
|
-
};
|
|
927
|
-
|
|
928
|
-
const Main = ({
|
|
929
|
-
parameters,
|
|
930
|
-
sortedPages,
|
|
931
|
-
pdfEnabled,
|
|
932
|
-
children
|
|
933
|
-
}) => {
|
|
934
|
-
const {
|
|
935
|
-
name
|
|
936
|
-
} = parameters;
|
|
937
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
938
|
-
TopBar,
|
|
939
|
-
{
|
|
940
|
-
parameters
|
|
941
|
-
}
|
|
942
|
-
), /* @__PURE__ */ React.createElement(
|
|
943
|
-
SideBar,
|
|
944
|
-
{
|
|
945
|
-
name,
|
|
946
|
-
sortedPages,
|
|
947
|
-
pdfEnabled
|
|
948
|
-
}
|
|
949
|
-
), /* @__PURE__ */ React.createElement(Page, null, /* @__PURE__ */ React.createElement("section", { id: "dg-content" }, /* @__PURE__ */ React.createElement("div", { id: "dg-innerContent" }, children)), /* @__PURE__ */ React.createElement(WebFooter, { parameters })));
|
|
950
|
-
};
|
|
951
|
-
|
|
952
|
-
const Cover = ({
|
|
953
|
-
parameters
|
|
954
|
-
}) => {
|
|
955
|
-
return /* @__PURE__ */ React.createElement("div", { className: "w-fixed-width" }, /* @__PURE__ */ React.createElement("div", { id: "dg-innerContent" }, /* @__PURE__ */ React.createElement(
|
|
956
|
-
"table",
|
|
957
|
-
{
|
|
958
|
-
id: "dg-coverInfo"
|
|
959
|
-
},
|
|
960
|
-
/* @__PURE__ */ React.createElement("thead", null, /* @__PURE__ */ React.createElement("tr", null, /* @__PURE__ */ React.createElement("th", { colSpan: 3, id: "dg-title" }, parameters.title))),
|
|
961
|
-
/* @__PURE__ */ React.createElement("tfoot", null),
|
|
962
|
-
/* @__PURE__ */ React.createElement("tbody", null, /* @__PURE__ */ React.createElement("tr", null, /* @__PURE__ */ React.createElement("td", null, /* @__PURE__ */ React.createElement("strong", null, "Owner: "), /* @__PURE__ */ React.createElement("span", { id: "dg-owner" }, parameters.owner?.url ? /* @__PURE__ */ React.createElement("a", { href: parameters.owner.url }, parameters.owner.name) : parameters.owner.name)), /* @__PURE__ */ React.createElement("td", null, /* @__PURE__ */ React.createElement("strong", null, "Version: "), /* @__PURE__ */ React.createElement("span", { id: "dg-version" }, parameters.version)), /* @__PURE__ */ React.createElement("td", null, /* @__PURE__ */ React.createElement("strong", null, "Released: "), /* @__PURE__ */ React.createElement("span", { id: "dg-release-date" }, parameters.releaseDate))), /* @__PURE__ */ React.createElement("tr", null, /* @__PURE__ */ React.createElement("td", null, /* @__PURE__ */ React.createElement("strong", null, "Author: "), /* @__PURE__ */ React.createElement("span", { id: "dg-author" }, parameters.author?.url ? /* @__PURE__ */ React.createElement("a", { href: parameters.author.url }, parameters.author.name) : parameters.author.name)), /* @__PURE__ */ React.createElement("td", { colSpan: 2 }, /* @__PURE__ */ React.createElement("strong", null, "Contributors: "), /* @__PURE__ */ React.createElement("span", { id: "dg-contributors" }, parameters.contributors.map((contributor, i) => /* @__PURE__ */ React.createElement(Fragment, { key: i }, contributor?.url ? /* @__PURE__ */ React.createElement("a", { href: contributor.url }, contributor.name) : contributor.name, i < parameters.contributors.length - 1 && ","))))), /* @__PURE__ */ React.createElement("tr", { className: "dg-finalRow" }, /* @__PURE__ */ React.createElement("td", null, /* @__PURE__ */ React.createElement("strong", null, "Module: "), /* @__PURE__ */ React.createElement("span", { id: "dg-module" }, parameters.module)), /* @__PURE__ */ React.createElement("td", null, /* @__PURE__ */ React.createElement("strong", null, "ID: "), /* @__PURE__ */ React.createElement("span", { id: "dg-id" }, parameters.id)), /* @__PURE__ */ React.createElement("td", null, /* @__PURE__ */ React.createElement("strong", null, "Link: "), /* @__PURE__ */ React.createElement("span", { id: "dg-website" }, parameters.website?.url ? /* @__PURE__ */ React.createElement("a", { href: parameters.website.url }, parameters.website.name) : parameters.website.name))))
|
|
963
|
-
), /* @__PURE__ */ React.createElement("h1", null, "Summary"), /* @__PURE__ */ React.createElement("p", { id: "dg-summary" }, parameters.summary)));
|
|
964
|
-
};
|
|
965
|
-
|
|
966
|
-
const toHTML = (component) => {
|
|
967
|
-
return ReactDOMServer.renderToStaticMarkup(component);
|
|
968
|
-
};
|
|
969
|
-
|
|
970
|
-
const { cloneDeep } = pkg;
|
|
971
|
-
const processTemplates = ({
|
|
972
|
-
parameters,
|
|
973
|
-
templates: rawTemplates
|
|
974
|
-
}) => {
|
|
975
|
-
const templates = cloneDeep(rawTemplates);
|
|
976
|
-
for (let key in templates) {
|
|
977
|
-
if (templates.hasOwnProperty(key)) {
|
|
978
|
-
let $ = templates[key];
|
|
979
|
-
$("title").text(parameters.title);
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
return templates;
|
|
983
|
-
};
|
|
984
|
-
const processPages = async ({
|
|
985
|
-
templates,
|
|
986
|
-
pages: rawPages,
|
|
987
|
-
sortedPages,
|
|
988
|
-
parameters,
|
|
989
|
-
options,
|
|
990
|
-
contents
|
|
991
|
-
}) => {
|
|
992
|
-
const hydratedTemplates = processTemplates({
|
|
993
|
-
parameters,
|
|
994
|
-
templates
|
|
995
|
-
});
|
|
996
|
-
const pages = cloneDeep(rawPages);
|
|
997
|
-
const pageTableOfContentsEnabled = options.pageToc;
|
|
998
|
-
const tableOfContents = contents;
|
|
999
|
-
const mainTemplate = hydratedTemplates.main;
|
|
1000
|
-
const pdfEnabled = options.pdf;
|
|
1001
|
-
console.log(pico.green("Generating the static web content"));
|
|
1002
|
-
tableOfContents.forEach((section) => {
|
|
1003
|
-
section.pages.forEach((page) => {
|
|
1004
|
-
let $2 = cheerio.load(mainTemplate.html());
|
|
1005
|
-
let key = page.source;
|
|
1006
|
-
const htmlPage = toHTML(
|
|
1007
|
-
/* @__PURE__ */ React.createElement(
|
|
1008
|
-
Main,
|
|
1009
|
-
{
|
|
1010
|
-
parameters,
|
|
1011
|
-
sortedPages,
|
|
1012
|
-
pdfEnabled
|
|
1013
|
-
}
|
|
1014
|
-
)
|
|
1015
|
-
);
|
|
1016
|
-
$2("body").html(htmlPage);
|
|
1017
|
-
const content = pages[key];
|
|
1018
|
-
$2("#dg-innerContent").html(content);
|
|
1019
|
-
let html = [], i = -1;
|
|
1020
|
-
let headings = $2("h1, h2, h3, h4, h5, h6");
|
|
1021
|
-
if (headings.length > 0) {
|
|
1022
|
-
html[++i] = '<ul class="dg-pageToc">';
|
|
1023
|
-
}
|
|
1024
|
-
headings.each(function() {
|
|
1025
|
-
let label = $2(this).text();
|
|
1026
|
-
let anchor = label.toLowerCase().replace(/\s+/g, "-");
|
|
1027
|
-
$2(this).attr("id", anchor);
|
|
1028
|
-
html[++i] = '<li><a href="#' + anchor + '">' + label + "</a></li>";
|
|
1029
|
-
});
|
|
1030
|
-
if (headings.length > 0) {
|
|
1031
|
-
html[++i] = "</ul>";
|
|
1032
|
-
}
|
|
1033
|
-
if (pageTableOfContentsEnabled === true && page.html !== true) {
|
|
1034
|
-
$2("#dg-innerContent").prepend(html.join(""));
|
|
1035
|
-
}
|
|
1036
|
-
if (!page.hideAutomaticPageHeading) {
|
|
1037
|
-
$2("#dg-innerContent").prepend(
|
|
1038
|
-
'<h1 id="dg-autoTitle">' + page.title + "</h1>"
|
|
1039
|
-
);
|
|
1040
|
-
$2("#dg-autoTitle").addClass("dg-hiddenTitle");
|
|
1041
|
-
}
|
|
1042
|
-
pages[key] = $2.html();
|
|
1043
|
-
});
|
|
1044
|
-
});
|
|
1045
|
-
const webCoverHtml = toHTML(
|
|
1046
|
-
/* @__PURE__ */ React.createElement(
|
|
1047
|
-
Main,
|
|
1048
|
-
{
|
|
1049
|
-
parameters,
|
|
1050
|
-
sortedPages,
|
|
1051
|
-
pdfEnabled
|
|
1052
|
-
},
|
|
1053
|
-
/* @__PURE__ */ React.createElement(
|
|
1054
|
-
Cover,
|
|
1055
|
-
{
|
|
1056
|
-
parameters
|
|
1057
|
-
}
|
|
1058
|
-
)
|
|
1059
|
-
)
|
|
1060
|
-
);
|
|
1061
|
-
let $ = cheerio.load(mainTemplate.html());
|
|
1062
|
-
$("body").html(webCoverHtml);
|
|
1063
|
-
return {
|
|
1064
|
-
pages,
|
|
1065
|
-
redirect: hydratedTemplates.redirect,
|
|
1066
|
-
webCover: $.html()
|
|
1067
|
-
};
|
|
1068
|
-
};
|
|
1069
|
-
|
|
1070
|
-
const writePages = async ({
|
|
1071
|
-
options,
|
|
1072
|
-
hydratedPages,
|
|
1073
|
-
contents,
|
|
1074
|
-
mainProcess
|
|
1075
|
-
}) => {
|
|
1076
|
-
console.log(pico.green("Writing the web page files"));
|
|
1077
|
-
try {
|
|
1078
|
-
const promises = contents.flatMap(
|
|
1079
|
-
(section) => section.pages.map((page) => {
|
|
1080
|
-
const key = page.source;
|
|
1081
|
-
const name = key.substr(0, page.source.lastIndexOf("."));
|
|
1082
|
-
const path = options.output + name + ".html";
|
|
1083
|
-
const html = hydratedPages.pages[key];
|
|
1084
|
-
return writeFile(path, html);
|
|
1085
|
-
})
|
|
1086
|
-
);
|
|
1087
|
-
await Promise.all(promises);
|
|
1088
|
-
await writeFile(options.output + "ownership.html", hydratedPages.webCover);
|
|
1089
|
-
await copyDirectory(
|
|
1090
|
-
join(packageAbsolutePath, "include/require"),
|
|
1091
|
-
options.output + "require",
|
|
1092
|
-
options.verbose
|
|
1093
|
-
);
|
|
1094
|
-
await copyDirectory(
|
|
1095
|
-
options.input + "files",
|
|
1096
|
-
options.output + "files",
|
|
1097
|
-
options.verbose
|
|
1098
|
-
);
|
|
1099
|
-
} catch (error) {
|
|
1100
|
-
console.log(pico.red("Error writing the web page files"));
|
|
1101
|
-
if (options.verbose === true) {
|
|
1102
|
-
console.log(pico.red(error));
|
|
1103
|
-
}
|
|
1104
|
-
mainProcess.exit(1);
|
|
1105
|
-
}
|
|
1106
|
-
};
|
|
1107
|
-
|
|
1108
|
-
let createRedirect = async ({ options, redirectPage, homePage }) => {
|
|
1109
|
-
if (options.isRedirectEnabled) {
|
|
1110
|
-
let parent = options.output.replace(/\/$/, "");
|
|
1111
|
-
parent = parent.split(path.sep).slice(-1).pop();
|
|
1112
|
-
let homepage = homePage;
|
|
1113
|
-
homepage = homepage.source.substr(0, homepage.source.lastIndexOf(".")) + ".html";
|
|
1114
|
-
let redirectLink = parent + "/" + homepage;
|
|
1115
|
-
let $ = redirectPage;
|
|
1116
|
-
$("a").attr("href", redirectLink);
|
|
1117
|
-
$("meta[http-equiv=REFRESH]").attr("content", "0;url=" + redirectLink);
|
|
1118
|
-
let file = options.output + "../index.html";
|
|
1119
|
-
try {
|
|
1120
|
-
await writeFile(file, $.html());
|
|
1121
|
-
} catch (error) {
|
|
1122
|
-
console.log(pico.red("Error writing redirect file: " + file));
|
|
1123
|
-
if (options.verbose === true) {
|
|
1124
|
-
console.log(pico.red(error));
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
};
|
|
1129
|
-
|
|
1130
|
-
var version = "5.2.0";
|
|
1131
|
-
|
|
1132
|
-
function DocGen(process) {
|
|
1133
|
-
let mainProcess = process;
|
|
1134
|
-
let options;
|
|
1135
|
-
this.getVersion = () => {
|
|
1136
|
-
return version;
|
|
1137
|
-
};
|
|
1138
|
-
this.setOptions = (userOptions) => {
|
|
1139
|
-
options = userOptions;
|
|
1140
|
-
if (options.input) {
|
|
1141
|
-
options.input = path.normalize(options.input + "/");
|
|
1142
|
-
}
|
|
1143
|
-
if (options.output) {
|
|
1144
|
-
options.output = path.normalize(options.output + "/");
|
|
1145
|
-
}
|
|
1146
|
-
};
|
|
1147
|
-
this.scaffold = async () => scaffold$1({
|
|
1148
|
-
outputDirectory: options.output,
|
|
1149
|
-
verbose: options.verbose === true
|
|
1150
|
-
});
|
|
1151
|
-
this.run = async () => {
|
|
1152
|
-
console.log(pico.green(pico.bold("DocGen version " + version)));
|
|
1153
|
-
await cleanDirectory(options.output, options.verbose);
|
|
1154
|
-
const templates = await loadTemplates({
|
|
1155
|
-
options,
|
|
1156
|
-
mainProcess
|
|
1157
|
-
});
|
|
1158
|
-
const { contents, rawParameters } = await loadMeta({
|
|
1159
|
-
inputPath: options.input,
|
|
1160
|
-
verbose: options.verbose,
|
|
1161
|
-
mainProcess
|
|
1162
|
-
});
|
|
1163
|
-
const sortedPages = sortPages({ contents });
|
|
1164
|
-
const parameters = deriveParameters({
|
|
1165
|
-
rawParameters,
|
|
1166
|
-
setVersion: options.setVersion,
|
|
1167
|
-
setReleaseDate: options.setReleaseDate,
|
|
1168
|
-
homeLink: contents[0].pages[0]
|
|
1169
|
-
});
|
|
1170
|
-
const pages = await loadMarkdown({
|
|
1171
|
-
options,
|
|
1172
|
-
contents,
|
|
1173
|
-
mainProcess
|
|
1174
|
-
});
|
|
1175
|
-
const hydratedPages = await processPages({
|
|
1176
|
-
templates,
|
|
1177
|
-
pages,
|
|
1178
|
-
sortedPages,
|
|
1179
|
-
parameters,
|
|
1180
|
-
options,
|
|
1181
|
-
contents
|
|
1182
|
-
});
|
|
1183
|
-
await writePages({
|
|
1184
|
-
options,
|
|
1185
|
-
contents,
|
|
1186
|
-
hydratedPages,
|
|
1187
|
-
mainProcess
|
|
1188
|
-
});
|
|
1189
|
-
await createRedirect({
|
|
1190
|
-
options,
|
|
1191
|
-
redirectPage: hydratedPages.redirect,
|
|
1192
|
-
homePage: contents[0].pages[0]
|
|
1193
|
-
});
|
|
1194
|
-
if (options.pdf === true) {
|
|
1195
|
-
generatePdf({
|
|
1196
|
-
options,
|
|
1197
|
-
pages,
|
|
1198
|
-
parameters,
|
|
1199
|
-
sortedPages,
|
|
1200
|
-
mainProcess
|
|
1201
|
-
});
|
|
1202
|
-
} else {
|
|
1203
|
-
console.log(pico.green(pico.bold("Done!")));
|
|
1204
|
-
}
|
|
1205
|
-
};
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
const generator = new DocGen(process);
|
|
1209
|
-
const scaffold = (command) => {
|
|
1210
|
-
generator.setOptions(command);
|
|
1211
|
-
generator.scaffold();
|
|
1212
|
-
};
|
|
1213
|
-
const run = (command) => {
|
|
1214
|
-
generator.setOptions(command);
|
|
1215
|
-
generator.run();
|
|
1216
|
-
};
|
|
1217
|
-
program.version(generator.getVersion()).usage("[command] [--option]");
|
|
1218
|
-
program.command("scaffold").usage("[--option]").description("create a template input directory").option(
|
|
1219
|
-
"-o, --output [path]",
|
|
1220
|
-
"path to the output directory (default: ./)",
|
|
1221
|
-
"./"
|
|
1222
|
-
).option("-v, --verbose", "show verbose output including detailed errors").action((command) => {
|
|
1223
|
-
scaffold(command);
|
|
1224
|
-
});
|
|
1225
|
-
program.command("run").usage("[--option]").description("create a static website from an input directory").option(
|
|
1226
|
-
"-i, --input [path]",
|
|
1227
|
-
"path to the input directory [default: ./]",
|
|
1228
|
-
"./"
|
|
1229
|
-
).option(
|
|
1230
|
-
"-o, --output [path]",
|
|
1231
|
-
"path to the output directory [default: ./output]",
|
|
1232
|
-
"./output"
|
|
1233
|
-
).option("-v, --verbose", "show verbose output including detailed errors").option(
|
|
1234
|
-
"-t, --page-toc",
|
|
1235
|
-
"show a page table of contents at the top of each web page"
|
|
1236
|
-
).option("-p, --pdf", "create a PDF document").option(
|
|
1237
|
-
"-r, --redirect",
|
|
1238
|
-
"create an index.html in the parent directory that redirects to the homepage"
|
|
1239
|
-
).option(
|
|
1240
|
-
"-s, --set-version [version]",
|
|
1241
|
-
"override parameters.version (useful for build tools) [default: false]",
|
|
1242
|
-
false
|
|
1243
|
-
).option(
|
|
1244
|
-
"-R, --set-release-date [date]",
|
|
1245
|
-
"override parameters.date (useful for build tools) [default: false]",
|
|
1246
|
-
false
|
|
1247
|
-
).action((command) => {
|
|
1248
|
-
run(command);
|
|
1249
|
-
});
|
|
1250
|
-
program.parse(process.argv);
|
|
1251
|
-
if (!process.argv.slice(2).length) {
|
|
1252
|
-
program.help();
|
|
1253
|
-
}
|