hdoc-tools 0.9.14 → 0.9.16
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/LICENSE +21 -0
- package/README.md +7 -5
- package/hdoc-build.js +12 -2
- package/hdoc-help.js +2 -2
- package/hdoc-validate.js +11 -2
- package/hdoc.js +11 -5
- package/package.json +1 -1
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2022 Hornbill Docs
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
@@ -35,26 +35,28 @@ Returns statistics regarding the book you are working on:
|
|
35
35
|
- Number of Markdown Files in the Book
|
36
36
|
- Number of Static HTML Files in the Book
|
37
37
|
|
38
|
-
If the -v switch is provided, then
|
38
|
+
If the -v switch is provided, then more verbose output is output, which includes a list of each MD and HTML file found, the file sizes, and file-specific word count.
|
39
39
|
|
40
40
|
### build
|
41
41
|
|
42
|
-
Performs a local build of the book, validates the links and static content are present and correct
|
42
|
+
Performs a local build of the book, validates the links and static content are present and correct and outputs as a ZIP file.
|
43
43
|
|
44
|
-
If the -v switch is provided, then
|
44
|
+
If the -v switch is provided, then more verbose output is provided, which includes a list of all HTML files created and checked for embedded links and static content.
|
45
45
|
|
46
46
|
### build
|
47
47
|
|
48
48
|
Performs a minimum local build of the book, then validates the links and static content are present and correct.
|
49
49
|
|
50
|
-
If the -v switch is provided, then
|
50
|
+
If the -v switch is provided, then more verbose output is provided, which includes a list of all HTML files created and checked for embedded links and static content.
|
51
|
+
|
52
|
+
Use the --set-version argument to set the version number of the built book.
|
51
53
|
|
52
54
|
### serve
|
53
55
|
|
54
56
|
Starts a local web server on port 3000, serving the book content.
|
55
57
|
|
56
58
|
To preview the documentation in a browser, you can open a terminal window and run the dev preview server with the
|
57
|
-
command `hdoc serve` and in a local browser go to the
|
59
|
+
command `hdoc serve` and in a local browser go to the URL `http://localhost:3000`
|
58
60
|
|
59
61
|
## Installation
|
60
62
|
|
package/hdoc-build.js
CHANGED
@@ -22,7 +22,8 @@
|
|
22
22
|
pdf_header_template_path = path.join(__dirname, 'templates', 'pdf-header.html'),
|
23
23
|
non_git_pdf_header_template_path = path.join(__dirname, 'templates', 'pdf-header-non-git.html'),
|
24
24
|
pdf_template_path = path.join(__dirname, 'templates', 'pdf'),
|
25
|
-
pdf_template_file_path = path.join(pdf_template_path, 'template.html')
|
25
|
+
pdf_template_file_path = path.join(pdf_template_path, 'template.html'),
|
26
|
+
regex_version = /^[0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}$/;
|
26
27
|
|
27
28
|
let bc = {}, // Breadcrumbs map
|
28
29
|
book_read_time = 0,
|
@@ -565,7 +566,7 @@
|
|
565
566
|
sorted: true
|
566
567
|
};
|
567
568
|
|
568
|
-
exports.run = async function (source_path, verbose_output, github_api_token, validate) {
|
569
|
+
exports.run = async function (source_path, verbose_output, github_api_token, validate, build_version = '') {
|
569
570
|
if (github_api_token !== '') {
|
570
571
|
git_token = github_api_token;
|
571
572
|
}
|
@@ -607,6 +608,15 @@
|
|
607
608
|
work_hdocbook_path = path.join(work_path, doc_id, 'hdocbook.json');
|
608
609
|
|
609
610
|
hdocbook_config = require(hdocbook_path);
|
611
|
+
if (build_version !== '') {
|
612
|
+
hdocbook_config.version = build_version;
|
613
|
+
}
|
614
|
+
|
615
|
+
if (!hdocbook_config.version.match(regex_version)) {
|
616
|
+
console.log(`ERROR: Version number does not match required format - ${hdocbook_config.version}\n`);
|
617
|
+
process.exit(1);
|
618
|
+
}
|
619
|
+
|
610
620
|
if (hdocbook_config.publicSource.endsWith('.git')) hdocbook_config.publicSource = hdocbook_config.publicSource.substring(0, hdocbook_config.publicSource.length - 4);
|
611
621
|
|
612
622
|
console.log(`Building: ${doc_id} v${hdocbook_config.version}...\n`);
|
package/hdoc-help.js
CHANGED
@@ -12,7 +12,7 @@ Command Line Usage
|
|
12
12
|
Commands
|
13
13
|
|
14
14
|
- build
|
15
|
-
Performs a local build of the book, and outputs as a ZIP file
|
15
|
+
Performs a local build of the book, and outputs as a ZIP file. Use non-mandatory argument '--set-version 1.2.3' to set the version number of the built book
|
16
16
|
|
17
17
|
- createDocs
|
18
18
|
Creates folder structure and markdown documents as defined in the HDocBook navigation item links
|
@@ -23,7 +23,7 @@ Commands
|
|
23
23
|
- init
|
24
24
|
Initializes a new HDocBook project from a template, using runtime input variables
|
25
25
|
|
26
|
-
- serve
|
26
|
+
- serve
|
27
27
|
Starts a local web server on port 3000, serving the content. Supports a -port N to use a different port
|
28
28
|
|
29
29
|
- stats
|
package/hdoc-validate.js
CHANGED
@@ -19,7 +19,8 @@
|
|
19
19
|
},
|
20
20
|
regex_nav_paths = /[a-z0-9-\/]+/g;
|
21
21
|
|
22
|
-
let prod_families = {}
|
22
|
+
let prod_families = {},
|
23
|
+
prods_supported = [];
|
23
24
|
|
24
25
|
let errors = {},
|
25
26
|
messages = {},
|
@@ -35,6 +36,9 @@
|
|
35
36
|
const prods = await axios.get('https://docs.hornbill.com/_books/products.json', { httpsAgent: agent });
|
36
37
|
if (prods.status === 200) {
|
37
38
|
prod_families = prods.data;
|
39
|
+
for (let i = 0; i < prod_families.products.length; i++) {
|
40
|
+
prods_supported.push(prod_families.products[i].id);
|
41
|
+
}
|
38
42
|
} else {
|
39
43
|
throw `Unexpected Status ${prods.status}`;
|
40
44
|
}
|
@@ -323,7 +327,12 @@
|
|
323
327
|
}
|
324
328
|
}
|
325
329
|
if (!valid_product) {
|
326
|
-
|
330
|
+
let val_prod_error = `Incorrect productFamily: ${hdocbook_config.productFamily}. Supported values:`;
|
331
|
+
for (let i = 0; i < prods_supported.length; i++) {
|
332
|
+
val_prod_error += `\n - ${prods_supported[i]}`
|
333
|
+
}
|
334
|
+
meta_errors.push(val_prod_error)
|
335
|
+
|
327
336
|
}
|
328
337
|
|
329
338
|
// Check navigation spellings
|
package/hdoc.js
CHANGED
@@ -24,9 +24,10 @@
|
|
24
24
|
// Default source path to working directory
|
25
25
|
let source_path = process.cwd();
|
26
26
|
let ui_path = path.join(__dirname, 'ui');
|
27
|
-
let
|
28
|
-
|
29
|
-
|
27
|
+
let git_token = '',
|
28
|
+
command = '', // Our command to run
|
29
|
+
build_version = '',
|
30
|
+
verbose = false;
|
30
31
|
|
31
32
|
// Get options from command args
|
32
33
|
for (let x = 0; x < process.argv.length; x++) {
|
@@ -51,11 +52,16 @@
|
|
51
52
|
if (x < process.argv.length) {
|
52
53
|
ui_path = process.argv[x];
|
53
54
|
}
|
54
|
-
} else if (process.argv[x] == '
|
55
|
+
} else if (process.argv[x] == '--git-token') {
|
55
56
|
x++;
|
56
57
|
if (x < process.argv.length) {
|
57
58
|
git_token = process.argv[x];
|
58
59
|
}
|
60
|
+
} else if (process.argv[x] == '--set-version') {
|
61
|
+
x++;
|
62
|
+
if (x < process.argv.length) {
|
63
|
+
build_version = process.argv[x];
|
64
|
+
}
|
59
65
|
}
|
60
66
|
}
|
61
67
|
|
@@ -68,7 +74,7 @@
|
|
68
74
|
server.run(ui_path, source_path);
|
69
75
|
} else if (command == 'build') {
|
70
76
|
const builder = require(path.join(__dirname, 'hdoc-build.js'));
|
71
|
-
await builder.run(source_path, verbose, git_token, false);
|
77
|
+
await builder.run(source_path, verbose, git_token, false, build_version);
|
72
78
|
} else if (command == 'createDocs') {
|
73
79
|
const creator = require(path.join(__dirname, 'hdoc-create.js'));
|
74
80
|
await creator.run(source_path);
|