-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview_nav.js
executable file
·35 lines (28 loc) · 940 Bytes
/
view_nav.js
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
#!/usr/bin/env node
const { categories } = require("./config");
const { normalize } = require("./src/util");
const { createDOM } = require("./src/env");
const byTitle = (title) => (a) => a.title === title;
const onlyObjects = (a) => /-objects\.html$/.test(a.link);
const toRepresentation = (a) => a.link.match(/([A-z]+)-objects\.html$/)[1];
/**
* Grab all category defintions for navigation
* from JavaScript in the page
*/
for (const _category of categories) {
const category = normalize(_category);
const { window } = createDOM(category, true);
const { tocJSON } = window;
if (!tocJSON) {
console.log("failure to parse TOC on page", category);
continue;
}
const items = tocJSON
.find(byTitle("Reference"))
.children[0].children.find(byTitle("Objects and Attributes"))
.children.filter(onlyObjects)
.map(toRepresentation);
console.log("objects are", items);
// only need a single version of tocJSON
break;
}