hdoc-tools 0.9.54 → 0.9.55
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 +4 -4
- package/hdoc-module.js +9 -6
- package/hdoc-stats.js +17 -17
- package/hdoc-validate.js +1 -1
- package/package.json +1 -1
package/hdoc-build.js
CHANGED
@@ -203,7 +203,7 @@
|
|
203
203
|
delete contributors.success;
|
204
204
|
delete contributors.error;
|
205
205
|
contributors.editPath = github_paths.edit_path;
|
206
|
-
|
206
|
+
|
207
207
|
}
|
208
208
|
fm_headers.push({
|
209
209
|
id: 'edit-path',
|
@@ -225,7 +225,7 @@
|
|
225
225
|
|
226
226
|
let doc_header = '';
|
227
227
|
let pdf_header = '';
|
228
|
-
if (hdocbook_config.publicSource.includes('github.com/Hornbill-Docs')) {
|
228
|
+
if (hdocbook_config.publicSource && hdocbook_config.publicSource.includes('github.com/Hornbill-Docs')) {
|
229
229
|
// Build doc header from template and frontmatter tags
|
230
230
|
doc_header = process_doc_header(fm_headers, file_path.relativePath, doc_header_template);
|
231
231
|
if (pdf_enable && !pdf_path_excluded(file_path.relativePath)) pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template);
|
@@ -435,7 +435,7 @@
|
|
435
435
|
|
436
436
|
let doc_header = '';
|
437
437
|
let pdf_header = '';
|
438
|
-
if (hdocbook_config.publicSource.includes('github.com/Hornbill-Docs')) {
|
438
|
+
if (hdocbook_config.publicSource && hdocbook_config.publicSource.includes('github.com/Hornbill-Docs')) {
|
439
439
|
// Build doc header from template and frontmatter tags
|
440
440
|
doc_header = process_doc_header(fm_headers, file_path.relativePath, doc_header_template);
|
441
441
|
if (pdf_enable && !pdf_path_excluded(file_path.relativePath)) pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template);
|
@@ -629,7 +629,7 @@
|
|
629
629
|
process.exit(1);
|
630
630
|
}
|
631
631
|
|
632
|
-
if (hdocbook_config.publicSource.endsWith('.git')) hdocbook_config.publicSource = hdocbook_config.publicSource.substring(0, hdocbook_config.publicSource.length - 4);
|
632
|
+
if (hdocbook_config.publicSource && hdocbook_config.publicSource.endsWith('.git')) hdocbook_config.publicSource = hdocbook_config.publicSource.substring(0, hdocbook_config.publicSource.length - 4);
|
633
633
|
|
634
634
|
console.log(`Loading product families...`);
|
635
635
|
const prods = await hdoc.load_product_families();
|
package/hdoc-module.js
CHANGED
@@ -222,12 +222,15 @@
|
|
222
222
|
};
|
223
223
|
|
224
224
|
exports.get_github_api_path = function (repo, relative_path) {
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
225
|
+
if (repo) {
|
226
|
+
repo = repo.endsWith('/') ? repo.slice(0, -1) : repo;
|
227
|
+
let github_paths = {};
|
228
|
+
github_paths.api_path = repo.replace('https://github.com/', 'https://api.github.com/repos/');
|
229
|
+
github_paths.api_path += '/commits?path=/' + relative_path.replace('\\\\', '/').replace('\\', '/');
|
230
|
+
github_paths.edit_path = repo + '/blob/main/' + relative_path.replace('\\\\', '/').replace('\\', '/');
|
231
|
+
return github_paths;
|
232
|
+
}
|
233
|
+
return '';
|
231
234
|
};
|
232
235
|
|
233
236
|
exports.get_github_contributors = async function (github_url, github_api_token) {
|
package/hdoc-stats.js
CHANGED
@@ -1,31 +1,31 @@
|
|
1
1
|
|
2
2
|
(function () {
|
3
3
|
'use strict';
|
4
|
-
|
4
|
+
|
5
5
|
// Required modules
|
6
6
|
// /const { STATUS_CODES } = require('http');
|
7
7
|
const fs = require('fs'),
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
path = require('path'),
|
9
|
+
dree = require('dree'),
|
10
|
+
html2text = require('html-to-text'),
|
11
|
+
wordsCount = require('words-count').default;
|
12
|
+
|
13
13
|
// Regex to remove Hornbill-specific tags
|
14
14
|
const hbMDTagRegex = /(:{3}[ ]note)|(:{3}[ ]tip)|(:{3}[ ]important)|(:{3}[ ]caution)|(:{3}[ ]warning)|(:{3})/g;
|
15
|
-
|
15
|
+
|
16
16
|
let stats = {
|
17
17
|
totalMDFiles: 0,
|
18
18
|
totalStaticHTMLFiles: 0,
|
19
19
|
totalWordCount: 0,
|
20
20
|
mdFiles: {},
|
21
|
-
staticHTMLFiles: {}
|
21
|
+
staticHTMLFiles: {}
|
22
22
|
};
|
23
23
|
|
24
24
|
let markdownFiles = [];
|
25
25
|
|
26
26
|
// File callback for scan
|
27
|
-
const fileCallback = function(element) {
|
28
|
-
if (element.extension === 'md'
|
27
|
+
const fileCallback = function (element) {
|
28
|
+
if (element.extension === 'md') {
|
29
29
|
markdownFiles.push(element);
|
30
30
|
stats.totalMDFiles++;
|
31
31
|
} else {
|
@@ -51,7 +51,7 @@
|
|
51
51
|
const dreeOptions = {
|
52
52
|
descendants: true,
|
53
53
|
depth: 10,
|
54
|
-
extensions: ['md','html','htm'],
|
54
|
+
extensions: ['md', 'html', 'htm'],
|
55
55
|
hash: false,
|
56
56
|
normalize: true,
|
57
57
|
size: true,
|
@@ -60,8 +60,8 @@
|
|
60
60
|
symbolicLinks: false
|
61
61
|
};
|
62
62
|
|
63
|
-
exports.run = function(ui_path, source_path, verbose = false) {
|
64
|
-
|
63
|
+
exports.run = function (ui_path, source_path, verbose = false) {
|
64
|
+
|
65
65
|
// GERRY: The stats here are needed to support content development. The idea is to count all of the ]
|
66
66
|
// words in a HDocBook so we know the size of the book, this helps with 3rd party involvement where
|
67
67
|
// we generally need to know the word count of the content in order to get a quote for things like
|
@@ -69,12 +69,12 @@
|
|
69
69
|
//
|
70
70
|
// For each .md file, and for each static .HTML file (that is html files that we have not generated) we
|
71
71
|
// should do a word count, excluding MD or HTML tags
|
72
|
-
|
72
|
+
|
73
73
|
// STEVE: Get the docId (book root) from the hdocbook-project.json
|
74
74
|
// From there, loop through looking for:
|
75
75
|
// * HTML files without a matching MD, and word count those
|
76
76
|
// * MD files, and word count those
|
77
|
-
|
77
|
+
|
78
78
|
|
79
79
|
console.log('Hornbill HDocBook Stats : verbose=' + verbose, '\r\n');
|
80
80
|
|
@@ -112,7 +112,7 @@
|
|
112
112
|
|
113
113
|
// Scan content path directory, send file info to callback for processing
|
114
114
|
dree.scan(bookPath, dreeOptions, fileCallback);
|
115
|
-
markdownFiles.forEach(function(element){
|
115
|
+
markdownFiles.forEach(function (element) {
|
116
116
|
// Load markdown file
|
117
117
|
let md_txt = fs.readFileSync(element.path, 'utf8');
|
118
118
|
|
@@ -120,7 +120,7 @@
|
|
120
120
|
const text = html2text.convert(html_txt, {
|
121
121
|
wordwrap: null
|
122
122
|
});
|
123
|
-
|
123
|
+
|
124
124
|
// Do the wordcount and add to status
|
125
125
|
const wordCount = wordsCount(text);
|
126
126
|
stats.totalWordCount += wordCount;
|
package/hdoc-validate.js
CHANGED
@@ -181,7 +181,7 @@
|
|
181
181
|
messages[htmlFile.relativePath].push(`Link is a properly formatted external URL: ${links[i]}`);
|
182
182
|
|
183
183
|
// Skip if it's the auto-generated edit url, as these could be part of a private repo which would return a 404
|
184
|
-
if (links[i] === hdoc.get_github_api_path(hdocbook_config.publicSource, htmlFile.relativePath).edit_path.replace(path.extname(htmlFile.relativePath), '.md')) {
|
184
|
+
if (hdocbook_config.publicSource !== undefined && links[i] === hdoc.get_github_api_path(hdocbook_config.publicSource, htmlFile.relativePath).edit_path.replace(path.extname(htmlFile.relativePath), '.md')) {
|
185
185
|
continue;
|
186
186
|
}
|
187
187
|
|