hdoc-tools 0.9.55 → 0.10.0
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/hdoc-validate.js
CHANGED
@@ -27,7 +27,8 @@
|
|
27
27
|
md_to_validate = [],
|
28
28
|
exclude_links = {},
|
29
29
|
exclude_spellcheck = {},
|
30
|
-
exclude_h1_count = {}
|
30
|
+
exclude_h1_count = {},
|
31
|
+
exclude_spellcheck_output = [];
|
31
32
|
|
32
33
|
const excludeLink = async function (url) {
|
33
34
|
if (exclude_links[url]) return true;
|
@@ -69,16 +70,22 @@
|
|
69
70
|
}
|
70
71
|
}
|
71
72
|
if (Object.keys(spelling_errors).length) {
|
73
|
+
let exclude_output = {
|
74
|
+
document_path: sourceFile.relativePath.replace(path.extname(sourceFile.relativePath), ''),
|
75
|
+
words: []
|
76
|
+
};
|
72
77
|
for (const word in spelling_errors) {
|
73
78
|
if (spelling_errors.hasOwnProperty(word)) {
|
74
79
|
words.push(word);
|
80
|
+
exclude_output.words.push(word);
|
75
81
|
}
|
76
82
|
}
|
83
|
+
exclude_spellcheck_output.push(exclude_output);
|
77
84
|
}
|
78
85
|
return words;
|
79
86
|
};
|
80
87
|
|
81
|
-
const checkNavigation = async function (source_path, flat_nav) {
|
88
|
+
const checkNavigation = async function (source_path, flat_nav, excludes) {
|
82
89
|
let nav_errors = [];
|
83
90
|
for (let key in flat_nav) {
|
84
91
|
if (flat_nav.hasOwnProperty(key)) {
|
@@ -126,7 +133,11 @@
|
|
126
133
|
if (translate_output.hasOwnProperty(spell_val)) {
|
127
134
|
for (const spelling in translate_output[spell_val][0]) {
|
128
135
|
if (translate_output[spell_val][0].hasOwnProperty(spelling)) {
|
129
|
-
|
136
|
+
if (!excludes[key]) {
|
137
|
+
nav_errors.push(`Navigation path [${key}] key contains a British English spelling: ${spelling} should be ${translate_output[spell_val][0][spelling].details}`);
|
138
|
+
} else if (!excludes[key].includes(spelling.toLowerCase())) {
|
139
|
+
nav_errors.push(`Navigation path [${key}] key contains a British English spelling: ${spelling} should be ${translate_output[spell_val][0][spelling].details}`);
|
140
|
+
}
|
130
141
|
}
|
131
142
|
}
|
132
143
|
}
|
@@ -145,7 +156,11 @@
|
|
145
156
|
for (let j = 0; j < translate_output[spell_val].length; j++) {
|
146
157
|
for (const spelling in translate_output[spell_val][j]) {
|
147
158
|
if (translate_output[spell_val][j].hasOwnProperty(spelling)) {
|
148
|
-
|
159
|
+
if (!excludes[key]) {
|
160
|
+
nav_errors.push(`Navigation path [${key}] display text contains a British English spelling: ${spelling} should be ${translate_output[spell_val][j][spelling].details}`);
|
161
|
+
} else if (!excludes[key].includes(spelling.toLowerCase())) {
|
162
|
+
nav_errors.push(`Navigation path [${key}] display text contains a British English spelling: ${spelling} should be ${translate_output[spell_val][j][spelling].details}`);
|
163
|
+
}
|
149
164
|
}
|
150
165
|
}
|
151
166
|
}
|
@@ -384,28 +399,13 @@
|
|
384
399
|
// Check URL exists
|
385
400
|
if (!hdocbook_config.publicSource.startsWith('https://github.com') && !hdocbook_config.publicSource.startsWith('https://api.github.com')) {
|
386
401
|
meta_errors.push(`Value for publicSource in book metadata is not a recognised GitHub URL: ${hdocbook_config.publicSource}`);
|
387
|
-
} else {
|
388
|
-
//
|
389
402
|
}
|
390
403
|
}
|
391
|
-
|
392
404
|
}
|
393
405
|
|
394
|
-
|
395
|
-
|
396
|
-
if (nav_errors.length > 0) meta_errors.push(...nav_errors);
|
397
|
-
|
398
|
-
if (meta_errors.length > 0) {
|
399
|
-
console.log('\r\n-----------------------');
|
400
|
-
console.log(' Validation Output ');
|
401
|
-
console.log('-----------------------');
|
402
|
-
for (let i = 0; i < meta_errors.length; i++) {
|
403
|
-
console.log(`- ${meta_errors[i]}`);
|
404
|
-
}
|
405
|
-
console.log(`\r\n${meta_errors.length} Validation Errors Found`);
|
406
|
-
return false;
|
406
|
+
if (!hdocbook_config.audience || !(hdocbook_config.audience instanceof Array) || hdocbook_config.audience.length === 0) {
|
407
|
+
meta_errors.push(`Property audience of type array in book metadata is mandatory.`);
|
407
408
|
}
|
408
|
-
|
409
409
|
if (hdocbook_project.validation) {
|
410
410
|
if (hdocbook_project.validation.exclude_links && hdocbook_project.validation.exclude_links instanceof Array) {
|
411
411
|
hdocbook_project.validation.exclude_links.forEach(function (excl_link) {
|
@@ -424,6 +424,22 @@
|
|
424
424
|
}
|
425
425
|
}
|
426
426
|
|
427
|
+
// Check navigation spellings
|
428
|
+
const nav_errors = await checkNavigation(source_path, nav_items, exclude_spellcheck);
|
429
|
+
if (nav_errors.length > 0) meta_errors.push(...nav_errors);
|
430
|
+
|
431
|
+
if (meta_errors.length > 0) {
|
432
|
+
console.log('\r\n-----------------------');
|
433
|
+
console.log(' Validation Output ');
|
434
|
+
console.log('-----------------------');
|
435
|
+
for (let i = 0; i < meta_errors.length; i++) {
|
436
|
+
console.log(`- ${meta_errors[i]}`);
|
437
|
+
}
|
438
|
+
console.log(`\r\n${meta_errors.length} Validation Errors Found`);
|
439
|
+
return false;
|
440
|
+
}
|
441
|
+
|
442
|
+
|
427
443
|
let excl_output = [];
|
428
444
|
|
429
445
|
// Do spellchecking on markdown files
|
@@ -519,6 +535,10 @@
|
|
519
535
|
}
|
520
536
|
if (error_count > 0) {
|
521
537
|
console.log(`\r\n${error_count} Validation Errors Found`);
|
538
|
+
if (verbose) {
|
539
|
+
console.log(`\n`);
|
540
|
+
console.log(JSON.stringify(exclude_spellcheck_output, null, 2));
|
541
|
+
}
|
522
542
|
return false;
|
523
543
|
}
|
524
544
|
}
|
package/package.json
CHANGED
@@ -64,7 +64,11 @@
|
|
64
64
|
/* eof nav tabs in doc content */
|
65
65
|
|
66
66
|
|
67
|
-
|
67
|
+
.DocContent .code-badge-pre
|
68
|
+
{
|
69
|
+
max-width: 100%!important;
|
70
|
+
min-width: 100%!important;
|
71
|
+
}
|
68
72
|
|
69
73
|
@media (min-width: 1000px) {
|
70
74
|
|
@@ -117,3 +121,4 @@
|
|
117
121
|
width:100%;
|
118
122
|
display:table;
|
119
123
|
}
|
124
|
+
|
@@ -723,4 +723,19 @@
|
|
723
723
|
content: "/";
|
724
724
|
padding-left: 5px;
|
725
725
|
padding-right: 5px;
|
726
|
-
}
|
726
|
+
}
|
727
|
+
|
728
|
+
|
729
|
+
|
730
|
+
/* lighter bg for code blocks */
|
731
|
+
.HTL-doc .hljs
|
732
|
+
{
|
733
|
+
background: #494949;
|
734
|
+
width: 100%;
|
735
|
+
}
|
736
|
+
|
737
|
+
.dark .HTL-doc .hljs
|
738
|
+
{
|
739
|
+
background: #000000;
|
740
|
+
width: 100%;
|
741
|
+
}
|
package/ui/js/doc.hornbill.js
CHANGED
@@ -642,6 +642,7 @@ async function intialiseApp() {
|
|
642
642
|
|
643
643
|
|
644
644
|
//-- get session info
|
645
|
+
/*
|
645
646
|
let dummyResponse = {
|
646
647
|
"type": "user",
|
647
648
|
"userId": "doom-guy",
|
@@ -653,6 +654,7 @@ async function intialiseApp() {
|
|
653
654
|
"validUntil": "2023-07-30 06:33:49Z"
|
654
655
|
}
|
655
656
|
dummyResponse.expiresDateTime = new Date(dummyResponse.validUntil).toLocaleDateString() + ' ' + new Date(dummyResponse.validUntil).toLocaleTimeString();
|
657
|
+
*/
|
656
658
|
|
657
659
|
fetchJsonFile("_api/session/").then(function(sessionData)
|
658
660
|
{
|
@@ -665,6 +667,7 @@ async function intialiseApp() {
|
|
665
667
|
view.setSessionInfo(sessionData);
|
666
668
|
}
|
667
669
|
});
|
670
|
+
|
668
671
|
//-- eof session stuff
|
669
672
|
|
670
673
|
await fetchJsonFile("_books/library.json").then(function(data){
|