manual-utils.js
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'use strict';
const _ = require('lodash');
const jetpack = require('fs-jetpack');
const { normalize } = require('path');
const assert = require('assert');
function getDeclaredManuals() {
const declaredManualGroups = require('./manual-groups.json');
return _.flatten(_.values(declaredManualGroups)).map(file => {
return normalize(`./docs/manual/${file}`);
});
}
function getAllManuals() {
return jetpack.find('./docs/manual/', { matching: '*.md' }).map(m => {
return normalize(`./${m}`);
});
}
function checkManuals() {
// First we check that declared manuals and all manuals are the same
const declared = getDeclaredManuals().sort();
const all = getAllManuals().sort();
assert.deepStrictEqual(declared, all);
// Then we check that every manual begins with a single `#`. This is
// important for ESDoc to render the left menu correctly.
for (const manualRelativePath of all) {
assert(
/^#[^#]/.test(jetpack.read(manualRelativePath)),
`Manual '${manualRelativePath}' must begin with a single '#'`
);
}
}
module.exports = { getDeclaredManuals, getAllManuals, checkManuals };