forked from ckeditor/ckeditor4-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntfile.js
145 lines (117 loc) · 3.64 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
/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.html or http://ckeditor.com/license
*/
'use strict';
const Umberto = require( 'umberto' );
module.exports = function( grunt ) {
const packageVersion = grunt.file.readJSON( 'package.json' ).version;
require( 'load-grunt-tasks' )( grunt );
grunt.loadNpmTasks( 'grunt-contrib-connect' );
grunt.loadTasks( 'dev/tasks' );
grunt.registerTask( 'api', [ 'jsduck:api' ] );
grunt.registerTask( 'umberto', function() {
const done = this.async();
const skipApi = grunt.option( 'skipApi' );
const skipValidation = grunt.option( 'skipValidation' );
const dev = grunt.option( 'dev' );
const clean = grunt.option( 'clean' );
return Umberto.buildSingleProject( {
skipApi,
skipValidation,
dev,
clean
} )
.then( done )
.catch( err => {
grunt.log.error( `Building Documentation failed: ${ err }` );
done();
} );
} );
grunt.registerTask( 'fix-scayt-docs', function() {
const done = this.async();
const scaytMap = grunt.file.readJSON( 'scayturls.json' );
var file = grunt.file.read( 'docs/api/data/CKEDITOR.config.json' );
for ( const key in scaytMap ) {
file = file.replace( new RegExp( '@@' + key , 'g' ), scaytMap[ key ] );
}
grunt.file.write( 'docs/api/data/CKEDITOR.config.json', file );
done();
} );
grunt.registerTask( 'docs', [ 'api', 'fix-scayt-docs', 'umberto' ] );
grunt.registerTask( 'docs-serve', [ 'api', 'fix-scayt-docs', 'umberto', 'connect' ] );
grunt.initConfig( {
path: grunt.option( 'path' ) || getCKEditorPath(),
jsduck: {
api: {
src: [
'<%= path %>/core',
'<%= path %>/plugins',
'<%= path %>/adapters',
'<%= path %>/ckeditor.js',
'repos/ckeditor-plugin-scayt',
'repos/ckeditor-plugin-wsc'
],
cmd: 'ckeditor-jsduck',
options: {
tags: 'source/customs.rb',
warnings: [ '-nodoc', '-image_unused' ],
output: 'docs/api/data',
export: 'full',
external: 'Blob,File,FileReader,DocumentFragment',
exclude: '<%= path %>/plugins/codesnippet/lib',
'ignore-html': 'source'
}
}
},
docs: {
options: {
skipApi: false,
skipValidation: false,
dev: false,
clean: true
}
},
'docs-serve': {
options: {
skipApi: false,
skipValidation: false,
dev: false,
clean: true
}
},
connect: {
server: {
options: {
port: 9001,
base: 'build/docs',
keepalive: true,
open: 'http://localhost:9001/ckeditor4/' + packageVersion + '/guide/dev_installation.html'
}
}
}
} );
// SEO is on by default, unless disabled via command–line `--seo false`.
// This option is set here because JSDuck does not simply accept `seo: false` in config.
if ( grunt.option( 'seo' ) !== false ) {
grunt.config( 'jsduck.docs.options.seo', true );
}
function getCKEditorPath() {
grunt.log.writeln( 'CKEditor Documentation Builder v' + packageVersion + '.' );
var ckeditorPath = 'repos/ckeditor-dev';
if ( process.env.CKEDITOR_DEV ) {
grunt.log.writeln( '[i] Using CKEditor directory from CKEDITOR_DEV env variable.' );
ckeditorPath = process.env.CKEDITOR_DEV;
} else {
grunt.log.writeln( '[i] CKEDITOR_DEV env variable not set. Looking for', '../ckeditor-dev...'[ 'cyan' ] );
if ( grunt.file.exists( '../ckeditor-dev/ckeditor.js' ) ) {
grunt.log.writeln( '[i] Directory', '../ckeditor-dev'[ 'cyan' ], 'found!' );
ckeditorPath = '../ckeditor-dev';
} else {
grunt.log.writeln( '[i] CKEditor directory not found.' );
}
}
grunt.log.writeln( '[i] Using', ckeditorPath[ 'cyan' ], 'as source directory.' );
return ckeditorPath;
}
};