forked from sitna/api-sitna-jsdoc-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
210 lines (198 loc) · 6.99 KB
/
Gruntfile.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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
module.exports = function(grunt) {
var path = require("path");
/**
* Used to process the handlebar template names when compiling them to the "tmpl" namespace.
* @example
* processTemplateName( "src/tmpl/template.hbs" ) => "template" => tmpl["template"]
* processTemplateName( "src/tmpl/_partial.hbs" ) => "partial" => tmpl["partial"]
* processTemplateName( "src/tmpl/group/template.hbs" ) => "group/template" => tmpl["group/template"]
* processTemplateName( "src/tmpl/group/_partial.hbs" ) => "group/partial" => tmpl["group/partial"]
*/
var processTemplateName = function(filePath){
return filePath.replace(/^.*?\/tmpl\/(.*)?\.hbs/, '$1').replace(/(\/|^)_/, '$1');
};
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: {
test: ['.test/'],
examples: ['examples/'],
template: ['template/']
},
handlebars: {
compile: {
options: {
namespace: 'tmpl',
node: true,
partialsUseNamespace: true,
processName: processTemplateName,
processPartialName: processTemplateName
},
files: {
"template/tmpl.js": ["src/tmpl/**/*.hbs"]
}
}
},
copy : {
template: {
files: [
{expand: true, flatten: true, src: ['src/conf.json'], dest: 'template/', filter: 'isFile'},
{expand: true, flatten: true, src: ['src/publish.js'], dest: 'template/', filter: 'isFile'},
{expand: true, flatten: true, src: ['src/utils/template.js'], dest: 'template/utils/', filter: 'isFile'},
{expand: true, flatten: true, src: ['src/utils/postProcessor.js'], dest: 'template/utils/', filter: 'isFile'},
{expand: true, flatten: true, src: ['src/utils/docletHelper.js'], dest: 'template/utils/', filter: 'isFile'},
{expand: true, flatten: true, src: ['src/utils/handlebarsHelper.js'], dest: 'template/utils/', filter: 'isFile'},
{expand: true, flatten: true, src: ['src/utils/lunrHelper.js'], dest: 'template/utils/', filter: 'isFile'}
]
},
bootstrap: {
files : [
{expand: true, flatten: true, src: ['node_modules/bootstrap/dist/js/bootstrap.min.js'], dest: 'template/static/js/', filter: 'isFile'},
{expand: true, flatten: true, src: ['node_modules/bootstrap/dist/css/bootstrap.min.css'], dest: 'template/static/css/', filter: 'isFile'},
{expand: true, flatten: true, src: ['node_modules/bootstrap/dist/fonts/*'], dest: 'template/static/fonts/', filter: 'isFile'}
]
},
jquery: {
files : [
{expand: true, flatten: true, src: ['node_modules/jquery/dist/jquery.min.js'], dest: 'template/static/js/', filter: 'isFile'}
]
},
clipboard: {
files : [
{expand: true, flatten: true, src: ['node_modules/clipboard/dist/clipboard.min.js'], dest: 'template/static/js/', filter: 'isFile'}
]
},
prism: {
files : [
{expand: true, flatten: true, src: ['node_modules/prismjs/prism.js'], dest: 'template/static/js/', filter: 'isFile'},
{expand: true, flatten: true, src: ['node_modules/prismjs/themes/prism.css'], dest: 'template/static/css/', filter: 'isFile'}
]
},
lunr: {
files : [
{expand: true, flatten: true, src: ['node_modules/lunr/lunr.min.js'], dest: 'template/static/js/', filter: 'isFile'}
]
}
},
uglify: {
prism: { // prism requires it's own build as I've modified some plugins and use some default ones to.
files: {
'template/static/js/prism.min.js': [
'node_modules/prismjs/prism.js',
'node_modules/prismjs/plugins/normalize-whitespace/prism-normalize-whitespace.js',
'src/static/js/prism-line-numbers.js',
'src/static/js/prism-toolbar.js',
'src/static/js/prism-copy-to-clipboard.js',
]
}
},
template: {
files: {
'template/static/js/template.min.js': [
'src/static/js/markdown-helpers.js',
'src/static/js/symbols.js',
'src/static/js/table-of-contents.js',
'src/static/js/access-filter.js',
'src/static/js/lunr-search.js',
'src/static/js/example-run.js',
'src/static/js/google-analytics.js'
]
}
}
},
cssmin: {
prism: {
files: {
'template/static/css/prism.min.css': [
'node_modules/prismjs/themes/prism.css',
'src/static/css/prism-theme-overrides.css',
'src/static/css/prism-line-numbers.css',
'src/static/css/prism-toolbar.css'
]
}
},
template: {
files: {
'template/static/css/template.min.css': [
'src/static/css/site.css',
'src/static/css/callout.css',
'src/static/css/page-header.css',
'src/static/css/symbols.css',
'src/static/css/tags.css',
'src/static/css/anchor-link.css',
'src/static/css/breadcrumbs.css',
'src/static/css/dummy-console.css',
'src/static/css/lunr-search.css',
'src/static/css/related-tutorials.css',
'src/static/css/toc.css',
'src/static/css/access-filter.css'
]
}
}
},
jsdoc: {
namespaced: {
src: ["README.md","test-src/namespaced/**/*.js"],
options: {
destination: './.test',
template : './template',
configure : './test-src/default.conf.json',
tutorials: './test-src/fixtures/tutorials/',
private: true
}
},
default: {
src: ["README.md","test-src/fixtures/**/*.js"],
options: {
destination: './examples/default',
template : './template',
configure : './test-src/default.conf.json',
tutorials: './test-src/fixtures/tutorials/',
private: true
}
},
inline: {
src: ["README.md","test-src/fixtures/**/*.js"],
options: {
destination: './examples/inline',
template : './template',
configure : './test-src/inline.conf.json',
tutorials: './test-src/fixtures/tutorials/',
private: true
}
},
"logo-color": {
src: ["README.md","test-src/fixtures/**/*.js"],
options: {
destination: './examples/logo-color',
template : './template',
configure : './test-src/logo-color.conf.json',
tutorials: './test-src/fixtures/tutorials/',
private: true
}
},
collapse: {
src: ["README.md","test-src/fixtures/**/*.js"],
options: {
destination: './examples/collapse',
template : './template',
configure : './test-src/collapse.conf.json',
tutorials: './test-src/fixtures/tutorials/',
private: true
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-handlebars');
grunt.loadNpmTasks('grunt-jsdoc');
grunt.registerTask('template', ['clean:template', 'handlebars', 'copy', 'uglify', 'cssmin']);
grunt.registerTask('all', ['template', 'clean:examples', 'jsdoc:default', 'jsdoc:inline', 'jsdoc:logo-color', 'jsdoc:collapse', 'jsdoc:namespaced']);
grunt.registerTask('default', ['template', 'jsdoc:default']);
grunt.registerTask('inline', ['template', 'jsdoc:inline']);
grunt.registerTask('logo-color', ['template', 'jsdoc:logo-color']);
grunt.registerTask('collapse', ['template', 'jsdoc:collapse']);
grunt.registerTask('namespaced', ['template', 'jsdoc:namespaced']);
};