-
Notifications
You must be signed in to change notification settings - Fork 75
/
Gruntfile.js
122 lines (108 loc) · 2.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
var hljs = require('highlight.js');
module.exports = function(grunt) {
var generateApi = require("./source/api-gen/generate-api-docs.js");
function buildStatic() {
// last two arguments are input file and output directory
generateApi(grunt, "./source/api-gen/api.json", "./source/api");
}
grunt.initConfig({
// ...
assemble: {
options: {
layout: 'default',
layoutdir: './source/_layouts',
marked:{
highlight: function (code, lang) {
if (lang)
return hljs.highlight(lang, code).value;
else
return hljs.highlightAuto(code, ["javascript", "html"]).value;
}
}
},
release: {
files: [{
cwd: './source',
dest: './',
expand: true,
src: ['index.html', 'documentation/*', 'cookbook/**/*.md', 'getting-started/*', 'api/**/*.*', 'components/*.html'] //'api/**/*.*',
}]
},
beta: {
files: [{
cwd: './source',
dest: './beta',
expand: true,
src: ['api/**/*.*']
}]
}
},
connect: {
dev: {
options: {
open: true,
port: 8000,
base: './',
keepalive: true
}
}
},
less: {
default: {
files: {
"craftyjs-site.css":"source/less/craftyjs-site.less",
}
}
},
watch: {
less: {
files: 'source/less/*.less',
tasks: ['less'],
},
templates: {
files: ['source/**/*', '!source/less/*.less'],
tasks: ['assemble'],
},
},
linkChecker: {
includeApi: {
site: 'localhost',
options: {
initialPort: 8000,
callback: function (crawler) {
crawler.addFetchCondition(function (url) {
if (url.path.indexOf("glyphicon") >= 0)
return false
return true;
});
}
}
},
ignoreApi: {
site: 'localhost',
options: {
initialPort: 8000,
callback: function (crawler) {
crawler.addFetchCondition(function (url) {
if (url.path.indexOf("glyphicon") >= 0)
return false
else if (url.path.indexOf("api") >= 0)
return false;
return true;
});
}
}
}
}
});
grunt.loadNpmTasks('grunt-assemble');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-link-checker');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.registerTask('default', ['api', 'less', 'assemble:release']);
grunt.registerTask('beta-docs', ['api', 'less', 'assemble:beta']);
grunt.registerTask('api', "Generate api documentation", buildStatic);
grunt.registerTask('fast-check', 'linkChecker:ignoreApi');
grunt.registerTask('full-check', 'linkChecker:includeApi');
};