hdoc-tools 0.7.15 → 0.7.17

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/README.md CHANGED
@@ -1,9 +1,51 @@
1
- # HDocBook documentation
2
- This is an example of a simple static content documentation project that is compatible with the Hornbill Docs system
1
+ # hdoc-tools
3
2
 
4
- Make sure that you have installed hdoc-tools
3
+ Hornbill HDocBook Development Support Tool.
5
4
 
6
- npm install hdoc-tools -g
5
+ ## Usage
6
+
7
+ <code>hdoc argument switches</code>
8
+
9
+ ## Arguments
10
+
11
+ The arguments available to this command-line tool are as follows.
12
+
13
+ ### help
14
+
15
+ Outputs available arguments and switches.
16
+
17
+ ### init
18
+
19
+ Initializes a new HDocBook project from a template, using runtime input variables.
20
+
21
+ ### stats
22
+
23
+ Returns statistics regarding the book you are working on:
24
+
25
+ - Document ID
26
+ - Version
27
+ - Title
28
+ - Description
29
+ - Public Source
30
+ - Total Book Word Count
31
+ - Number of Markdown Files in the Book
32
+ - Number of Static HTML Files in the Book
33
+
34
+ If the -v switch is provided, then a more verbose output is output, which includes a list of each MD and HTML file found, the file sizes, and file-specific word count.
35
+
36
+ ### build
37
+
38
+ Performs a local build of the book, validates the links and static content are present and correct, and outputs as a ZIP file.
39
+
40
+ If the -v switch is provided, then a more verbose output is provided, which includes a list of all HTML files created and checked for embedded links and static content.
41
+
42
+ ### serve
43
+
44
+ Starts a local web server on port 3000, serving the book content.
7
45
 
8
46
  To preview the documentation in a browser, you can open a terminal window and run the dev preview server with the
9
47
  command `hdoc serve` and in a local browser go to the url `http://localhost:3000`
48
+
49
+ ## Installation
50
+
51
+ npm install hdoc-tools -g
package/hdoc-build.js CHANGED
@@ -14,8 +14,6 @@
14
14
  md_files = [];
15
15
 
