hdoc-tools 0.9.56 → 0.11.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-help.js CHANGED
@@ -1,10 +1,10 @@
1
1
  (function () {
2
- 'use strict';
2
+ 'use strict';
3
3
 
4
- exports.run = function() {
5
-
6
- // STEVE: The purpose of this function is to output information about hdoc arguments
7
- const helpText = `
4
+ exports.run = function () {
5
+
6
+ // STEVE: The purpose of this function is to output information about hdoc arguments
7
+ const helpText = `
8
8
  Command Line Usage
9
9
 
10
10
  hdoc <command> [switches]
@@ -32,10 +32,16 @@ Commands
32
32
  - validate
33
33
  Validates the book content
34
34
 
35
+ - bump
36
+ Updates the semantic version number of the current book. If no options are specified, then the default of patch is applied:
37
+ - major - updates the major version of the book. i.e. - 1.4.5 would become 2.0.0
38
+ - minor - updates the minor version of the book. i.e. - 1.4.5 would become 1.5.0
39
+ - patch (default) - updates the patch version of the book. i.e. - 1.4.5 would become 1.4.6
40
+
35
41
  Example
36
42
 
37
43
  hdoc stats -v
38
44
  `;
39
- console.log(helpText);
40
- };
45
+ console.log(helpText);
46
+ };
41
47
  })();
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
- nav_errors.push(`Navigation path [${key}] key contains a British English spelling: ${spelling} should be ${translate_output[spell_val][0][spelling].details}`);
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
- nav_errors.push(`Navigation path [${key}] display text contains a British English spelling: ${spelling} should be ${translate_output[spell_val][j][spelling].details}`);
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
  }
@@ -391,22 +406,6 @@
391
406
  if (!hdocbook_config.audience || !(hdocbook_config.audience instanceof Array) || hdocbook_config.audience.length === 0) {
392
407
  meta_errors.push(`Property audience of type array in book metadata is mandatory.`);
393
408
  }
394
-
395
- // Check navigation spellings
396
- const nav_errors = await checkNavigation(source_path, nav_items);
397
- if (nav_errors.length > 0) meta_errors.push(...nav_errors);
398
-
399
- if (meta_errors.length > 0) {
400
- console.log('\r\n-----------------------');
401
- console.log(' Validation Output ');
402
- console.log('-----------------------');
403
- for (let i = 0; i < meta_errors.length; i++) {
404
- console.log(`- ${meta_errors[i]}`);
405
- }
406
- console.log(`\r\n${meta_errors.length} Validation Errors Found`);
407
- return false;
408
- }
409
-
410
409
  if (hdocbook_project.validation) {
411
410
  if (hdocbook_project.validation.exclude_links && hdocbook_project.validation.exclude_links instanceof Array) {
412
411
  hdocbook_project.validation.exclude_links.forEach(function (excl_link) {
@@ -425,6 +424,22 @@
425
424
  }
426
425
  }
427
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
+
428
443
  let excl_output = [];
429
444
 
430
445
  // Do spellchecking on markdown files
@@ -520,6 +535,10 @@
520
535
  }
521
536
  if (error_count > 0) {
522
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
+ }
523
542
  return false;
524
543
  }
525
544
  }
package/hdoc.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  (async function () {
3
3
  'use strict';
4
4
 
@@ -25,11 +25,12 @@
25
25
  // Default source path to working directory
26
26
  let source_path = process.cwd();
27
27
  let ui_path = path.join(__dirname, 'ui');
28
- let git_token = '',
29
- command = '', // Our command to run
30
- build_version = '',
31
- verbose = false,
32
- gen_exclude = false; // To generate spellcheck exclusions for all files
28
+ let git_token = '',
29
+ command = '', // Our command to run
30
+ build_version = '',
31
+ verbose = false,
32
+ gen_exclude = false,
33
+ bump_type = 'patch'; // To generate spellcheck exclusions for all files
33
34
 
34
35
  // Get options from command args
35
36
  for (let x = 0; x < process.argv.length; x++) {
@@ -39,6 +40,13 @@
39
40
  // Third argument is command
40
41
  if (x == 2) {
41
42
  command = process.argv[x];
43
+
44
+ if (command === 'bump') {
45
+ x++;
46
+ if (x < process.argv.length) {
47
+ bump_type = process.argv[x];
48
+ }
49
+ }
42
50
  continue;
43
51
  }
44
52
 
@@ -95,6 +103,9 @@
95
103
  } else if (command == 'help') {
96
104
  const help = require(path.join(__dirname, 'hdoc-help.js'));
97
105
  help.run();
106
+ } else if (command == 'bump') {
107
+ const bump = require(path.join(__dirname, 'hdoc-bump.js'));
108
+ bump.run(source_path, bump_type);
98
109
  } else {
99
110
  console.log('Unknown command:', command, '\r\n');
100
111
  console.log('Run hdoc help for information regarding this tool.\r\n');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hdoc-tools",
3
- "version": "0.9.56",
3
+ "version": "0.11.0",
4
4
  "description": "Hornbill HDocBook Development Support Tool",
5
5
  "main": "hdoc.js",
6
6
  "bin": {
@@ -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
+ }
@@ -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){