-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
173 lines (158 loc) · 4.38 KB
/
index.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/**
* Themeleon template helper, using consolidate.js module.
*
* See <https://github.com/themeleon/themeleon>.
* See <https://github.com/tj/consolidate.js>.
*/
var themeleon = require('themeleon')().use('consolidate');
/**
* Utility function we will use to merge a default configuration
* with the user object.
*/
var extend = require('extend');
/**
* SassDoc extras (providing Markdown and other filters, and different way to
* index SassDoc data).
*
* See <https://github.com/SassDoc/sassdoc-extras>.
*/
var extras = require('sassdoc-extras');
/**
* The theme function. You can directly export it like this:
*
* module.exports = themeleon(__dirname, function (t) {});
*
* ... but here we want more control on the template variables, so there
* is a little bit of preprocessing below.
*
* The theme function describes the steps to render the theme.
*/
var theme = themeleon(__dirname, function (t) {
/**
* Copy the assets folder from the theme's directory in the
* destination directory.
*/
t.copy('assets');
/**
* Render `views/index.swig` with the theme's context (`ctx` below)
* as `index.html` in the destination directory.
*/
t.swig('views/index.swig', 'index.html');
});
/**
* Actual theme function. It takes the destination directory `dest`
* (that will be handled by Themeleon), and the context variables `ctx`.
*
* Here, we will modify the context to have a `view` key defaulting to
* a literal object, but that can be overriden by the user's
* configuration.
*/
module.exports = function (dest, ctx) {
var def = {
display: {
access: ['public', 'private'],
alias: false,
watermark: true,
},
groups: {
'undefined': 'General',
},
'shortcutIcon': 'http://sass-lang.com/favicon.ico',
};
// Apply default values for groups and display.
ctx.groups = extend(def.groups, ctx.groups);
ctx.display = extend(def.display, ctx.display);
// Extend top-level context keys.
ctx = extend({}, def, ctx);
/**
* Parse text data (like descriptions) as Markdown, and put the
* rendered HTML in `html*` variables.
*
* For example, `ctx.package.description` will be parsed as Markdown
* in `ctx.package.htmlDescription`.
*
* See <http://sassdoc.com/extra-tools/#markdown>.
*/
extras.markdown(ctx);
/**
* Add a `display` property for each data item regarding of display
* configuration (hide private items and aliases for example).
*
* You'll need to add default values in your `.sassdocrc` before
* using this filter:
*
* {
* "display": {
* "access": ["public", "private"],
* "alias": false
* }
* }
*
* See <http://sassdoc.com/extra-tools/#display-toggle>.
*/
extras.display(ctx);
/**
* Allow the user to give a name to the documentation groups.
*
* We can then have `@group slug` in the docblock, and map `slug`
* to `Some title string` in the theme configuration.
*
* **Note:** all items without a group are in the `undefined` group.
*
* See <http://sassdoc.com/extra-tools/#groups-aliases>.
*/
extras.groupName(ctx);
/**
* Use SassDoc indexer to index the data by group and type, so we
* have the following structure:
*
* {
* "group-slug": {
* "function": [...],
* "mixin": [...],
* "variable": [...]
* },
* "another-group": {
* "function": [...],
* "mixin": [...],
* "variable": [...]
* }
* }
*
* You can then use `data.byGroupAndType` instead of `data` in your
* templates to manipulate the indexed object.
*/
ctx.data.byGroupAndType = extras.byGroupAndType(ctx.data);
/**
* Now we have prepared the data, we can proxy to the Themeleon
* generated theme function.
*/
return theme.apply(this, arguments);
};
module.exports.annotations = [];
module.exports.annotations.push(function () {
return {
name: 'date',
parse: function (text) {
return text;
},
default: function (comment) {
return '';
},
autofill: function (comment) {},
multiple: false
};
});
module.exports.annotations.push(function () {
return {
name: 'expectedVersion',
parse: function (text) {
return text;
},
default: function (comment) {
return '';
},
autofill: function (comment) {},
multiple: false
};
});