16
16
  function expand_variables(text) {
17
- // For debug mode our base path is our root??
18
- text = text.replaceAll('{{BASE_PATH}}', '/' + docId);
19
17
  text = text.replaceAll('{{BUILD_NUMBER}}', '0');
20
18
 
21
19
  let build_date = new Date().toISOString();
@@ -70,7 +68,7 @@
70
68
  // * Create a _work folder
71
69
  // * copy the hdocbook content to the work folder
72
70
  // * Render all markdown into side-by-side HTML file
73
- // * Replace SERVER_VARS embedded in documents with the right base path, version information etc.
71
+ // * Replace SERVER_VARS embedded in documents with the right version information etc.
74
72
  // * Build an index (sqlite FTS5) by extracting text from all HTML content in the work
75
73
  // folder, conceptually we are making a little mini website crawler to index all of the content
76
74
  // within the book.
package/hdoc-serve.js CHANGED
@@ -53,7 +53,7 @@
53
53
  var hdocbook_config = require(hdocbook_path);
54
54
  var hdocbook_mtime = fs.statSync(hdocbook_path).mtime;
55
55
 
56
- app.get('/content/library.json', function (req, res) {
56
+ app.get('/_books/library.json', function (req, res) {
57
57
  let library = {
58
58
  books: [{
59
59
  docId: hdocbook_config.docId,
@@ -112,7 +112,6 @@
112
112
 
113
113
  function expand_variables(text) {
114
114
  // For debug mode our base path is our root??
115
- text = text.replaceAll('{{BASE_PATH}}', '/' + docId);
116
115
  text = text.replaceAll('{{DOC_ID}}', docId);
117
116
  text = text.replaceAll('{{BUILD_NUMBER}}', '0');
118
117
 
@@ -213,13 +212,13 @@
213
212
  //
214
213
  // Anything else in this handler will return a 404 error
215
214
 
216
- app.get('/content/*', function (req, res) {
215
+ app.get('/_books/*', function (req, res) {
217
216
 
218
217
  let url = req.url;
219
218
 
220
219
  let segs = url.split('/');
221
220
 
222
- if (segs.length == 4 && segs[1] == 'content' && segs[3] == 'book.json') {
221
+ if (segs.length == 4 && segs[1] == '_books' && segs[3] == 'book.json') {
223
222
  // Special case of a virtual file here, we need to check the book ID and
224
223
  // if its our book, send the json
225
224
  if (hdocbook_config.docId == segs[2]) {
@@ -231,7 +230,7 @@
231
230
  res.status(404).send('Specified bookId ' + segs[2] + ' not found');
232
231
  }
233
232
  return;
234
- } else if (segs.length == 3 && segs[1] == 'content' && segs[2] == 'index.json') {
233
+ } else if (segs.length == 3 && segs[1] == '_books' && segs[2] == 'index.json') {
235
234
  // For development mode, we always have an index with one book in it, the one being developed
236
235
  if (hdocbook_config) {
237
236
  let index = {
@@ -252,7 +251,7 @@
252
251
  return;
253
252
  }
254
253
 
255
- url = url.replace('/content/', '/');
254
+ url = url.replace('/_books/', '/');
256
255
 
257
256
  console.log('URL Requested:', url);
258
257
 
@@ -331,23 +330,6 @@
331
330
  app.get('/*', function (req, res) {
332
331
 
333
332
  let segs = req.url.split('/');
334
- if (segs.length > 2 && segs[1] === docId) {
335
- // In this case we are looking for static content within the book
336
- // Create the file path
337
- let url = req.url.replace('/content/', '/');
338
- console.log('URL Requested:', url);
339
- let file_path = path.join(source_path, url);
340
-
341
- // If the file exists, send it.
342
- if (fs.existsSync(file_path) == true) {
343
- send_file(req, res, file_path);
344
- return;
345
- }
346
-
347
- // All else fails, we have not file to return, so return a 404 error here
348
- send_content_resource_404(req, res);
349
- return;
350
- }
351
333
 
352
334
  let ui_file_path = path.join(ui_path, req.url);
353
335
 
@@ -375,7 +357,7 @@
375
357
  console.log('Server listening at http://127.0.0.1:%s', port);
376
358
  console.log('Document source path is: ' + source_path);
377
359
 
378
- let _vars = ['{{DOC_ID}}', '{{BASE_PATH}}', '{{BUILD_NUMBER}}', '{{BUILD_DATE}}'];
360
+ let _vars = ['{{DOC_ID}}', '{{BUILD_NUMBER}}', '{{BUILD_DATE}}'];
379
361
  console.log("Server Vars:");
380
362
  for(let x = 0; x < _vars.length; x++) {
381
363
  let name = _vars[x];
package/hdoc-validate.js CHANGED
@@ -63,6 +63,8 @@ const parseLinkDestination = require('markdown-it/lib/helpers/parse_link_destina
63
63
  // Remove explicit anchor links
64
64
  let file_path = path.join(source_path, relative_path.split('#')[0]);
65
65
 
66
+ // Replace /_books/ with /
67
+ file_path = file_path.replace(path.sep + '_books' + path.sep, path.sep);
66
68
  if (!fs.existsSync(file_path) && !fs.existsSync(file_path + '.htm') && !fs.existsSync(file_path + '.html')) {
67
69
  errors[html_path.relativePath].push(`Book resource does not exist: ${file_path}`);
68
70
  return false;
@@ -118,7 +120,7 @@ const parseLinkDestination = require('markdown-it/lib/helpers/parse_link_destina
118
120
  // Write list
119
121
  const listFile = path.join(source_path, doc_id, 'list.txt');
120
122
  fs.writeFileSync(listFile, listContent);
121
- console.log(`${listFile} created successfully`);
123
+ console.log(`\r\nLink list text file created successfully: ${listFile}`);
122
124
  } catch (err) {
123
125
  console.error(err);
124
126
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hdoc-tools",
3
- "version": "0.7.15",
3
+ "version": "0.7.17",
4
4
  "description": "Hornbill HDocBook Development Support Tool",
5
5
  "main": "hdoc.js",
6
6
  "bin": {
@@ -233,7 +233,7 @@ function loadContentUrl(linkRef,fromPageRefresh,fromPopState)
233
233
 
234
234
  //-- for now just load whatever the href prop is (we can add actions to perform specific processing and then load content based on element atts etc)
235
235
  let frontmatterData = {};
236
- fetch("content/"+linkRef).then(response =>
236
+ fetch("_books/"+linkRef).then(response =>
237
237
  {
238
238
  if(response.headers.has("X-frontmatter"))
239
239
  {
@@ -474,7 +474,7 @@ async function intialiseApp() {
474
474
  jqContentContainer = $(".injected-document-content");
475
475
  jqLeftNav = $("#DocSidebarNav");
476
476
 
477
- await fetchJsonFile("content/library.json").then(function(data){
477
+ await fetchJsonFile("_books/library.json").then(function(data){
478
478
 
479
479
  // Get docbook library list
480
480
  view.docApp.library = data;
@@ -482,7 +482,7 @@ async function intialiseApp() {
482
482
 
483
483
  }).then(function(){
484
484
  // Get hdocbook.json
485
- fetchJsonFile("content/" + view.docId + "/hdocbook.json").then(function(data)
485
+ fetchJsonFile("_books/" + view.docId + "/hdocbook.json").then(function(data)
486
486
  {
487
487
  view.docApp.book = data;
488
488
  view.bookId = data.docId;