@ckeditor/ckeditor5-dev-docs 43.0.0-alpha.0 → 44.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/build.js CHANGED
@@ -3,51 +3,96 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
6
+ import glob from 'fast-glob';
7
+ import TypeDoc from 'typedoc';
8
+ import typedocPlugins from '@ckeditor/typedoc-plugins';
9
+
10
+ import validators from './validators/index.js';
7
11
 
8
12
  /**
9
- * Builds CKEditor 5 documentation.
13
+ * Builds CKEditor 5 documentation using `typedoc`.
10
14
  *
11
- * @param {JSDocConfig|TypedocConfig} config
15
+ * @param {TypedocConfig} config
12
16
  * @returns {Promise}
13
17
  */
14
- module.exports = async function build( config ) {
15
- const type = config.type || 'jsdoc';
16
-
17
- if ( type === 'jsdoc' ) {
18
- return require( './buildjsdoc' )( config );
19
- } else if ( type === 'typedoc' ) {
20
- return require( './buildtypedoc' )( config );
21
- } else {
22
- throw new Error( `Unknown documentation tool (${ type }).` );
18
+ export default async function build( config ) {
19
+ const { plugins } = typedocPlugins;
20
+ const sourceFilePatterns = config.sourceFiles.filter( Boolean );
21
+ const strictMode = config.strict || false;
22
+ const extraPlugins = config.extraPlugins || [];
23
+ const validatorOptions = config.validatorOptions || {};
24
+
25
+ const files = await glob( sourceFilePatterns );
26
+ const typeDoc = new TypeDoc.Application();
27
+
28
+ typeDoc.options.addReader( new TypeDoc.TSConfigReader() );
29
+ typeDoc.options.addReader( new TypeDoc.TypeDocReader() );
30
+
31
+ typeDoc.bootstrap( {
32
+ tsconfig: config.tsconfig,
33
+ excludeExternals: true,
34
+ entryPoints: files,
35
+ logLevel: 'Warn',
36
+ basePath: config.cwd,
37
+ blockTags: [
38
+ '@eventName',
39
+ '@default'
40
+ ],
41
+ inlineTags: [
42
+ '@link',
43
+ '@glink'
44
+ ],
45
+ modifierTags: [
46
+ '@publicApi',
47
+ '@skipSource',
48
+ '@internal'
49
+ ],
50
+ plugin: [
51
+ // Fixes `"name": 'default" in the output project.
52
+ 'typedoc-plugin-rename-defaults',
53
+
54
+ plugins[ 'typedoc-plugin-module-fixer' ],
55
+ plugins[ 'typedoc-plugin-symbol-fixer' ],
56
+ plugins[ 'typedoc-plugin-interface-augmentation-fixer' ],
57
+ plugins[ 'typedoc-plugin-tag-error' ],
58
+ plugins[ 'typedoc-plugin-tag-event' ],
59
+ plugins[ 'typedoc-plugin-tag-observable' ],
60
+ plugins[ 'typedoc-plugin-purge-private-api-docs' ],
61
+
62
+ // The `event-inheritance-fixer` plugin must be loaded after `tag-event` plugin, as it depends on its output.
63
+ plugins[ 'typedoc-plugin-event-inheritance-fixer' ],
64
+
65
+ // The `event-param-fixer` plugin must be loaded after `tag-event` and `tag-observable` plugins, as it depends on their output.
66
+ plugins[ 'typedoc-plugin-event-param-fixer' ],
67
+
68
+ ...extraPlugins
69
+ ]
70
+ } );
71
+
72
+ console.log( 'Typedoc started...' );
73
+
74
+ const conversionResult = typeDoc.convert();
75
+
76
+ if ( !conversionResult ) {
77
+ throw 'Something went wrong with TypeDoc.';
23
78
  }
24
- };
25
79
 
26
- /**
27
- * @typedef {Object} JSDocConfig
28
- *
29
- * @property {'jsdoc'} type
30
- *
31
- * @property {Array.<String>} sourceFiles Glob pattern with source files.
32
- *
33
- * @property {String} readmePath Path to `README.md`.
34
- *
35
- * @property {Boolean} [validateOnly=false] Whether JSDoc should only validate the documentation and finish
36
- * with error code `1`. If not passed, the errors will be printed to the console but the task will finish with `0`.
37
- *
38
- * @property {Boolean} [strict=false] If `true`, errors found during the validation will finish the process
39
- * and exit code will be changed to `1`.
40
- *
41
- * @property {String} [outputPath='docs/api/output.json'] A path to the place where extracted doclets will be saved.
42
- *
43
- * @property {String} [extraPlugins=[]] An array of path to extra plugins that will be added to JSDoc.
44
- */
80
+ const validationResult = validators.validate( conversionResult, typeDoc, validatorOptions );
81
+
82
+ if ( !validationResult && strictMode ) {
83
+ throw 'Something went wrong with TypeDoc.';
84
+ }
85
+
86
+ if ( config.outputPath ) {
87
+ await typeDoc.generateJson( conversionResult, config.outputPath );
88
+ }
89
+
90
+ console.log( `Documented ${ files.length } files!` );
91
+ }
45
92
 
46
93
  /**
47
94
  * @typedef {Object} TypedocConfig
48
95
  *
49
- * @property {'typedoc'} type
50
- *
51
96
  * @property {Object} config
52
97
  *
53
98
  * @property {String} cwd
package/lib/index.js CHANGED
@@ -3,10 +3,4 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const build = require( './build' );
9
-
10
- module.exports = {
11
- build
12
- };
6
+ export { default as build } from './build.js';
@@ -3,10 +3,8 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const { ReflectionKind } = require( 'typedoc' );
9
- const { utils } = require( '@ckeditor/typedoc-plugins' );
6
+ import { ReflectionKind } from 'typedoc';
7
+ import typedocPlugins from '@ckeditor/typedoc-plugins';
10
8
 
11
9
  /**
12
10
  * Validates the output produced by TypeDoc.
@@ -16,7 +14,8 @@ const { utils } = require( '@ckeditor/typedoc-plugins' );
16
14
  * @param {Object} project Generated output from TypeDoc to validate.
17
15
  * @param {Function} onError A callback that is executed when a validation error is detected.
18
16
  */
19
- module.exports = function validate( project, onError ) {
17
+ export default function validate( project, onError ) {
18
+ const { utils } = typedocPlugins;
20
19
  const reflections = project
21
20
  .getReflectionsByKind( ReflectionKind.Class | ReflectionKind.CallSignature )
22
21
  .filter( utils.isReflectionValid );
@@ -38,9 +37,11 @@ module.exports = function validate( project, onError ) {
38
37
  }
39
38
  }
40
39
  }
41
- };
40
+ }
42
41
 
