hdoc-tools 0.30.0 → 0.32.0
Sign up to get free protection for your applications and to get access to all the features.
- package/custom_modules/tips.js +6 -0
- package/hdoc-build.js +16 -1
- package/hdoc-module.js +54 -0
- package/hdoc-validate.js +14 -0
- package/package.json +1 -1
- package/templates/pdf/css/hdocs-pdf.css +11 -2
- package/templates/pdf/css/vars.css +16 -5
- package/ui/css/theme-default/styles/components/htl-doc.css +11 -2
- package/ui/css/theme-default/styles/vars.css +16 -4
package/custom_modules/tips.js
CHANGED
@@ -26,6 +26,11 @@
|
|
26
26
|
class: "bi bi-megaphone",
|
27
27
|
title: "Important",
|
28
28
|
};
|
29
|
+
case "info":
|
30
|
+
return {
|
31
|
+
class: "bi bi-info-circle",
|
32
|
+
title: "Information",
|
33
|
+
};
|
29
34
|
case "caution":
|
30
35
|
return {
|
31
36
|
class: "bi bi-x-circle",
|
@@ -77,6 +82,7 @@
|
|
77
82
|
setupContainer("note");
|
78
83
|
setupContainer("tip");
|
79
84
|
setupContainer("important");
|
85
|
+
setupContainer("info");
|
80
86
|
setupContainer("caution");
|
81
87
|
setupContainer("warning");
|
82
88
|
|
package/hdoc-build.js
CHANGED
@@ -60,6 +60,7 @@
|
|
60
60
|
let conversion_failed = 0;
|
61
61
|
let doc_header_template = "";
|
62
62
|
let doc_header_template_non_git = "";
|
63
|
+
let github_repo_details = {};
|
63
64
|
let global_source_path = "";
|
64
65
|
let pdf_created = 0;
|
65
66
|
let pdf_enable = false;
|
@@ -306,7 +307,8 @@
|
|
306
307
|
hdocbook_config.publicSource,
|
307
308
|
file_path.relativePath,
|
308
309
|
);
|
309
|
-
|
310
|
+
|
311
|
+
const contributors = await hdoc.get_github_contributors(
|
310
312
|
github_paths.api_path,
|
311
313
|
git_token,
|
312
314
|
);
|
@@ -1184,6 +1186,18 @@
|
|
1184
1186
|
prods_supported = prods.prods_supported;
|
1185
1187
|
}
|
1186
1188
|
|
1189
|
+
const clean_repo = hdocbook_config.publicSource.endsWith("/") ? hdocbook_config.publicSource.slice(0, -1) : hdocbook_config.publicSource;
|
1190
|
+
const api_path = clean_repo.replace(
|
1191
|
+
"https://github.com/",
|
1192
|
+
"https://api.github.com/repos/",
|
1193
|
+
);
|
1194
|
+
|
1195
|
+
// Get github repo details
|
1196
|
+
github_repo_details = await hdoc.get_github_repo_details( api_path, git_token );
|
1197
|
+
if (github_repo_details.success) {
|
1198
|
+
console.warn(`Unable to retrieve GitHub Repository details: ${github_repo_details.error}`);
|
1199
|
+
}
|
1200
|
+
|
1187
1201
|
if (!validate) {
|
1188
1202
|
console.log("Caching CSS for PDF generation...");
|
1189
1203
|
const css_files = [
|
@@ -1394,6 +1408,7 @@
|
|
1394
1408
|
gen_exclude,
|
1395
1409
|
redirects,
|
1396
1410
|
draft_links,
|
1411
|
+
github_repo_details.data.private,
|
1397
1412
|
);
|
1398
1413
|
if (!validation_success) {
|
1399
1414
|
const end_time = Date.now();
|
package/hdoc-module.js
CHANGED
@@ -434,6 +434,60 @@
|
|
434
434
|
return github_paths;
|
435
435
|
};
|
436
436
|
|
437
|
+
exports.get_github_repo_details = async (
|
438
|
+
github_url,
|
439
|
+
github_api_token,
|
440
|
+
) => {
|
441
|
+
const response = {
|
442
|
+
success: false,
|
443
|
+
error: "",
|
444
|
+
data: {},
|
445
|
+
private: false
|
446
|
+
};
|
447
|
+
const request_options = {
|
448
|
+
headers: {
|
449
|
+
"User-Agent": "HornbillDocsBuild",
|
450
|
+
"Cache-Control": "no-cache",
|
451
|
+
Host: "api.github.com",
|
452
|
+
Accept: "application/json",
|
453
|
+
},
|
454
|
+
timeout: 5000,
|
455
|
+
};
|
456
|
+
if (github_api_token !== "") {
|
457
|
+
request_options.headers.authorization = `Bearer ${github_api_token}`;
|
458
|
+
}
|
459
|
+
|
460
|
+
let github_response;
|
461
|
+
try {
|
462
|
+
github_response = await axios.get(github_url, request_options);
|
463
|
+
if (retried) {
|
464
|
+
retried = false;
|
465
|
+
console.log("API call retry success!");
|
466
|
+
}
|
467
|
+
} catch (err) {
|
468
|
+
if (err.response) {
|
469
|
+
if (err.response.status !== 403 && err.response.status !== 401) {
|
470
|
+
response.error = err;
|
471
|
+
return response;
|
472
|
+
}
|
473
|
+
github_response = err.response;
|
474
|
+
} else {
|
475
|
+
response.error = `Unexpected response from GitHub for [${github_url}:\n${JSON.stringify(
|
476
|
+
err,
|
477
|
+
)}]`;
|
478
|
+
}
|
479
|
+
}
|
480
|
+
if (github_response.status === 200) {
|
481
|
+
response.success = true;
|
482
|
+
response.data = github_response.data;
|
483
|
+
response.private = github_response.data.private;
|
484
|
+
} else {
|
485
|
+
// Is it a 404 or 403?
|
486
|
+
response.error = `${github_response.status} : ${data.message}`;
|
487
|
+
}
|
488
|
+
return response;
|
489
|
+
};
|
490
|
+
|
437
491
|
exports.get_github_contributors = async (
|
438
492
|
github_url,
|
439
493
|
github_api_token,
|
package/hdoc-validate.js
CHANGED
@@ -28,6 +28,7 @@ const e = require("express");
|
|
28
28
|
const md_to_validate = [];
|
29
29
|
const exclude_links = {};
|
30
30
|
const exclude_spellcheck = {};
|
31
|
+
let private_repo = false;
|
31
32
|
let redirects = {};
|
32
33
|
const exclude_h1_count = {};
|
33
34
|
const exclude_spellcheck_output = [];
|
@@ -545,6 +546,17 @@ const e = require("express");
|
|
545
546
|
continue;
|
546
547
|
}
|
547
548
|
|
549
|
+
if (
|
550
|
+
links[i].toLowerCase().includes("docs-internal.hornbill.com") &&
|
551
|
+
markdown_paths.relativePath.includes('/_inline/') &&
|
552
|
+
!private_repo
|
553
|
+
) {
|
554
|
+
// Is the parent book in a public repo? If so, flag this as an error.
|
555
|
+
const error_message = processErrorMessage(`Hornbill docs-internal links should not be used in public book inline content: ${links[i]}`, markdown_paths.relativePath, markdown_content, links[i]);
|
556
|
+
errors[htmlFile.relativePath].push( error_message );
|
557
|
+
continue;
|
558
|
+
}
|
559
|
+
|
548
560
|
try {
|
549
561
|
await axios({
|
550
562
|
url: links[i],
|
@@ -810,9 +822,11 @@ const e = require("express");
|
|
810
822
|
gen_exclude,
|
811
823
|
gen_redirects,
|
812
824
|
draft_links,
|
825
|
+
is_private,
|
813
826
|
) => {
|
814
827
|
console.log("Performing Validation and Building SEO Link List...");
|
815
828
|
redirects = gen_redirects;
|
829
|
+
private_repo = is_private;
|
816
830
|
|
817
831
|
// Get a list of HTML files in source_path
|
818
832
|
dree.scan(source_path, dreeOptions, fileContentCallback);
|
package/package.json
CHANGED
@@ -212,13 +212,22 @@ video {
|
|
212
212
|
}
|
213
213
|
|
214
214
|
.hdoc-alert.alert-icon-important {
|
215
|
+
border-color: var(--htl-custom-block-important-border);
|
216
|
+
color: var(--htl-custom-block-important-text);
|
217
|
+
background-color: var(--htl-custom-block-important-bg);
|
218
|
+
}
|
219
|
+
|
220
|
+
.hdoc-alert.alert-icon-important code {
|
221
|
+
background-color: var(--htl-custom-block-important-code-bg);
|
222
|
+
}
|
223
|
+
|
224
|
+
.hdoc-alert.alert-icon-info {
|
215
225
|
border-color: var(--htl-custom-block-info-border);
|
216
226
|
color: var(--htl-custom-block-info-text);
|
217
227
|
background-color: var(--htl-custom-block-info-bg);
|
218
|
-
|
219
228
|
}
|
220
229
|
|
221
|
-
.hdoc-alert.alert-icon-
|
230
|
+
.hdoc-alert.alert-icon-info code {
|
222
231
|
background-color: var(--htl-custom-block-info-code-bg);
|
223
232
|
}
|
224
233
|
|
@@ -310,14 +310,18 @@
|
|
310
310
|
* Component: Custom Block
|
311
311
|
* -------------------------------------------------------------------------- */
|
312
312
|
|
313
|
-
:root {
|
313
|
+
:root {
|
314
314
|
--htl-custom-block-code-font-size: var(--htl-default-font-size);
|
315
315
|
|
316
|
-
--htl-custom-block-
|
317
|
-
--htl-custom-block-
|
318
|
-
--htl-custom-block-
|
319
|
-
--htl-custom-block-
|
316
|
+
--htl-custom-block-important-border: var(--htl-c-indigo-dark);
|
317
|
+
--htl-custom-block-important-text: var(--htl-c-indigo-dark);
|
318
|
+
--htl-custom-block-important-bg: var(--htl-c-indigo-lighter);
|
319
|
+
--htl-custom-block-important-code-bg: var(--htl-custom-block-important-bg);
|
320
320
|
|
321
|
+
--htl-custom-block-info-border: var(--htl-c-blue-dimm-1);
|
322
|
+
--htl-custom-block-info-text: var(--htl-c-blue-darker);
|
323
|
+
--htl-custom-block-info-bg: var(--htl-c-blue-dimm-3);
|
324
|
+
--htl-custom-block-info-code-bg: var(--htl-custom-block-info-bg);
|
321
325
|
|
322
326
|
--htl-custom-block-tip-border: var(--htl-c-green-dimm-1);
|
323
327
|
--htl-custom-block-tip-text: var(--htl-c-green-darker);
|
@@ -346,6 +350,13 @@
|
|
346
350
|
--htl-custom-block-details-bg: var(--htl-c-black-mute);
|
347
351
|
--htl-custom-block-details-code-bg: var(--htl-c-gray-dark-4);
|
348
352
|
|
353
|
+
--htl-custom-block-important-border: var(--htl-c-indigo-lighter);
|
354
|
+
--htl-custom-block-important-bg: var(--htl-c-indigo-dark);
|
355
|
+
--htl-custom-block-important-text: var(--htl-c-indigo-lighter);
|
356
|
+
|
357
|
+
--htl-custom-block-info-text: var(--htl-c-blue);
|
358
|
+
--htl-custom-block-info-bg: var(--htl-c-blue-dimm-3);
|
359
|
+
|
349
360
|
--htl-custom-block-tip-border: var(--htl-c-green-dimm-2);
|
350
361
|
--htl-custom-block-tip-text: var(--htl-c-green-light);
|
351
362
|
|
@@ -796,13 +796,22 @@
|
|
796
796
|
}
|
797
797
|
|
798
798
|
.HTL-doc .hdoc-alert.alert-icon-important {
|
799
|
+
border-color: var(--htl-custom-block-important-border);
|
800
|
+
color: var(--htl-custom-block-important-text);
|
801
|
+
background-color: var(--htl-custom-block-important-bg);
|
802
|
+
}
|
803
|
+
|
804
|
+
.HTL-doc .hdoc-alert.alert-icon-important code {
|
805
|
+
background-color: var(--htl-custom-block-important-code-bg);
|
806
|
+
}
|
807
|
+
|
808
|
+
.HTL-doc .hdoc-alert.alert-icon-info {
|
799
809
|
border-color: var(--htl-custom-block-info-border);
|
800
810
|
color: var(--htl-custom-block-info-text);
|
801
811
|
background-color: var(--htl-custom-block-info-bg);
|
802
|
-
|
803
812
|
}
|
804
813
|
|
805
|
-
.HTL-doc .hdoc-alert.alert-icon-
|
814
|
+
.HTL-doc .hdoc-alert.alert-icon-info code {
|
806
815
|
background-color: var(--htl-custom-block-info-code-bg);
|
807
816
|
}
|
808
817
|
|
@@ -313,10 +313,15 @@
|
|
313
313
|
:root {
|
314
314
|
--htl-custom-block-code-font-size: var(--htl-default-font-size);
|
315
315
|
|
316
|
-
--htl-custom-block-
|
317
|
-
--htl-custom-block-
|
318
|
-
--htl-custom-block-
|
319
|
-
--htl-custom-block-
|
316
|
+
--htl-custom-block-important-border: var(--htl-c-indigo-dark);
|
317
|
+
--htl-custom-block-important-text: var(--htl-c-indigo-dark);
|
318
|
+
--htl-custom-block-important-bg: var(--htl-c-indigo-lighter);
|
319
|
+
--htl-custom-block-important-code-bg: var(--htl-custom-block-important-bg);
|
320
|
+
|
321
|
+
--htl-custom-block-info-border: var(--htl-c-blue-dimm-1);
|
322
|
+
--htl-custom-block-info-text: var(--htl-c-blue-darker);
|
323
|
+
--htl-custom-block-info-bg: var(--htl-c-blue-dimm-3);
|
324
|
+
--htl-custom-block-info-code-bg: var(--htl-custom-block-info-bg);
|
320
325
|
|
321
326
|
--htl-custom-block-tip-border: var(--htl-c-green-dimm-1);
|
322
327
|
--htl-custom-block-tip-text: var(--htl-c-green-darker);
|
@@ -345,6 +350,13 @@
|
|
345
350
|
--htl-custom-block-details-bg: var(--htl-c-black-mute);
|
346
351
|
--htl-custom-block-details-code-bg: var(--htl-c-gray-dark-4);
|
347
352
|
|
353
|
+
--htl-custom-block-important-border: var(--htl-c-indigo-lighter);
|
354
|
+
--htl-custom-block-important-bg: var(--htl-c-indigo-dark);
|
355
|
+
--htl-custom-block-important-text: var(--htl-c-indigo-lighter);
|
356
|
+
|
357
|
+
--htl-custom-block-info-text: var(--htl-c-blue);
|
358
|
+
--htl-custom-block-info-bg: var(--htl-c-blue-dimm-3);
|
359
|
+
|
348
360
|
--htl-custom-block-tip-border: var(--htl-c-green-dimm-2);
|
349
361
|
--htl-custom-block-tip-text: var(--htl-c-green-light);
|
350
362
|
|