-
Notifications
You must be signed in to change notification settings - Fork 18
/
Gruntfile.js
215 lines (198 loc) · 6.07 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
211
212
213
214
215
module.exports = function(grunt) {
var packageNames = [];
var guides = [];
// Grunt Tasks
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-dom-munger');
grunt.loadNpmTasks('grunt-md2html');
grunt.loadNpmTasks('grunt-gh-pages');
grunt.initConfig({
folder_list : {
options : {
files: false,
folders: true
},
files : {
'tmp/fixtures.json': ['packages/**']
}
},
shell: {
// Delete old version of the Site.
makeSite: {
command: "rm -rf docs/site; mkdir docs/site"
},
// Build each set of docs in each package directory.
makeDocs: {
command: function (packageName) {
return ['cd packages/'+packageName, 'ember ember-cli-yuidoc'].join('&&');
}
},
// Copy the newly built individual docs into the main docs folder.
copyDocs: {
command: function (packageName) {
return 'cp -r packages/'+packageName+'/docs docs/site/'+packageName;
}
},
// Use "Core" as the template for non-YUI pages.
// Copy "Core" assets over.
copyAssets: {
command: function () {
return 'cp -r docs/site/core/assets docs/site/assets';
}
},
// Copy "Core" index.html over.
copyIndex: {
command: function () {
return 'cp docs/site/core/index.html docs/site/index.html';
}
},
copyGuidesTemplate: {
command: function () {
return 'cp docs/site/core/index.html docs/site/guide-template.html';
}
},
deleteGuidesTemplate: {
command: function () {
return 'rm docs/site/guide-template.html';
}
},
createCname: {
command: function() {
return 'touch docs/site/CNAME; echo "www.spree-ember.com" > docs/site/CNAME;';
}
}
},
dom_munger: {
// Generate the "Packages" Page
packages: {
options: {
remove: ['#sidebar-content', '#main-content'],
callback: function($){
$('#main-package-name h3').text('Packages');
packageNames.forEach(function(packageName) {
$("#docs-content").append("<a class='small-12 columns panel' href='./"+packageName+"/index.html'><h3>spree-ember-"+packageName+"</h3></a>");
})
}
},
src: 'docs/site/index.html',
dest: 'docs/site/packages.html'
},
// Generate the Homepage
index: {
options: {
remove: ['section#main'],
callback: function($){
$('header').addClass('homepage');
$('header .info').append('<iframe src="https://ghbtns.com/github-btn.html?user=hhff&repo=spree-ember&type=star&count=true&size=large" frameborder="0" scrolling="0" width="120px" height="30px" style="margin-top:20px;"></iframe>');
}
},
src: 'docs/site/index.html'
},
guideTemplate: {
options: {
callback: function($){
$("#sidebar-content h3").first().text("Guides");
$("#sidebar-content ul").first().empty();
guides.forEach(function(guideName) {
var prettyName = guideName.split("-");
prettyName.shift();
if (prettyName.length > 1) {
prettyName = prettyName.join(" ");
}
$("#sidebar-content ul").first().append("<li><a href='./"+guideName+".html'>"+prettyName+"</a></li>");
});
$('#main-package-name h3').text('Guides');
$('#main-content').text('{DOC}');
}
},
src: 'docs/site/guide-template.html'
}
},
md2html: {
guides: {
options: {
layout: 'docs/site/guide-template.html'
},
files: [{
expand: true,
cwd: 'docs/guides',
src: ['*.md'],
dest: 'docs/site',
ext: '.html'
}]
},
// Need a better way to do this:
auth: {
options: {
layout: 'docs/site/auth/index.html'
},
files: [{
src: ['packages/auth/README.md'],
dest: 'docs/site/auth/index.html'
}]
},
checkouts: {
options: {
layout: 'docs/site/checkouts/index.html'
},
files: [{
src: ['packages/checkouts/README.md'],
dest: 'docs/site/checkouts/index.html'
}]
},
core: {
options: {
layout: 'docs/site/core/index.html'
},
files: [{
src: ['packages/core/README.md'],
dest: 'docs/site/core/index.html'
}]
},
storefront: {
options: {
layout: 'docs/site/storefront/index.html'
},
files: [{
src: ['packages/storefront/README.md'],
dest: 'docs/site/storefront/index.html'
}]
}
},
'gh-pages': {
options: {
base: 'docs/site'
},
src: ['**/*']
}
});
grunt.registerTask('default', 'Generate Docs!', function() {
grunt.task.run('shell:makeSite');
// Prepare API Docs for Packages
grunt.file.expand('packages/*').forEach(function(path) {
packageNames.push(path.split('/')[1]);
});
packageNames.forEach(function(packageName) {
grunt.task.run('shell:makeDocs:'+packageName);
grunt.task.run('shell:copyDocs:'+packageName);
grunt.task.run('md2html:'+packageName);
});
// Create Homepage and Packages Index
grunt.task.run('shell:copyAssets');
grunt.task.run('shell:copyIndex');
grunt.task.run('dom_munger:packages');
grunt.task.run('dom_munger:index');
// Discover Guides
grunt.file.expand('docs/guides/*').forEach(function(path) {
guides.push(path.split('/')[2].split('.')[0]);
});
// Prepare the Guides Template
grunt.task.run('shell:copyGuidesTemplate');
grunt.task.run('dom_munger:guideTemplate');
// Create Guide Files
grunt.task.run('md2html:guides');
grunt.task.run('shell:deleteGuidesTemplate');
grunt.task.run('shell:createCname');
grunt.task.run('gh-pages');
});
};