hdoc-tools 0.7.7 → 0.7.8
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 +6 -39
- package/hdoc-init.js +59 -72
- 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
|
@@ -1,42 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# HDocBook documentation
|
|
2
|
+
This is an example of a simple static content documentation project that is compatible with the Hornbill Docs system
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
Make sure that you have installed hdoc-tools
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
npm install hdoc-tools -g
|
|
6
7
|
|
|
7
|
-
|
|
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, and outputs as a ZIP file.
|
|
39
|
-
|
|
40
|
-
### serve
|
|
41
|
-
|
|
42
|
-
Starts a local web server on port 3000, serving the book content.
|
|
8
|
+
To preview the documentation in a browser, you can open a terminal window and run the dev preview server with the
|
|
9
|
+
command `hdoc serve` and in a local browser go to the url `http://localhost:3000`
|
package/hdoc-init.js
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
}
|
|
41
41
|
];
|
|
42
42
|
|
|
43
|
-
const createBook = function(server_path, source_path, docProps) {
|
|
43
|
+
const createBook = function (server_path, source_path, docProps) {
|
|
44
44
|
console.log('\r\nCreating book with the following properties:\r\n');
|
|
45
45
|
console.log(' Doc ID:', docProps.id);
|
|
46
46
|
console.log(' Title:', docProps.title);
|
|
@@ -48,85 +48,72 @@
|
|
|
48
48
|
console.log(' Author:', docProps.author);
|
|
49
49
|
console.log(' Initial Version:', docProps.version, '\r\n');
|
|
50
50
|
|
|
51
|
-
//
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// Create target book folder
|
|
56
|
-
fs.mkdirSync(bookPath);
|
|
57
|
-
|
|
58
|
-
// Now copy files over
|
|
59
|
-
const templatePath = path.join(server_path, 'templates','init');
|
|
60
|
-
console.log('Copying template from:', templatePath);
|
|
51
|
+
// Now copy files over
|
|
52
|
+
const templatePath = path.join(server_path, 'templates', 'init');
|
|
53
|
+
console.log('Copying template from:', templatePath);
|
|
61
54
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
55
|
+
if (fs.existsSync(templatePath)) {
|
|
56
|
+
// If template path exists, do sync copy into book path
|
|
57
|
+
try {
|
|
58
|
+
fs.copySync(templatePath, source_path);
|
|
59
|
+
} catch (e) {
|
|
60
|
+
console.error('Error copying template:\r\n', e);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
70
63
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
64
|
+
// Rename _hdocbook folder to docId, sync as we need to wait
|
|
65
|
+
// until this in complete for the next tasks to be successful
|
|
66
|
+
const bookContentRoot = path.join(source_path, docProps.id);
|
|
67
|
+
try {
|
|
68
|
+
fs.renameSync(path.join(source_path, '_hdocbook'), bookContentRoot);
|
|
69
|
+
} catch (e) {
|
|
70
|
+
console.error('Error renaming template folder:\r\n', e);
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
80
73
|
|
|
81
|
-
|
|
82
|
-
|
|
74
|
+
// The file update tasks can now all be done async now
|
|
75
|
+
// we have the file and folder structure in place
|
|
83
76
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
77
|
+
// Update hdocbook-project.json
|
|
78
|
+
const hdocBookProjectFilePath = path.join(source_path, 'hdocbook-project.json');
|
|
79
|
+
const hdocBookProjectFile = require(hdocBookProjectFilePath);
|
|
80
|
+
hdocBookProjectFile.docId = docProps.id;
|
|
81
|
+
fs.writeFile(hdocBookProjectFilePath, JSON.stringify(hdocBookProjectFile, null, 2), function writeJSON(err) {
|
|
82
|
+
if (err) return console.log('Error updating:', hdocBookProjectFilePath, '\r\n', err);
|
|
83
|
+
console.log('Updated:', hdocBookProjectFilePath);
|
|
84
|
+
});
|
|
92
85
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
console.log('Updated:', hdocBookFilePath);
|
|
109
|
-
});
|
|
86
|
+
// Update root/hdocbook.json
|
|
87
|
+
const hdocBookFilePath = path.join(bookContentRoot, 'hdocbook.json');
|
|
88
|
+
const hdocbookFile = require(hdocBookFilePath);
|
|
89
|
+
hdocbookFile.docId = docProps.id;
|
|
90
|
+
hdocbookFile.title = docProps.title;
|
|
91
|
+
hdocbookFile.description = docProps.description;
|
|
92
|
+
hdocbookFile.version = docProps.version;
|
|
93
|
+
hdocbookFile.navigation.items[0].items = [{
|
|
94
|
+
"text": "Welcome",
|
|
95
|
+
"link": path.join(docProps.id, 'index')
|
|
96
|
+
}];
|
|
97
|
+
fs.writeFile(hdocBookFilePath, JSON.stringify(hdocbookFile, null, 2), function writeJSON(err) {
|
|
98
|
+
if (err) return console.log('Error updating:', hdocBookFilePath, '\r\n', err);
|
|
99
|
+
console.log('Updated:', hdocBookFilePath);
|
|
100
|
+
});
|
|
110
101
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
102
|
+
// Update package.json
|
|
103
|
+
const packageFilePath = path.join(source_path, 'package.json');
|
|
104
|
+
const packageFile = require(packageFilePath);
|
|
105
|
+
packageFile.name = docProps.id;
|
|
106
|
+
packageFile.version = docProps.version;
|
|
107
|
+
hdocbookFile.description = docProps.description;
|
|
108
|
+
hdocbookFile.version = docProps.version;
|
|
109
|
+
hdocbookFile.author = docProps.author;
|
|
110
|
+
fs.writeFile(packageFilePath, JSON.stringify(packageFile, null, 2), function writeJSON(err) {
|
|
111
|
+
if (err) return console.log('Error updating:', packageFilePath, '\r\n', err);
|
|
112
|
+
console.log('Updated:', packageFilePath);
|
|
113
|
+
});
|
|
123
114
|
|
|
124
|
-
} else {
|
|
125
|
-
console.error('Template path does not exist:', templatePath);
|
|
126
|
-
process.exit(1);
|
|
127
|
-
}
|
|
128
115
|
} else {
|
|
129
|
-
console.error('
|
|
116
|
+
console.error('Template path does not exist:', templatePath);
|
|
130
117
|
process.exit(1);
|
|
131
118
|
}
|
|
132
119
|
};
|