hdoc-tools 0.54.0 → 0.55.1
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 +1 -0
- package/hdoc-content-routes.js +41 -0
- package/hdoc-edit.js +2 -12
- package/hdoc-module.js +5 -1
- package/hdoc-serve.js +14 -21
- package/package.json +1 -1
- package/schemas/hdocbook.schema.json +3 -2
package/hdoc-build.js
CHANGED
|
@@ -1176,6 +1176,7 @@
|
|
|
1176
1176
|
);
|
|
1177
1177
|
|
|
1178
1178
|
// Get github repo details
|
|
1179
|
+
console.log(`Fetching GitHub repository details from ${api_path}...`);
|
|
1179
1180
|
github_repo_details = await hdoc.get_github_repo_details( api_path, git_token );
|
|
1180
1181
|
if (!github_repo_details.success) {
|
|
1181
1182
|
if (git_token === "") {
|
package/hdoc-content-routes.js
CHANGED
|
@@ -33,6 +33,47 @@ function escape_html(str) {
|
|
|
33
33
|
.replace(/>/g, ">");
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
// Recursively walk <source_path>/<docId>/_inline building the nav fragment
|
|
37
|
+
// consumed by the viewer's nav-section-component. Subfolders become
|
|
38
|
+
// expandable container nodes (items, no link); files become leaf links.
|
|
39
|
+
function build_inline_nav_items(dir, docId, rel_prefix) {
|
|
40
|
+
const items = [];
|
|
41
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
42
|
+
if (entry.isDirectory()) {
|
|
43
|
+
items.push({
|
|
44
|
+
text: entry.name,
|
|
45
|
+
expand: false,
|
|
46
|
+
items: build_inline_nav_items(
|
|
47
|
+
path.join(dir, entry.name),
|
|
48
|
+
docId,
|
|
49
|
+
`${rel_prefix}${entry.name}/`,
|
|
50
|
+
),
|
|
51
|
+
});
|
|
52
|
+
} else {
|
|
53
|
+
const name = entry.name.replace(path.extname(entry.name), "");
|
|
54
|
+
items.push({
|
|
55
|
+
text: name,
|
|
56
|
+
link: `${docId}/_inline/${rel_prefix}${name}`,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return items;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Build the top-level "Inline Help Items" nav fragment for a book, or {}
|
|
64
|
+
// if the book has no _inline folder.
|
|
65
|
+
function build_nav_inline(source_path, docId) {
|
|
66
|
+
const inline_path = path.join(source_path, docId, "_inline");
|
|
67
|
+
if (!fs.existsSync(inline_path)) return {};
|
|
68
|
+
return {
|
|
69
|
+
text: "Inline Help Items",
|
|
70
|
+
expand: true,
|
|
71
|
+
inline: true,
|
|
72
|
+
items: build_inline_nav_items(inline_path, docId, ""),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
exports.build_nav_inline = build_nav_inline;
|
|
76
|
+
|
|
36
77
|
// Build a content handler bound to a single book's context.
|
|
37
78
|
//
|
|
38
79
|
// ctx:
|
package/hdoc-edit.js
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
const sha1 = (data) =>
|
|
27
27
|
crypto.createHash("sha1").update(Buffer.from(data)).digest("hex");
|
|
28
|
-
const { create_content_handler } = require(
|
|
28
|
+
const { create_content_handler, build_nav_inline } = require(
|
|
29
29
|
path.join(__dirname, "hdoc-content-routes.js"),
|
|
30
30
|
);
|
|
31
31
|
const { TocModel } = require(path.join(__dirname, "hdoc-toc.js"));
|
|
@@ -184,17 +184,7 @@
|
|
|
184
184
|
);
|
|
185
185
|
|
|
186
186
|
// Inline-help nav fragment, surfaced via /_books/library.json.
|
|
187
|
-
|
|
188
|
-
const inline_path = path.join(sp, id, "_inline");
|
|
189
|
-
if (fs.existsSync(inline_path)) {
|
|
190
|
-
inline = { text: "Inline Help Items", expand: true, inline: true, items: [] };
|
|
191
|
-
for (const file of fs.readdirSync(inline_path)) {
|
|
192
|
-
inline.items.push({
|
|
193
|
-
text: file.replace(path.extname(file), ""),
|
|
194
|
-
link: `${id}/_inline/${file.replace(path.extname(file), "")}`,
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
}
|
|
187
|
+
const inline = build_nav_inline(sp, id);
|
|
198
188
|
|
|
199
189
|
source_path = sp;
|
|
200
190
|
hdocbook_project = proj;
|
package/hdoc-module.js
CHANGED
|
@@ -96,7 +96,11 @@
|
|
|
96
96
|
retryCount++;
|
|
97
97
|
if (retryCount > maxRetries) return response;
|
|
98
98
|
retried = true;
|
|
99
|
-
|
|
99
|
+
const backoff_ms = Math.min(wait_ms, GITHUB_MAX_BACKOFF_MS);
|
|
100
|
+
console.log(
|
|
101
|
+
`GitHub rate limit hit (HTTP ${response.status}) — waiting ${Math.round(backoff_ms / 1000)}s before retry ${retryCount}/${maxRetries}. Provide --git-token <PAT> to raise the limit.`,
|
|
102
|
+
);
|
|
103
|
+
await sleep(backoff_ms);
|
|
100
104
|
continue;
|
|
101
105
|
}
|
|
102
106
|
retryCount++;
|
package/hdoc-serve.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
const fs = require("node:fs");
|
|
5
5
|
const path = require("node:path");
|
|
6
6
|
const hdoc = require(path.join(__dirname, "hdoc-module.js"));
|
|
7
|
-
const { create_content_handler } = require(
|
|
7
|
+
const { create_content_handler, build_nav_inline } = require(
|
|
8
8
|
path.join(__dirname, "hdoc-content-routes.js"),
|
|
9
9
|
);
|
|
10
10
|
|
|
@@ -59,23 +59,7 @@
|
|
|
59
59
|
docId = hdocbook_project.docId;
|
|
60
60
|
|
|
61
61
|
// Get inline content for nav
|
|
62
|
-
const
|
|
63
|
-
let nav_inline = {};
|
|
64
|
-
if (fs.existsSync(inline_path)) {
|
|
65
|
-
const inline_files = fs.readdirSync(inline_path);
|
|
66
|
-
nav_inline = {
|
|
67
|
-
text: "Inline Help Items",
|
|
68
|
-
expand: true,
|
|
69
|
-
inline: true,
|
|
70
|
-
items: [],
|
|
71
|
-
};
|
|
72
|
-
for (const file of inline_files) {
|
|
73
|
-
nav_inline.items.push({
|
|
74
|
-
text: file.replace(path.extname(file), ""),
|
|
75
|
-
link: `${docId}/_inline/${file.replace(path.extname(file), "")}`,
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
}
|
|
62
|
+
const nav_inline = build_nav_inline(source_path, docId);
|
|
79
63
|
// Get an express server instance
|
|
80
64
|
const app = express();
|
|
81
65
|
|
|
@@ -135,10 +119,10 @@
|
|
|
135
119
|
});
|
|
136
120
|
|
|
137
121
|
const server = app.listen(port, "0.0.0.0", () => {
|
|
138
|
-
const
|
|
139
|
-
|
|
122
|
+
const addr = server.address();
|
|
123
|
+
if (!addr) return;
|
|
140
124
|
|
|
141
|
-
console.log("Server listening at http://127.0.0.1:%s", port);
|
|
125
|
+
console.log("Server listening at http://127.0.0.1:%s", addr.port);
|
|
142
126
|
console.log(`Document source path is: ${source_path}`);
|
|
143
127
|
|
|
144
128
|
const _vars = ["{{DOC_ID}}", "{{BUILD_NUMBER}}", "{{BUILD_DATE}}"];
|
|
@@ -148,6 +132,15 @@
|
|
|
148
132
|
console.log(" ", name, " = ", hdoc.expand_variables(name, docId));
|
|
149
133
|
}
|
|
150
134
|
});
|
|
135
|
+
|
|
136
|
+
server.on("error", (err) => {
|
|
137
|
+
if (err.code === "EADDRINUSE") {
|
|
138
|
+
console.error(`\nPort ${port} is already in use. Pick a different port with -port.\n`);
|
|
139
|
+
} else {
|
|
140
|
+
console.error(`\nServer error: ${err}\n`);
|
|
141
|
+
}
|
|
142
|
+
process.exit(1);
|
|
143
|
+
});
|
|
151
144
|
};
|
|
152
145
|
|
|
153
146
|
})();
|
package/package.json
CHANGED
|
@@ -35,17 +35,18 @@
|
|
|
35
35
|
"description": "The ID of the product family this book belongs to.",
|
|
36
36
|
"enum": [
|
|
37
37
|
"esp",
|
|
38
|
-
"com.hornbill.docmanager",
|
|
39
38
|
"com.hornbill.boardmanager",
|
|
40
39
|
"com.hornbill.customermanager",
|
|
40
|
+
"com.hornbill.collaboration",
|
|
41
|
+
"com.hornbill.docmanager",
|
|
41
42
|
"com.hornbill.grc",
|
|
42
43
|
"com.hornbill.itom",
|
|
43
44
|
"com.hornbill.livechat",
|
|
45
|
+
"com.hornbill.pricingcalculator",
|
|
44
46
|
"com.hornbill.projectmanager",
|
|
45
47
|
"com.hornbill.servicemanager",
|
|
46
48
|
"com.hornbill.suppliermanager",
|
|
47
49
|
"com.hornbill.timesheetmanager",
|
|
48
|
-
"com.hornbill.collaboration",
|
|
49
50
|
"appdev",
|
|
50
51
|
"hdocs"
|
|
51
52
|
]
|