43
42
  function getIdentifiersFromFiresTag( reflection ) {
43
+ const { utils } = typedocPlugins;
44
+
44
45
  if ( !reflection.comment ) {
45
46
  return [];
46
47
  }
@@ -3,14 +3,12 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const { utils } = require( '@ckeditor/typedoc-plugins' );
9
- const seeValidator = require( './see-validator' );
10
- const linkValidator = require( './link-validator' );
11
- const firesValidator = require( './fires-validator' );
12
- const moduleValidator = require( './module-validator' );
13
- const overloadsValidator = require( './overloads-validator' );
6
+ import typedocPlugins from '@ckeditor/typedoc-plugins';
7
+ import seeValidator from './see-validator/index.js';
8
+ import linkValidator from './link-validator/index.js';
9
+ import firesValidator from './fires-validator/index.js';
10
+ import moduleValidator from './module-validator/index.js';
11
+ import overloadsValidator from './overloads-validator/index.js';
14
12
 
15
13
  /**
16
14
  * Validates the CKEditor 5 documentation.
@@ -20,8 +18,9 @@ const overloadsValidator = require( './overloads-validator' );
20
18
  * @param {TypedocValidator} [options={}] A configuration object.
21
19
  * @returns {Boolean}
22
20
  */
23
- module.exports = {
21
+ export default {
24
22
  validate( project, typeDoc, options = {} ) {
23
+ const { utils } = typedocPlugins;
25
24
  const validators = [
26
25
  seeValidator,
27
26
  linkValidator,
@@ -3,10 +3,8 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const { ReflectionKind } = require( 'typedoc' );
9
- const { utils } = require( '@ckeditor/typedoc-plugins' );
6
+ import { ReflectionKind } from 'typedoc';
7
+ import typedocPlugins from '@ckeditor/typedoc-plugins';
10
8
 
11
9
  /**
12
10
  * Validates the output produced by TypeDoc.
@@ -16,7 +14,8 @@ const { utils } = require( '@ckeditor/typedoc-plugins' );
16
14
  * @param {Object} project Generated output from TypeDoc to validate.
17
15
  * @param {Function} onError A callback that is executed when a validation error is detected.
18
16
  */
19
- module.exports = function validate( project, onError ) {
17
+ export default function validate( project, onError ) {
18
+ const { utils } = typedocPlugins;
20
19
  const reflections = project.getReflectionsByKind( ReflectionKind.All ).filter( utils.isReflectionValid );
21
20
 
22
21
  for ( const reflection of reflections ) {
@@ -34,7 +33,7 @@ module.exports = function validate( project, onError ) {
34
33
  }
35
34
  }
36
35
  }
37
- };
36
+ }
38
37
 
39
38
  function getIdentifiersFromLinkTag( reflection ) {
40
39
  if ( !reflection.comment ) {
@@ -3,10 +3,8 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const { ReflectionKind } = require( 'typedoc' );
9
- const { utils } = require( '@ckeditor/typedoc-plugins' );
6
+ import { ReflectionKind } from 'typedoc';
7
+ import typedocPlugins from '@ckeditor/typedoc-plugins';
10
8
 
11
9
  const AUGMENTATION_MODULE_REGEXP = /[^\\/]+[\\/]src[\\/]augmentation/;
12
10
 
@@ -18,7 +16,8 @@ const AUGMENTATION_MODULE_REGEXP = /[^\\/]+[\\/]src[\\/]augmentation/;
18
16
  * @param {Object} project Generated output from TypeDoc to validate.
19
17
  * @param {Function} onError A callback that is executed when a validation error is detected.
20
18
  */
21
- module.exports = function validate( project, onError ) {
19
+ export default function validate( project, onError ) {
20
+ const { utils } = typedocPlugins;
22
21
  const reflections = project.getReflectionsByKind( ReflectionKind.Module );
23
22
 
24
23
  for ( const reflection of reflections ) {
@@ -53,4 +52,4 @@ module.exports = function validate( project, onError ) {
53
52
  onError( `Invalid module name: "${ reflection.name }"`, reflection );
54
53
  }
55
54
  }
56
- };
55
+ }
@@ -3,10 +3,8 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const { ReflectionKind } = require( 'typedoc' );
9
- const { utils } = require( '@ckeditor/typedoc-plugins' );
6
+ import { ReflectionKind } from 'typedoc';
7
+ import typedocPlugins from '@ckeditor/typedoc-plugins';
10
8
 
11
9
  // The `@label` validator is currently not used.
12
10
  // See: https://github.com/ckeditor/ckeditor5/issues/13591.
@@ -21,7 +19,8 @@ const { utils } = require( '@ckeditor/typedoc-plugins' );
21
19
  * @param {Object} project Generated output from TypeDoc to validate.
22
20
  * @param {Function} onError A callback that is executed when a validation error is detected.
23
21
  */
24
- module.exports = function validate( project, onError ) {
22
+ export default function validate( project, onError ) {
23
+ const { utils } = typedocPlugins;
25
24
  const kinds = ReflectionKind.Method | ReflectionKind.Constructor | ReflectionKind.Function;
26
25
  const reflections = project.getReflectionsByKind( kinds ).filter( utils.isReflectionValid );
27
26
 
@@ -52,4 +51,4 @@ module.exports = function validate( project, onError ) {
52
51
  }
53
52
  }
54
53
  }
55
- };
54
+ }
@@ -3,10 +3,8 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const { ReflectionKind } = require( 'typedoc' );
9
- const { utils } = require( '@ckeditor/typedoc-plugins' );
6
+ import { ReflectionKind } from 'typedoc';
7
+ import typedocPlugins from '@ckeditor/typedoc-plugins';
10
8
 
11
9
  /**
12
10
  * Validates the output produced by TypeDoc.
@@ -16,7 +14,8 @@ const { utils } = require( '@ckeditor/typedoc-plugins' );
16
14
  * @param {Object} project Generated output from TypeDoc to validate.
17
15
  * @param {Function} onError A callback that is executed when a validation error is detected.
18
16
  */
19
- module.exports = function validate( project, onError ) {
17
+ export default function validate( project, onError ) {
18
+ const { utils } = typedocPlugins;
20
19
  const reflections = project.getReflectionsByKind( ReflectionKind.All ).filter( utils.isReflectionValid );
21
20
 
22
21
  for ( const reflection of reflections ) {
@@ -34,7 +33,7 @@ module.exports = function validate( project, onError ) {
34
33
  }
35
34
  }
36
35
  }
37
- };
36
+ }
38
37
 
39
38
  function getIdentifiersFromSeeTag( reflection ) {
40
39
  if ( !reflection.comment ) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-dev-docs",
3
- "version": "43.0.0-alpha.0",
3
+ "version": "44.0.0-alpha.0",
4
4
  "description": "Tasks used to build and verify the documentation for CKEditor 5.",
5
5
  "keywords": [],
6
6
  "author": "CKSource (http://cksource.com/)",
@@ -16,17 +16,16 @@
16
16
  "node": ">=18.0.0",
17
17
  "npm": ">=5.7.1"
18
18
  },
19
+ "type": "module",
19
20
  "main": "lib/index.js",
20
21
  "files": [
21
22
  "lib"
22
23
  ],
23
24
  "dependencies": {
24
- "@ckeditor/ckeditor5-dev-utils": "^43.0.0-alpha.0",
25
- "@ckeditor/jsdoc-plugins": "^43.0.0-alpha.0",
26
- "@ckeditor/typedoc-plugins": "^43.0.0-alpha.0",
25
+ "@ckeditor/ckeditor5-dev-utils": "^44.0.0-alpha.0",
26
+ "@ckeditor/typedoc-plugins": "^44.0.0-alpha.0",
27
27
  "fast-glob": "^3.2.4",
28
28
  "fs-extra": "^11.2.0",
29
- "jsdoc": "ckeditor/jsdoc#fixed-trailing-comment-doclets",
30
29
  "tmp": "^0.2.1",
31
30
  "typedoc": "^0.23.15",
32
31
  "typedoc-plugin-rename-defaults": "0.6.6"
package/lib/buildjsdoc.js DELETED
@@ -1,93 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md.
4
- */
5
-
6
- 'use strict';
7
-
8
- const fs = require( 'fs-extra' );
9
- const tmp = require( 'tmp' );
10
- const glob = require( 'fast-glob' );
11
- const { tools } = require( '@ckeditor/ckeditor5-dev-utils' );
12
-
13
- /**
14
- * Builds CKEditor 5 documentation using `jsdoc`.
15
- *
16
- * @param {JSDocConfig} config
17
- * @returns {Promise}
18
- */
19
- module.exports = async function build( config ) {
20
- const sourceFilePatterns = [
21
- config.readmePath,
22
- ...config.sourceFiles
23
- ];
24
-
25
- const extraPlugins = config.extraPlugins || [];
26
- const outputPath = config.outputPath || 'docs/api/output.json';
27
- const validateOnly = config.validateOnly || false;
28
- const strictCheck = config.strict || false;
29
-
30
- // Pass options to plugins via env variables.
31
- // Since plugins are added using `require` calls other forms are currently impossible.
32
- process.env.JSDOC_OUTPUT_PATH = outputPath;
33
-
34
- if ( validateOnly ) {
35
- process.env.JSDOC_VALIDATE_ONLY = 'true';
36
- }
37
-
38
- if ( strictCheck ) {
39
- process.env.JSDOC_STRICT_CHECK = 'true';
40
- }
41
-
42
- const files = await glob( sourceFilePatterns );
43
-
44
- const jsDocConfig = {
45
- plugins: [
46
- require.resolve( 'jsdoc/plugins/markdown' ),
47
- require.resolve( '@ckeditor/jsdoc-plugins/lib/purge-private-api-docs' ),
48
- require.resolve( '@ckeditor/jsdoc-plugins/lib/export-fixer/export-fixer' ),
49
- require.resolve( '@ckeditor/jsdoc-plugins/lib/custom-tags/error' ),
50
- require.resolve( '@ckeditor/jsdoc-plugins/lib/custom-tags/observable' ),
51
- require.resolve( '@ckeditor/jsdoc-plugins/lib/observable-event-provider' ),
52
- require.resolve( '@ckeditor/jsdoc-plugins/lib/longname-fixer/longname-fixer' ),
53
- require.resolve( '@ckeditor/jsdoc-plugins/lib/fix-code-snippets' ),
54
- require.resolve( '@ckeditor/jsdoc-plugins/lib/relation-fixer' ),
55
- require.resolve( '@ckeditor/jsdoc-plugins/lib/event-extender/event-extender' ),
56
- require.resolve( '@ckeditor/jsdoc-plugins/lib/cleanup' ),
57
- require.resolve( '@ckeditor/jsdoc-plugins/lib/validator/validator' ),
58
- require.resolve( '@ckeditor/jsdoc-plugins/lib/utils/doclet-logger' ),
59
- ...extraPlugins
60
- ],
61
- source: {
62
- include: files
63
- },
64
- opts: {
65
- encoding: 'utf8',
66
- recurse: true,
67
- access: 'all',
68
- template: 'templates/silent'
69
- }
70
- };
71
-
72
- const tmpConfig = tmp.fileSync();
73
-
74
- await fs.writeFile( tmpConfig.name, JSON.stringify( jsDocConfig ) );
75
-
76
- console.log( 'JSDoc started...' );
77
-
78
- try {
79
- // Not so beautiful API as for 2020...
80
- // See more in https://github.com/jsdoc/jsdoc/issues/938.
81
- const cmd = require.resolve( 'jsdoc/jsdoc.js' );
82
-
83
- // The `node` command is used for explicitly needed for Windows.
84
- // See https://github.com/ckeditor/ckeditor5/issues/7212.
85
- tools.shExec( `node ${ cmd } -c ${ tmpConfig.name }`, { verbosity: 'info' } );
86
- } catch ( error ) {
87
- console.error( 'An error was thrown by JSDoc:' );
88
-
89
- throw error;
90
- }
91
-
92
- console.log( `Documented ${ files.length } files!` );
93
- };
@@ -1,92 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md.
4
- */
5
-
6
- 'use strict';
7
-
8
- const glob = require( 'fast-glob' );
9
- const TypeDoc = require( 'typedoc' );
10
- const { plugins } = require( '@ckeditor/typedoc-plugins' );
11
-
12
- const validators = require( './validators' );
13
-
14
- /**
15
- * Builds CKEditor 5 documentation using `typedoc`.
16
- *
17
- * @param {TypedocConfig} config
18
- * @returns {Promise}
19
- */
20
- module.exports = async function build( config ) {
21
- const sourceFilePatterns = config.sourceFiles.filter( Boolean );
22
- const strictMode = config.strict || false;
23
- const extraPlugins = config.extraPlugins || [];
24
- const validatorOptions = config.validatorOptions || {};
25
-
26
- const files = await glob( sourceFilePatterns );
27
- const typeDoc = new TypeDoc.Application();
28
-
29
- typeDoc.options.addReader( new TypeDoc.TSConfigReader() );
30
- typeDoc.options.addReader( new TypeDoc.TypeDocReader() );
31
-
32
- typeDoc.bootstrap( {
33
- tsconfig: config.tsconfig,
34
- excludeExternals: true,
35
- entryPoints: files,
36
- logLevel: 'Warn',
37
- basePath: config.cwd,
38
- blockTags: [
39
- '@eventName',
40
- '@default'
41
- ],
42
- inlineTags: [
43
- '@link',
44
- '@glink'
45
- ],
46
- modifierTags: [
47
- '@publicApi',
48
- '@skipSource',
49
- '@internal'
50
- ],
51
- plugin: [
52
- // Fixes `"name": 'default" in the output project.
53
- 'typedoc-plugin-rename-defaults',
54
-
55
- plugins[ 'typedoc-plugin-module-fixer' ],
56
- plugins[ 'typedoc-plugin-symbol-fixer' ],
57
- plugins[ 'typedoc-plugin-interface-augmentation-fixer' ],
58
- plugins[ 'typedoc-plugin-tag-error' ],
59
- plugins[ 'typedoc-plugin-tag-event' ],
60
- plugins[ 'typedoc-plugin-tag-observable' ],
61
- plugins[ 'typedoc-plugin-purge-private-api-docs' ],
62
-
63
- // The `event-inheritance-fixer` plugin must be loaded after `tag-event` plugin, as it depends on its output.
64
- plugins[ 'typedoc-plugin-event-inheritance-fixer' ],
65
-
66
- // The `event-param-fixer` plugin must be loaded after `tag-event` and `tag-observable` plugins, as it depends on their output.
67
- plugins[ 'typedoc-plugin-event-param-fixer' ],
68
-
69
- ...extraPlugins
70
- ]
71
- } );
72
-
73
- console.log( 'Typedoc started...' );
74
-
75
- const conversionResult = typeDoc.convert();
76
-
77
- if ( !conversionResult ) {
78
- throw 'Something went wrong with TypeDoc.';
79
- }
80
-
81
- const validationResult = validators.validate( conversionResult, typeDoc, validatorOptions );
82
-
83
- if ( !validationResult && strictMode ) {
84
- throw 'Something went wrong with TypeDoc.';
85
- }
86
-
87
- if ( config.outputPath ) {
88
- await typeDoc.generateJson( conversionResult, config.outputPath );
89
- }
90
-
91
- console.log( `Documented ${ files.length } files!` );
92
- };