Skip to content

Commit 7522d44

Browse files
committed
feat(overall): scripting, reporting, simplicity
removed scripting capability, and all messages except for errors, then fixed test example to reflect this scripting removed completely, quiet option removed
1 parent 3b870e8 commit 7522d44

File tree

4 files changed

+4
-34
lines changed

4 files changed

+4
-34
lines changed

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,6 @@ buildOptions.version = '4.4.0';
6969
createDocs();
7070
```
7171

72-
By default the build can be quite verbose when creating the documents. If you would prefer that the builds be silent, the buildQuiet option is offered allowing the build to complete silently, except when actual errors occur.
73-
74-
```
75-
buildOptions.buildQuiet = true;
76-
```
77-
7872
The way that NODe is written protects already generated documents by ignoring future requests when documents already exist. If you plan to update your documents many times with the same build name directory you will want to use the updateApi option.
7973

8074
```
@@ -84,7 +78,7 @@ buildOptions.updateApi = true;
8478
Setting this option to _true_ tells NODe to create and overwrite the existing documents with each request.
8579

8680

87-
### As a Script
81+
### As a Script (0.10.2 and earlier)
8882

8983
You can also use NODe as your own script simply to pull and create Node.js documentation, but with less options. Even though this feature has less options, the options that do not exist can be easily scripted.
9084

app/index.js

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,20 @@ var buildOptions = {
2727
buildDir: process.cwd(),
2828
buildVersion: process.version.slice(1),
2929
buildName: 'node-documents',
30-
buildQuiet: false,
3130
updateApi: true
3231
}
3332

34-
var options = process.argv.slice(2);
35-
36-
// check for command line scripting options
37-
if(options[0] !== []) {
38-
options.forEach(function(ops, index) {
39-
if (ops.startsWith('-v')) {
40-
buildOptions.buildVersion = options[index + 1];
41-
flags[3] = '--node-version=' + version;
42-
} else if (ops.startsWith('-f')) {
43-
buildDir = options[index + 1];
44-
if (buildDir.slice(-1) !== docEnd) { buildDir += docEnd; }
45-
buildOptions.buildDir = buildDir + buildOptions.buildName;
46-
}
47-
if (index === options.length - 1) { checkOptions(); }
48-
});
49-
}
50-
5133
// Check for modular options
5234
function convertFile(file) {
5335
// take file and generate html file
5436
count++;
5537
flags[2] = apiDir + file;
5638
var filename = file.slice(0,-3);
57-
if (!buildOptions.buildQuiet) console.log('Creating doc ' + filename);
5839
var pathname = buildOptions.buildDir + filename + '.html';
5940
var fileStream = fs.createWriteStream(pathname, {flag: 'w'});
6041
var createFile = spawn('node', flags);
6142
createFile.stdout.pipe(fileStream);
62-
createFile.on('error', (err) => console.error('Error writing: ', err));
43+
createFile.on('error', (err) => console.error('NODe: Error writing: ', err));
6344
}
6445

6546
// grab template file and assets
@@ -77,8 +58,7 @@ function checkFiles() {
7758
function copyAssets() {
7859
fsx.copy(apiAssets, buildOptions.buildDir + 'assets', function(err) {
7960
// Quiet this error since it will show if assets already exist
80-
if (err && !buildOptions.buildQuiet) { return console.log('Error copying assets:', err); }
81-
if (!buildOptions.buildQuiet) { console.log('NODe: asset copy success'); }
61+
if (err) { return console.log('NODe: Error copying assets:', err); }
8262
});
8363
checkFiles();
8464
}
@@ -91,9 +71,7 @@ function checkFolders() {
9171
if (err || buildOptions.updateApi) { copyAssets(); }
9272
});
9373
} else {
94-
if (!buildOptions.buildQuiet) console.log('NODe API: creating build folder');
9574
fs.mkdir(buildOptions.buildDir, (err, out) => {
96-
if(err && !buildOptions.buildQuiet) { console.log('NODe API: Build folder already exists'); }
9775
copyAssets();
9876
});
9977
}
@@ -105,7 +83,6 @@ function checkOptions() {
10583
if(buildOptions.buildDir.slice(0,1)) { buildOptions.buildDir = buildOptions.buildDir.replace(/^~/, os.homedir); }
10684
if (buildOptions.buildDir.slice(-1) !== docEnd) { buildOptions.buildDir += docEnd; }
10785
buildOptions.buildDir += buildOptions.buildName + docEnd;
108-
if (!buildOptions.buildQuiet) { console.log('NODe API: Building to Directory: %s', buildOptions.buildDir); }
10986
checkFolders();
11087
}
11188

example/test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ var buildOptions = require('../app/index.js').buildOptions;
1111
// Test version change
1212
buildOptions.buildVersion = '4.4.0';
1313
buildOptions.buildName = 'apidoc';
14-
buildOptions.buildQuiet = true;
1514

1615
// Use this to overwrite existing API documents
1716
// buildOptions.updateApi = true;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"test": "istanbul cover _mocha -- -R spec test/module.test.js",
99
"precommit": "npm test && npm run check-coverage",
1010
"commit": "git-cz",
11-
"check-coverage": "istanbul check-coverage --statements 70 --branches 39 --functions 70 --lines 75",
11+
"check-coverage": "istanbul check-coverage --statements 80 --branches 35 --functions 80 --lines 85",
1212
"report-coverage": "cat ./coverage/lcov.info | codecov",
1313
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
1414
},

0 commit comments

Comments
 (0)