hdoc-tools 0.17.19 → 0.17.21
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-build.js +11 -2
- package/hdoc-module.js +13 -3
- package/hdoc-validate.js +21 -16
- package/package.json +1 -1
package/hdoc-build.js
CHANGED
@@ -923,8 +923,17 @@
|
|
923
923
|
}
|
924
924
|
}
|
925
925
|
console.log(`Processing navigation breadcrumbs...`);
|
926
|
-
|
927
|
-
|
926
|
+
const bc_build = hdoc.build_breadcrumbs(hdocbook_config.navigation.items);
|
927
|
+
if (bc_build.errors.length > 0) {
|
928
|
+
console.log('\r\n-----------------------');
|
929
|
+
console.log(' Validation Output ');
|
930
|
+
console.log('-----------------------');
|
931
|
+
console.log(`\n${bc_build.errors.length} errors found when processing navigation:\n`);
|
932
|
+
console.log(` - ${bc_build.errors.join('\n\n - ')}`);
|
933
|
+
console.log('\n');
|
934
|
+
process.exit(1);
|
935
|
+
}
|
936
|
+
bc = bc_build.bc;
|
928
937
|
console.log(`Processing content...`);
|
929
938
|
// Get a list of MD files in work_path
|
930
939
|
dree.scan(work_path, dreeOptions, build_file_callback);
|
package/hdoc-module.js
CHANGED
@@ -424,7 +424,10 @@
|
|
424
424
|
};
|
425
425
|
|
426
426
|
exports.build_breadcrumbs = function (nav_items) {
|
427
|
-
|
427
|
+
let response = {
|
428
|
+
bc: {},
|
429
|
+
errors: []
|
430
|
+
};
|
428
431
|
const buildBreadcrumb = (items, parentLinks) => {
|
429
432
|
|
430
433
|
// Process parent links
|
@@ -441,6 +444,13 @@
|
|
441
444
|
|
442
445
|
// Loop through items, build breadcrumb
|
443
446
|
for (let i = 0; i < items.length; i++) {
|
447
|
+
if (!items[i].text) {
|
448
|
+
response.errors.push(`The following Nav Item is missing its text property: ${JSON.stringify(items[i])}`);
|
449
|
+
}
|
450
|
+
|
451
|
+
if (!items[i].link && !items[i].items) {
|
452
|
+
response.errors.push(`The following Nav Item is missing has no link or items property: ${JSON.stringify(items[i])}`);
|
453
|
+
}
|
444
454
|
const item = items[i];
|
445
455
|
if (!parentlink && item.link) {
|
446
456
|
parentLinks[0].link = item.link;
|
@@ -450,7 +460,7 @@
|
|
450
460
|
const breadcrumb = [...parentLinks, { text, link }];
|
451
461
|
|
452
462
|
if (link) {
|
453
|
-
bc[link] = breadcrumb;
|
463
|
+
response.bc[link] = breadcrumb;
|
454
464
|
}
|
455
465
|
|
456
466
|
if (subItems) {
|
@@ -460,7 +470,7 @@
|
|
460
470
|
};
|
461
471
|
|
462
472
|
buildBreadcrumb(nav_items, []);
|
463
|
-
return
|
473
|
+
return response;
|
464
474
|
};
|
465
475
|
|
466
476
|
exports.load_product_families = async function () {
|
package/hdoc-validate.js
CHANGED
@@ -268,24 +268,29 @@
|
|
268
268
|
const checkRedirects = async function (source_path) {
|
269
269
|
let errors = [];
|
270
270
|
for (const key in redirects) {
|
271
|
-
if (redirects.hasOwnProperty(key)
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
271
|
+
if (redirects.hasOwnProperty(key)) {
|
272
|
+
if (redirects[key].code !== 301 && redirects[key].code !== 308 && redirects[key].code !== 410 )
|
273
|
+
errors.push(`Invalid redirect code: ${redirects[key].code}`);
|
274
|
+
|
275
|
+
if (redirects[key].location) {
|
276
|
+
let redir_locations = [
|
277
|
+
path.join(source_path, redirects[key].location + '.md'),
|
278
|
+
path.join(source_path, redirects[key].location, 'index.md'),
|
279
|
+
path.join(source_path, redirects[key].location + '.html'),
|
280
|
+
path.join(source_path, redirects[key].location + '.htm'),
|
281
|
+
path.join(source_path, redirects[key].location, 'index.html'),
|
282
|
+
path.join(source_path, redirects[key].location, 'index.htm')
|
283
|
+
];
|
284
|
+
let redir_location_ok = false;
|
285
|
+
for (let i = 0; i < redir_locations.length; i++) {
|
286
|
+
if (fs.existsSync(redir_locations[i])) {
|
287
|
+
redir_location_ok = true;
|
288
|
+
break;
|
289
|
+
}
|
285
290
|
}
|
291
|
+
if (!redir_location_ok)
|
292
|
+
errors.push(`Redirect location does not exist: ${redirects[key].location}`);
|
286
293
|
}
|
287
|
-
if (!redir_location_ok)
|
288
|
-
errors.push(`Redirect location does not exist: ${redirects[key].location}`);
|
289
294
|
}
|
290
295
|
}
|
291
296
|
return errors;
|