-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen-documentation.js
92 lines (79 loc) · 2.36 KB
/
gen-documentation.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/* gen-documentation.js */
/* Requirements */
const fs = require('fs');
const path = require('path');
const nunjucks = require('nunjucks');
/* Constants */
const outputDirectory = './docs/';
// setUseCodeTags(true);
/* Helper functions */
function outputFile(fname, data) {
fs.writeFile(path.join(outputDirectory, fname), data, err => {
if (err) {
console.error(err)
return
}
})
}
const files = [
{ template: './src-docs/templates/content-index.njk',
title: 'Home',
menuName: 'Home',
filename: 'index.html'
},
{ template: './src-docs/templates/content-workshops.njk',
title: 'Workshops',
menuName: 'Workshops',
filename: 'workshops.html'
},
{ template: './src-docs/templates/content-consulting.njk',
title: 'Consulting and Mentoring',
menuName: 'Consulting',
filename: 'consulting.html'
},
{ template: './src-docs/templates/content-tools.njk',
title: 'Open-Source Tools',
menuName: 'Tools',
filename: 'tools.html'
},
{ template: './src-docs/templates/content-standards.njk',
title: 'Standards',
menuName: 'Standards',
filename: 'standards.html'
},
{ template: './src-docs/templates/content-about.njk',
title: 'About',
menuName: 'About',
filename: 'about.html'
},
{ template: './src-docs/templates/content-sessions.njk',
title: 'Sessions',
menuName: '',
filename: 'sessions/index.html'
},
{ template: './src-docs/templates/content-test-hc.njk',
title: 'High Contrast Test',
menuName: '',
filename: 'test-hc.html'
}
];
// Create files
files.forEach( f => {
const p = f.filename.includes('/') ? '../' : './';
outputFile(f.filename, nunjucks.render(f.template, {title: f.title, files: files, path: p}));
console.log(`${f.filename} ${p}`);
})
/*
const htmlIndex = nunjucks.render('./src-docs/templates/content-index.njk',
{title: 'Open Web Accessibility Consulting'});
outputFile('index.html', htmlIndex);
const htmlAbout = nunjucks.render('./src-docs/templates/content-about.njk',
{title: 'About'});
outputFile('about.html', htmlAbout);
const htmlServices = nunjucks.render('./src-docs/templates/content-services.njk',
{title: 'Services'});
outputFile('services.html', htmlServices);
const htmlProjects = nunjucks.render('./src-docs/templates/content-projects.njk',
{title: 'Projects'});
outputFile('projects.html', htmlProjects);
*/