File tree Expand file tree Collapse file tree 5 files changed +49
-52
lines changed Expand file tree Collapse file tree 5 files changed +49
-52
lines changed Original file line number Diff line number Diff line change
1
+ [* ]
2
+ indent_size = 2
3
+ indent_style = space
Original file line number Diff line number Diff line change 1
1
* .html
2
2
node_modules
3
3
4
+ schema.json
5
+
4
6
* .pdf
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -7,9 +7,10 @@ const {JSDOM} = require("jsdom");
7
7
* JSDOM chosen due to availability of standard apis
8
8
* in a browser-free environment.
9
9
*/
10
- const createDOM = ( category ) => {
10
+ const createDOM = ( category , scripts = false ) => {
11
11
const fData = readFileSync ( "./" + category + ".html" )
12
- const dom = new JSDOM ( fData ) ;
12
+ const options = scripts ? { runScripts : "dangerously" } : undefined ;
13
+ const dom = new JSDOM ( fData , options ) ;
13
14
return dom ;
14
15
}
15
16
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env node
2
+ const { categories} = require ( './config' ) ;
3
+
4
+ const { normalize} = require ( './src/util' ) ;
5
+ const { createDOM} = require ( './src/env' ) ;
6
+
7
+ const byTitle = ( title ) => a => a . title === title ;
8
+
9
+ const onlyObjects = a => / - o b j e c t s \. h t m l $ / . test ( a . link ) ;
10
+ const toRepresentation = a => a . link . match ( / ( [ A - z ] + ) - o b j e c t s \. h t m l $ / ) [ 1 ] ;
11
+
12
+ /**
13
+ * Grab all category defintions for navigation
14
+ * from JavaScript in the page
15
+ */
16
+ for ( const _category of categories ) {
17
+ const category = normalize ( _category ) ;
18
+ const { window} = createDOM ( category , true ) ;
19
+ const { tocJSON} = window ;
20
+
21
+ if ( ! tocJSON ) {
22
+ console . log ( 'failure to parse TOC on page' , category ) ;
23
+ continue ;
24
+ }
25
+
26
+ const items = tocJSON
27
+ . find ( byTitle ( 'Reference' ) )
28
+ . children [ 0 ]
29
+ . children
30
+ . find ( byTitle ( 'Objects and Attributes' ) )
31
+ . children
32
+ . filter ( onlyObjects )
33
+ . map ( toRepresentation ) ;
34
+
35
+ console . log ( 'objects are' , items ) ;
36
+ // only need a single version of tocJSON
37
+ break ;
38
+ }
39
+
40
+
41
+
You can’t perform that action at this time.
0 commit comments