-
Notifications
You must be signed in to change notification settings - Fork 14
/
publish.js
90 lines (75 loc) · 2.64 KB
/
publish.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
/**
* This file is the required module for the Enyo.js JSDoc3 custom template.
*
* @file
*/
'use strict';
// nodejs built-ins
var util = require('util'),
fs = require('fs'),
path = require('path');
// internal
var helpers = require('./lib/helpers'),
proc = require('./lib/processor'),
resolveLinks = require('./lib/post_processors/common').process;
/**
* This is the entry point for the template. It is passed a TaffyDB database of everything that was
* parsed/interpreted by JSDoc and the options defined for JSDoc.
*/
exports.publish = function (db, opts) {
// before anything else happens we initialize our stateful helpers
helpers.init(db, opts);
// for every doclet we have the opportunity to pre-process it before rendering its template
// this is a separate routine from actually rendering and post-rendering routines (like
// resolving links)
db().each(proc.preProcess.bind(proc));
// now we need to do rendering, post-processing and then publishing (writing) the files
// note that the post-process routine is actually part of the rendering routine as well
db().each(proc.render.bind(proc));
// we allow for every kind of doclet to be rendered and post-processed prior to attempting to
// actually publish the file in case of attempted re-use of some output or other more
// intricate handling
db().each(proc.publish.bind(proc));
var namespaces = db({kind: 'namespace', subNamespace: {'!is': true}}).order('longname asec').get(),
kinds = db({kind: 'class', ui: {isUndefined: true}}).order('longname asec').get(),
controls = db({kind: 'class', ui: true}).order('longname asec').get(),
utils = db({kind: 'function', utility: true}).order('longname asec').get();
// publish our home (main) section of the site
helpers.publish('home.html', helpers.render(
'pages/home.html', {
namespaces: namespaces,
kinds: db({kind: 'class'}).order('longname asec').get()
}
));
// publish the glossary
helpers.publish('glossary.html', resolveLinks(helpers.render(
'pages/glossary.html', {
terms: db({kind: 'glossary'}).order('longname asec').get()
}
)));
// publish the namespaces page
helpers.publish('namespaces.html', helpers.render(
'pages/namespaces.html', {
namespaces: namespaces
}
));
// publish the kinds page
helpers.publish('kinds.html', helpers.render(
'pages/kinds.html', {
controls: controls,
kinds: kinds
}
));
// publish utilities page
helpers.publish('utilities.html', resolveLinks(helpers.render(
'pages/utilities.html', {
utils: utils
}
)));
// publish our index
helpers.publish('index.html', helpers.render(
'index.html', {
generated: new Date().toLocaleDateString()
}
));
};