Преглед на файлове

Merge branch 'master' into t/78

Piotrek Koszuliński преди 9 години
родител
ревизия
a5bb6d2250
променени са 9 файла, в които са добавени 99 реда и са изтрити 6 реда
  1. 1 1
      .gitignore
  2. 12 3
      dev/tasks/build/tasks.js
  3. 4 1
      dev/tasks/build/utils.js
  4. 4 1
      dev/tasks/dev/tasks.js
  5. 23 0
      dev/tasks/docs/jsdoc.json
  6. 33 0
      dev/tasks/docs/plugins/comment-fixer.js
  7. 19 0
      dev/tasks/docs/tasks.js
  8. 1 0
      gulpfile.js
  9. 2 0
      package.json

+ 1 - 1
.gitignore

@@ -10,4 +10,4 @@
 node_modules/**
 build/**
 coverage/**
-dist/**
+dist/**

+ 12 - 3
dev/tasks/build/tasks.js

@@ -1,4 +1,7 @@
-/* jshint node: true, esnext: true */
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
 
 'use strict';
 
@@ -132,9 +135,11 @@ module.exports = ( config ) => {
 		 * The main build task which is capable of copying, watching, processing and writing all files
 		 * to the `dist/` directory.
 		 *
+		 * @param {Object} buildOptions
+		 * @param {String} buildOptions.formats
 		 * @returns {Stream}
 		 */
-		build() {
+		build( buildOptions ) {
 			//
 			// NOTE: Error handling in streams is hard.
 			//
@@ -166,7 +171,7 @@ module.exports = ( config ) => {
 			//
 			// PS. The assumption is that all errors thrown somewhere inside conversionStream are forwarded to conversionStream.
 			// Multipipe and gulp-mirror seem to work this way, so we get a single error emitter.
-			const formats = options.formats.split( ',' );
+			const formats = ( buildOptions.formats || options.formats ).split( ',' );
 			const codeStream = tasks.src.all( options.watch )
 				.pipe(
 					utils.noop( ( file ) => {
@@ -230,5 +235,9 @@ module.exports = ( config ) => {
 
 	gulp.task( 'build', [ 'build:clean' ], tasks.build );
 
+	gulp.task( 'build-esnext', () => {
+		return tasks.build( { formats: 'esnext' } );
+	} );
+
 	return tasks;
 };

+ 4 - 1
dev/tasks/build/utils.js

@@ -1,4 +1,7 @@
-/* jshint node: true, esnext: true */
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
 
 'use strict';
 

+ 4 - 1
dev/tasks/dev/tasks.js

@@ -1,4 +1,7 @@
-/* jshint node: true, esnext: true */
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
 
 'use strict';
 

+ 23 - 0
dev/tasks/docs/jsdoc.json

@@ -0,0 +1,23 @@
+{
+	"opts": {
+		"encoding": "utf8",
+		"destination": "dist/docs",
+		"recurse": true,
+		"access": "all"
+	},
+	"plugins": [
+		"node_modules/jsdoc/plugins/markdown",
+		"dev/tasks/docs/plugins/comment-fixer"
+	],
+	"source": {
+		"include": [
+			"dist/esnext"
+		],
+		"exclude": [
+			"dist/esnext/test",
+			"dist/esnext/ckeditor5/core/lib"
+		],
+		"includePattern": ".+\\.js(doc)?$",
+		"excludePattern": "(^|\\/|\\\\)_"
+	}
+}

+ 33 - 0
dev/tasks/docs/plugins/comment-fixer.js

@@ -0,0 +1,33 @@
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+module.exports = {
+	handlers: {
+		/**
+		 * @see http://usejsdoc.org/about-plugins.html#event-beforeparse
+		 * @param evt
+		 */
+		beforeParse: function( evt ) {
+			'use strict';
+
+			let className;
+			let foundClassName = /export default class ([A-Za-z]+)/.exec( evt.source );
+
+			// Fix for {@link https://github.com/jsdoc3/jsdoc/issues/1137}. Export default class is not parsed by jsdoc 3.4.
+			if ( foundClassName ) {
+				className = foundClassName[ 1 ];
+				evt.source =
+					evt.source.replace( 'export default class', 'class' ) +
+					'\nexport default ' + className + ';\n';
+			}
+
+			// TODO: jsdoc fail to parse method with expanded argument list
+			evt.source = evt.source.replace( '...}', '}' );
+
+			// Make code in comments indented with one tab so it will not be shifted.
+			evt.source = evt.source.replace( /\*\t\t/g, '*\t' );
+		}
+	}
+};

+ 19 - 0
dev/tasks/docs/tasks.js

@@ -0,0 +1,19 @@
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+'use strict';
+
+const gulp = require( 'gulp' );
+const jsdoc = require( 'gulp-jsdoc3' );
+
+module.exports = () => {
+	gulp.task( 'docs', [ 'build-esnext' ], function( cb ) {
+		const config = require( './jsdoc.json' );
+
+		// Add the readme to the output.
+		gulp.src( [ 'README.md' ], { read: false } )
+			.pipe( jsdoc( config, cb ) );
+	} );
+};

+ 1 - 0
gulpfile.js

@@ -18,6 +18,7 @@ const config = {
 require( './dev/tasks/build/tasks' )( config );
 require( './dev/tasks/dev/tasks' )( config );
 require( './dev/tasks/lint/tasks' )( config );
+require( './dev/tasks/docs/tasks' )( config );
 
 gulp.task( 'default', [ 'build' ] );
 gulp.task( 'pre-commit', [ 'lint-staged' ] );

+ 2 - 0
package.json

@@ -31,6 +31,7 @@
     "gulp-babel": "^6.1.0",
     "gulp-filter": "^3.0.1",
     "gulp-jscs": "^3.0.2",
+    "gulp-jsdoc3": "^0.2.0",
     "gulp-jshint": "^2.0.0",
     "gulp-mirror": "^1",
     "gulp-rename": "^1.2.2",
@@ -40,6 +41,7 @@
     "guppy-pre-commit": "^0.3.0",
     "inquirer": "^0.11.0",
     "istanbul": "^0.4.1",
+    "jsdoc": "^3.4.0",
     "jshint": "^2.9.1",
     "jshint-reporter-jscs": "^0.1.0",
     "merge-stream": "^1.0.0",