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 CHANGED
@@ -923,8 +923,17 @@
923
923
  }
924
924
  }
925
925
  console.log(`Processing navigation breadcrumbs...`);
926
- bc = hdoc.build_breadcrumbs(hdocbook_config.navigation.items);
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
- const bc = {};
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 bc;
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) && redirects[key].location) {
272
- let redir_locations = [
273
- path.join(source_path, redirects[key].location + '.md'),
274
- path.join(source_path, redirects[key].location, 'index.md'),
275
- path.join(source_path, redirects[key].location + '.html'),
276
- path.join(source_path, redirects[key].location + '.htm'),
277
- path.join(source_path, redirects[key].location, 'index.html'),
278
- path.join(source_path, redirects[key].location, 'index.htm')
279
- ];
280
- let redir_location_ok = false;
281
- for (let i = 0; i < redir_locations.length; i++) {
282
- if (fs.existsSync(redir_locations[i])) {
283
- redir_location_ok = true;
284
- break;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hdoc-tools",
3
- "version": "0.17.19",
3
+ "version": "0.17.21",
4
4
  "description": "Hornbill HDocBook Development Support Tool",
5
5
  "main": "hdoc.js",
6
6
  "bin": {