umberto 2.2.0 → 2.3.1
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/.eslintrc.js +4 -3
- package/LICENSE.md +1 -1
- package/hexo-shim.js +1 -1
- package/package.json +6 -2
- package/scripts/filter/after-post-render/basepath-replacer.js +1 -1
- package/scripts/filter/after-post-render/fix-code-samples.js +1 -1
- package/scripts/filter/after-post-render/gather-guides.js +1 -1
- package/scripts/filter/after-post-render/img-linker.js +1 -1
- package/scripts/filter/after-post-render/import-guide.js +1 -1
- package/scripts/filter/after-post-render/insert-error-codes.js +4 -2
- package/scripts/filter/after-post-render/linker.js +1 -1
- package/scripts/filter/after-post-render/parseicontag.js +1 -1
- package/scripts/filter/after-post-render/process-variables.js +1 -1
- package/scripts/filter/after-post-render/snippets.js +1 -1
- package/scripts/filter/after-post-render/time-end.js +1 -1
- package/scripts/filter/after-post-render/time-start.js +1 -1
- package/scripts/filter/after-post-render/validate-after-render.js +1 -1
- package/scripts/filter/before-post-render/add-project-info-to-page.js +1 -1
- package/scripts/filter/before-post-render/add-repo-url.js +1 -1
- package/scripts/filter/before-post-render/change-output-path.js +1 -1
- package/scripts/filter/before-post-render/escape-special-characters.js +1 -1
- package/scripts/filter/before-post-render/execute-and-insert-function-results.js +1 -1
- package/scripts/filter/before-post-render/infobox.js +1 -1
- package/scripts/filter/before-post-render/insertchangelog.js +1 -1
- package/scripts/filter/before-post-render/replace-macros.js +1 -1
- package/scripts/filter/before-post-render/set-layout.js +1 -1
- package/scripts/filter/before-post-render/validate-page-data.js +1 -1
- package/scripts/helper/find-main-category-page.js +1 -1
- package/scripts/helper/get-pages-for-nav-tree.js +1 -1
- package/scripts/helper/mark-empty-categories.js +1 -1
- package/scripts/helper/normalize-badges.js +1 -1
- package/scripts/helper/u-split-to-title-and-content.js +1 -1
- package/scripts/helper/u-toc.js +1 -1
- package/scripts/utils/execute-and-insert-function-results.js +1 -1
- package/scripts/utils/findmaincategorypage.js +1 -1
- package/scripts/utils/getreportissuewidgeturl.js +1 -1
- package/scripts/utils/insertchangelog.js +1 -1
- package/scripts/utils/normalizebadges.js +1 -1
- package/scripts/utils/parseicontag.js +1 -1
- package/scripts/utils/parselinks.js +61 -41
- package/scripts/utils/shoulddisplaynewindicator.js +1 -1
- package/scripts/utils/transforminfobox.js +14 -3
- package/scripts-dev/postinstall.js +1 -1
- package/src/api-builder/api-builder.js +28 -8
- package/src/api-builder/classes/description-parser.js +79 -63
- package/src/api-builder/classes/doc-data-factory.js +58 -5
- package/src/api-builder/classes/file-name-manager.js +1 -1
- package/src/api-builder/classes/html-file.js +1 -1
- package/src/api-builder/classes/navigation-tree.js +1 -1
- package/src/api-builder/classes/tree-node.js +1 -1
- package/src/api-builder/utils/findtargetdoclet.js +84 -0
- package/src/api-builder/utils/utils.js +41 -0
- package/src/data-converter/converters/jsdoc2umberto.js +8 -1
- package/src/data-converter/converters/jsduck2umberto.js +1 -1
- package/src/data-converter/converters/typedoc/abstractparser.js +372 -0
- package/src/data-converter/converters/typedoc/accessorparser.js +64 -0
- package/src/data-converter/converters/typedoc/classparser.js +49 -0
- package/src/data-converter/converters/typedoc/constantparser.js +45 -0
- package/src/data-converter/converters/typedoc/constructorparser.js +34 -0
- package/src/data-converter/converters/typedoc/errorparser.js +44 -0
- package/src/data-converter/converters/typedoc/eventparser.js +57 -0
- package/src/data-converter/converters/typedoc/functionparser.js +61 -0
- package/src/data-converter/converters/typedoc/interfaceparser.js +46 -0
- package/src/data-converter/converters/typedoc/methodparser.js +63 -0
- package/src/data-converter/converters/typedoc/moduleparser.js +31 -0
- package/src/data-converter/converters/typedoc/propertyparser.js +74 -0
- package/src/data-converter/converters/typedoc/typedoc.ts +299 -0
- package/src/data-converter/converters/typedoc/typedocconverter.js +759 -0
- package/src/data-converter/converters/typedoc/typeparser.js +71 -0
- package/src/data-converter/converters/typedoc2umberto.js +52 -0
- package/src/data-converter/data-collection.js +1 -1
- package/src/data-converter/data-provider.js +4 -2
- package/src/data-converter/doclet-collection.js +14 -2
- package/src/data-converter/middlewares/relation-fixer.js +1 -1
- package/src/helpers/capitalize.js +1 -1
- package/src/helpers/copy-file.js +1 -1
- package/src/helpers/create-filtering-data-attribs.js +1 -1
- package/src/helpers/doc-formats.js +3 -2
- package/src/helpers/escape-longname.js +1 -1
- package/src/helpers/extract-longname.js +1 -1
- package/src/helpers/get-api-infobox-tooltip.js +1 -1
- package/src/helpers/get-docsearch-config.js +1 -1
- package/src/helpers/get-file-patterns-to-process.js +1 -1
- package/src/helpers/get-short-module-path.js +1 -1
- package/src/helpers/github-url.js +1 -1
- package/src/helpers/glob-to-regexp.js +1 -1
- package/src/helpers/html-safe.js +1 -1
- package/src/helpers/is-non-empty-array.js +1 -1
- package/src/helpers/snippets.js +1 -1
- package/src/helpers/split-longname.js +101 -8
- package/src/hexo/filter/extend-config.js +1 -1
- package/src/hexo/filter/project-locals.js +1 -1
- package/src/hexo/get-repo-urls.js +1 -1
- package/src/hexo/helper/get-page-group.js +1 -1
- package/src/hexo/project-globals.js +1 -1
- package/src/hexo-manager.js +1 -1
- package/src/index.js +1 -1
- package/src/sdk-builder/get-sdk-sources.js +1 -1
- package/src/sdk-builder/sdk-builder.js +1 -1
- package/src/tasks/build-api-docs.js +4 -4
- package/src/tasks/build-documentation.js +3 -3
- package/src/tasks/build-sdk.js +1 -1
- package/src/tasks/build-snippets.js +1 -1
- package/src/tasks/cache-files.js +1 -1
- package/src/tasks/compile-sass.js +1 -1
- package/src/tasks/copy-assets.js +1 -1
- package/src/tasks/copy-files.js +1 -1
- package/src/tasks/copy-project-docs.js +1 -1
- package/src/tasks/copy-project-icons.js +1 -1
- package/src/tasks/create-redirect-page.js +1 -1
- package/src/tasks/create-sitemap.js +1 -1
- package/src/tasks/create-sym-links.js +1 -1
- package/src/tasks/execute-hooks.js +1 -1
- package/src/tasks/get-extra-files.js +1 -1
- package/src/tasks/get-hexo-config.js +1 -1
- package/src/tasks/get-main-config.js +1 -1
- package/src/tasks/get-project-config.js +3 -3
- package/src/tasks/macro-replacer.js +1 -1
- package/src/tasks/overwrite-api-guides.js +1 -1
- package/src/tasks/read-doc-sources.js +1 -1
- package/src/tasks/run-webpack.js +1 -1
- package/src/tasks/validate-html-w3c.js +1 -1
- package/src/tasks/validate-links.js +1 -1
- package/src/tasks/watcher.js +1 -1
- package/src/tasks/write-html-files.js +1 -1
- package/src/template/template-collection.js +1 -1
- package/themes/umberto/layout/_api-docs/_mixin/_api-see-source.pug +2 -1
- package/themes/umberto/layout/_api-docs/_mixin/_class-item.pug +0 -1
- package/themes/umberto/layout/_api-docs/_mixin/_dev-names.pug +9 -3
- package/themes/umberto/layout/_api-docs/_mixin/_fires-item.pug +2 -2
- package/themes/umberto/layout/_api-docs/_mixin/_hierarchy-item.pug +2 -2
- package/themes/umberto/layout/_api-docs/_mixin/_link-or-text.pug +40 -41
- package/themes/umberto/layout/_api-docs/_mixin/_method.pug +8 -2
- package/themes/umberto/layout/_api-docs/_mixin/_property.pug +1 -1
- package/themes/umberto/layout/_api-docs/_mixin/_related.pug +1 -1
- package/themes/umberto/layout/_api-docs/_mixin/_sidebox-list-item.pug +1 -1
- package/themes/umberto/layout/_api-docs/_mixin/_type.pug +175 -9
- package/themes/umberto/layout/_api-docs/_mixin/type-parameter.pug +18 -0
- package/themes/umberto/layout/_api-docs/_partial/filter.pug +16 -4
- package/themes/umberto/layout/_api-docs/_partial/type-parameters.pug +26 -0
- package/themes/umberto/layout/_api-docs/api-base.pug +2 -0
- package/themes/umberto/src/css/_api-content.scss +1 -1
- package/themes/umberto/src/css/_api-info-box.scss +1 -1
- package/themes/umberto/src/css/_api-props-filter.scss +1 -1
- package/themes/umberto/src/css/_api-see-source.scss +1 -1
- package/themes/umberto/src/css/_api-subheader.scss +1 -1
- package/themes/umberto/src/css/_api-tree.scss +1 -1
- package/themes/umberto/src/css/_badge.scss +1 -1
- package/themes/umberto/src/css/_collapsinglist.scss +1 -1
- package/themes/umberto/src/css/_content.scss +3 -2
- package/themes/umberto/src/css/_docsearch.scss +1 -1
- package/themes/umberto/src/css/_dropdown.scss +1 -1
- package/themes/umberto/src/css/_editor-icon.scss +1 -1
- package/themes/umberto/src/css/_feedback-widget.scss +1 -1
- package/themes/umberto/src/css/_footer.scss +1 -1
- package/themes/umberto/src/css/_formatted.scss +1 -1
- package/themes/umberto/src/css/_guide-content.scss +1 -1
- package/themes/umberto/src/css/_guide-sdk-tree.scss +1 -1
- package/themes/umberto/src/css/_loading-spinner.scss +1 -1
- package/themes/umberto/src/css/_main.scss +1 -1
- package/themes/umberto/src/css/_navigation.scss +1 -1
- package/themes/umberto/src/css/_notice.scss +1 -1
- package/themes/umberto/src/css/_print.scss +1 -1
- package/themes/umberto/src/css/_prism.scss +1 -1
- package/themes/umberto/src/css/_rwd-breadcrumbs.scss +1 -1
- package/themes/umberto/src/css/_rwd-menu.scss +1 -1
- package/themes/umberto/src/css/_secondary-navigation.scss +1 -1
- package/themes/umberto/src/css/_theme-dark.scss +1 -1
- package/themes/umberto/src/css/_toggler.scss +1 -1
- package/themes/umberto/src/css/_top.scss +7 -1
- package/themes/umberto/src/css/_tree.scss +7 -5
- package/themes/umberto/src/css/_warning-banner.scss +1 -1
- package/themes/umberto/src/css/components/_lightbox.scss +1 -1
- package/themes/umberto/src/css/helpers/_color.scss +1 -1
- package/themes/umberto/src/css/helpers/_font.scss +1 -1
- package/themes/umberto/src/css/helpers/_globals.scss +1 -1
- package/themes/umberto/src/css/helpers/_reset.scss +1 -1
- package/themes/umberto/src/css/helpers/_spacing.scss +1 -1
- package/themes/umberto/src/css/pages/_sdk.scss +1 -1
- package/themes/umberto/src/css/styles.scss +1 -1
- package/themes/umberto/src/js/_anchors.js +1 -1
- package/themes/umberto/src/js/_apisearch.js +1 -1
- package/themes/umberto/src/js/_apitree.js +1 -1
- package/themes/umberto/src/js/_collapsables.js +1 -1
- package/themes/umberto/src/js/_copymobileapinavigation.js +1 -1
- package/themes/umberto/src/js/_devnames.js +1 -1
- package/themes/umberto/src/js/_dropdowns.js +1 -1
- package/themes/umberto/src/js/_filtering.js +2 -1
- package/themes/umberto/src/js/_imageModal.js +1 -1
- package/themes/umberto/src/js/_pagenavigation.js +1 -1
- package/themes/umberto/src/js/_prism.js +6 -1
- package/themes/umberto/src/js/_rwdmenu.js +1 -1
- package/themes/umberto/src/js/_samplecode.js +1 -1
- package/themes/umberto/src/js/_sidenavigation.js +1 -1
- package/themes/umberto/src/js/_toc.js +1 -1
- package/themes/umberto/src/js/_tooltips.js +1 -1
- package/themes/umberto/src/js/_warningbanner.js +1 -1
- package/themes/umberto/src/js/app.js +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2017-
|
|
2
|
+
* @license Copyright (c) 2017-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -9,6 +9,8 @@ const { default: cheerio } = require( 'cheerio' );
|
|
|
9
9
|
const splitLongname = require( '../../helpers/split-longname' );
|
|
10
10
|
const chalk = require( 'chalk' );
|
|
11
11
|
const macroReplacer = require( '../../tasks/macro-replacer' );
|
|
12
|
+
const findTargetDoclet = require( '../utils/findtargetdoclet' );
|
|
13
|
+
const { hasDedicatedApiPages, LONG_NAME_LABEL_REGEXP, LONG_NAME_MEMBER_SEPARATOR_REGEXP } = require( '../utils/utils' );
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Class responsible for parsing doc descriptions.
|
|
@@ -102,107 +104,121 @@ module.exports = class DescriptionParser {
|
|
|
102
104
|
|
|
103
105
|
/**
|
|
104
106
|
* Finds all {@link} and {@see} tags and converts them to links if possible. If not, converts to text.
|
|
107
|
+
*
|
|
105
108
|
* @param {String} str String to be parsed.
|
|
106
|
-
* @param {Object} options
|
|
109
|
+
* @param {Object} options
|
|
107
110
|
* @param {Doclet} options.doclet Parent doclet of currently processed item. Used to handle shorthand links.
|
|
111
|
+
* @param {Doclet} options.parentDoclet Parent of the parent. Used to handle shorthand links.
|
|
112
|
+
* @param {Boolean} options.asMember Whether the processed description is a child of the doclet.
|
|
108
113
|
* @returns {String} result Parsed string.
|
|
109
114
|
*/
|
|
110
115
|
_parseJSDocLinks( str, options = {} ) {
|
|
111
|
-
const regex = /{(?:@link|@see)\s+([
|
|
112
|
-
let result = str;
|
|
116
|
+
const regex = /{(?:@link|@see)\s+([^{]+?(?:{[^}]+})?([^{}]*\\?))}/g;
|
|
113
117
|
|
|
114
118
|
if ( str.indexOf( '@link' ) === -1 && str.indexOf( '@see' ) === -1 ) {
|
|
115
|
-
return
|
|
119
|
+
return str;
|
|
116
120
|
}
|
|
117
121
|
|
|
122
|
+
let result = str;
|
|
118
123
|
let match = regex.exec( str );
|
|
119
|
-
let href;
|
|
120
124
|
|
|
121
125
|
while ( match !== null ) {
|
|
122
|
-
|
|
123
|
-
let
|
|
126
|
+
const [ fullMatch ] = match;
|
|
127
|
+
let [ , longname, linkText ] = match[ 1 ].match( /^(\S+)\s*([\s\S]*)$/ );
|
|
128
|
+
let { longnameBase, name, label } = splitLongname( longname );
|
|
129
|
+
let structure, module, member, query;
|
|
124
130
|
|
|
125
131
|
if ( !options.asMember && ( longnameBase.startsWith( '~' ) || longname.startsWith( '~' ) || longname.startsWith( '#' ) ) ) {
|
|
126
|
-
|
|
127
|
-
|
|
132
|
+
member = name;
|
|
133
|
+
query = { skipModule: true };
|
|
134
|
+
structure = options.parentDoclet ? options.parentDoclet.longname : options.doclet.memberof;
|
|
135
|
+
|
|
136
|
+
// Shorthand: `#someMethod`.
|
|
137
|
+
// TODO: Why `#` only? Can it start with `.` or `~`?
|
|
128
138
|
if ( longname.startsWith( '#' ) ) {
|
|
129
|
-
|
|
130
|
-
}
|
|
139
|
+
member = longname.slice( 1 ).replace( LONG_NAME_LABEL_REGEXP, '' );
|
|
131
140
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
141
|
+
// It is needed due to the possible parsing of invalid links within the `@error` tag.
|
|
142
|
+
if ( options.doclet.longname ) {
|
|
143
|
+
structure = options.doclet.longname.split( LONG_NAME_MEMBER_SEPARATOR_REGEXP )[ 0 ];
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// Shorthand: `~SomeClass#someMethod`.
|
|
147
|
+
// Use the doclet full name as a reference to the structure.
|
|
148
|
+
else if ( longname.startsWith( '~' ) ) {
|
|
149
|
+
if ( options.doclet.longname ) {
|
|
150
|
+
structure = options.doclet.longname.split( '~' )[ 0 ];
|
|
151
|
+
|
|
152
|
+
// When looking for a different structure within the same module, include its name to search for proper doclets.
|
|
153
|
+
if ( longnameBase ) {
|
|
154
|
+
structure += `~${ longnameBase }`;
|
|
155
|
+
}
|
|
156
|
+
} else if ( options.parentDoclet && options.parentDoclet.longname ) {
|
|
157
|
+
structure = options.parentDoclet.longname.split( '~' )[ 0 ];
|
|
158
|
+
member = longname.slice( 1 );
|
|
159
|
+
}
|
|
146
160
|
}
|
|
147
161
|
} else {
|
|
162
|
+
// Normalize the specified link expression when linking within the module or definition (class, interface, etc.) scope.
|
|
148
163
|
if ( options.asMember && ( longnameBase.startsWith( '~' ) || longname.startsWith( '~' ) || longname.startsWith( '#' ) ) ) {
|
|
149
|
-
|
|
164
|
+
if ( longname.startsWith( '#' ) ) {
|
|
165
|
+
longname = options.doclet.longname + longname;
|
|
166
|
+
} else {
|
|
167
|
+
longname = options.doclet.memberof + longname;
|
|
168
|
+
}
|
|
169
|
+
|
|
150
170
|
const split = splitLongname( longname );
|
|
151
171
|
longnameBase = split.longnameBase;
|
|
152
172
|
name = split.name;
|
|
153
173
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
// extraId property looks like: method-methodName, or property-propertyName etc.
|
|
159
|
-
const linkTargetDocletByExtraId = this._dataCollection.get( `id:${ longnameBase }#${ name }` ).getFirst() ||
|
|
160
|
-
this._dataCollection.get( `id:${ longnameBase }.${ name }` ).getFirst() ||
|
|
161
|
-
this._dataCollection.get( `id:${ longnameBase }~${ name }` ).getFirst();
|
|
162
|
-
|
|
163
|
-
if ( docletByLongname ) {
|
|
164
|
-
href = this._fileNameManager.getUrl( longname ) ||
|
|
165
|
-
this._fileNameManager.getUrl( longnameBase, docletByLongname.extraId );
|
|
166
|
-
} else if ( linkTargetDocletByExtraId ) {
|
|
167
|
-
href = this._fileNameManager.getUrl( longname ) ||
|
|
168
|
-
this._fileNameManager.getUrl( longnameBase, linkTargetDocletByExtraId.extraId );
|
|
169
|
-
} else {
|
|
170
|
-
// The link may be written wrong, so try getting the doclet by longname, using # . or ~.
|
|
171
|
-
const linkTargetDoclet = this._dataCollection.get( `ln:${ longnameBase }#${ name }` ).getFirst() ||
|
|
172
|
-
this._dataCollection.get( `ln:${ longnameBase }.${ name }` ).getFirst() ||
|
|
173
|
-
this._dataCollection.get( `ln:${ longnameBase }~${ name }` ).getFirst();
|
|
174
|
-
|
|
175
|
-
if ( linkTargetDoclet ) {
|
|
176
|
-
href = this._fileNameManager.getUrl( longname ) ||
|
|
177
|
-
this._fileNameManager.getUrl( longnameBase, linkTargetDoclet.extraId );
|
|
178
|
-
}
|
|
179
|
-
}
|
|
174
|
+
|
|
175
|
+
module = longname;
|
|
176
|
+
structure = longnameBase;
|
|
177
|
+
member = name;
|
|
180
178
|
}
|
|
181
179
|
|
|
182
|
-
|
|
183
|
-
|
|
180
|
+
const targetDoclet = findTargetDoclet( this._dataCollection, { module, structure, member, label, query } );
|
|
181
|
+
let replaceToPhrase;
|
|
184
182
|
|
|
185
|
-
|
|
186
|
-
|
|
183
|
+
if ( targetDoclet ) {
|
|
184
|
+
let href;
|
|
185
|
+
|
|
186
|
+
if ( hasDedicatedApiPages( targetDoclet ) ) {
|
|
187
|
+
href = this._fileNameManager.getUrl( targetDoclet.longname );
|
|
187
188
|
} else {
|
|
189
|
+
href = [
|
|
190
|
+
this._fileNameManager.getUrl( targetDoclet.memberof ),
|
|
191
|
+
encodeURI( targetDoclet.extraId )
|
|
192
|
+
].join( '#' );
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if ( !linkText[ 3 ] && targetDoclet.kind === 'event' ) {
|
|
196
|
+
linkText = `event-${ targetDoclet.name }`;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
let linkContent = linkText;
|
|
200
|
+
|
|
201
|
+
if ( !linkText ) {
|
|
188
202
|
linkContent = `<code>${ splitLongname( longname.replace( 'event:', 'event-' ) ).name }</code>`;
|
|
189
203
|
}
|
|
190
204
|
|
|
191
|
-
|
|
192
|
-
result = result.replace( fullMatch, linkHtml );
|
|
205
|
+
replaceToPhrase = `<a href="${ href }">${ linkContent }</a>`;
|
|
193
206
|
} else {
|
|
194
|
-
console.log(
|
|
195
|
-
|
|
207
|
+
console.log(
|
|
208
|
+
`${ chalk.yellow( 'Warning:' ) } Invalid link in API docs: ${ chalk.gray( fullMatch ) }.`,
|
|
209
|
+
'There is no doclet of the link target.'
|
|
210
|
+
);
|
|
196
211
|
|
|
197
212
|
options.buildInfo.warningCount += 1;
|
|
198
213
|
|
|
199
214
|
if ( linkText ) {
|
|
200
|
-
|
|
215
|
+
replaceToPhrase = `<code>${ linkText } (${ longname })</code>`;
|
|
201
216
|
} else {
|
|
202
|
-
|
|
217
|
+
replaceToPhrase = `<code>${ longname }</code>`;
|
|
203
218
|
}
|
|
204
219
|
}
|
|
205
220
|
|
|
221
|
+
result = result.replace( fullMatch, replaceToPhrase );
|
|
206
222
|
match = regex.exec( str );
|
|
207
223
|
}
|
|
208
224
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2017-
|
|
2
|
+
* @license Copyright (c) 2017-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -115,15 +115,34 @@ module.exports = class DocDataFactory {
|
|
|
115
115
|
* @returns {Object}
|
|
116
116
|
*/
|
|
117
117
|
getClassShort( doclet, asMember = false ) {
|
|
118
|
+
const base = this._getBase( doclet, {
|
|
119
|
+
skipDescription: true
|
|
120
|
+
} );
|
|
121
|
+
|
|
118
122
|
const description = this._descriptionParser.parseDescription( doclet.description, {
|
|
119
123
|
doclet,
|
|
120
124
|
asMember,
|
|
121
125
|
buildInfo: this._options.buildInfo
|
|
122
126
|
} );
|
|
123
127
|
|
|
124
|
-
|
|
128
|
+
const itemData = {
|
|
125
129
|
description
|
|
126
|
-
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
if ( doclet.typeParameters ) {
|
|
133
|
+
itemData.typeParameters = doclet.typeParameters.map( typeParameter => {
|
|
134
|
+
if ( typeParameter.description ) {
|
|
135
|
+
typeParameter.description = this._descriptionParser.parseDescription( typeParameter.description, {
|
|
136
|
+
doclet,
|
|
137
|
+
buildInfo: this._options.buildInfo
|
|
138
|
+
} );
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return typeParameter;
|
|
142
|
+
} );
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return Object.assign( base, itemData );
|
|
127
146
|
}
|
|
128
147
|
|
|
129
148
|
/**
|
|
@@ -195,6 +214,8 @@ module.exports = class DocDataFactory {
|
|
|
195
214
|
itemData.returns = this._getMembers( doclet.returns );
|
|
196
215
|
}
|
|
197
216
|
|
|
217
|
+
itemData.typeParameters = doclet.typeParameters || null;
|
|
218
|
+
|
|
198
219
|
return Object.assign( base, itemData );
|
|
199
220
|
}
|
|
200
221
|
|
|
@@ -243,7 +264,7 @@ module.exports = class DocDataFactory {
|
|
|
243
264
|
const methods = classMembersCollection.get( 'function' );
|
|
244
265
|
const events = classMembersCollection.get( 'event' );
|
|
245
266
|
const configOptionsProcessed = this._getMembers( configOptions, { parentDoclet: doclet } );
|
|
246
|
-
// Sorting properties alphabetically and also public > protected > private.
|
|
267
|
+
// Sorting properties alphabetically and also public > internal > protected > private.
|
|
247
268
|
const propertiesProcessed = sortPartsAlphabetically(
|
|
248
269
|
this._getMembers( properties, { parentDoclet: doclet } ),
|
|
249
270
|
[
|
|
@@ -251,6 +272,10 @@ module.exports = class DocDataFactory {
|
|
|
251
272
|
key: 'access',
|
|
252
273
|
value: 'public'
|
|
253
274
|
},
|
|
275
|
+
{
|
|
276
|
+
key: 'access',
|
|
277
|
+
value: 'internal'
|
|
278
|
+
},
|
|
254
279
|
{
|
|
255
280
|
key: 'access',
|
|
256
281
|
value: 'protected'
|
|
@@ -275,6 +300,10 @@ module.exports = class DocDataFactory {
|
|
|
275
300
|
key: 'access',
|
|
276
301
|
value: 'public'
|
|
277
302
|
},
|
|
303
|
+
{
|
|
304
|
+
key: 'access',
|
|
305
|
+
value: 'internal'
|
|
306
|
+
},
|
|
278
307
|
{
|
|
279
308
|
key: 'access',
|
|
280
309
|
value: 'protected'
|
|
@@ -289,6 +318,8 @@ module.exports = class DocDataFactory {
|
|
|
289
318
|
const staticMethods = Array.isArray( methodsProcessed ) ? methodsProcessed.filter( m => m.scope === 'static' ) : [];
|
|
290
319
|
const instanceMethods = Array.isArray( methodsProcessed ) ? methodsProcessed.filter( m => m.scope !== 'static' ) : [];
|
|
291
320
|
const augmentsNested = doclet.augmentsNested ? doclet.augmentsNested : [];
|
|
321
|
+
const typeParameters = doclet.typeParameters || null;
|
|
322
|
+
|
|
292
323
|
augmentsNested.unshift( doclet.longname );
|
|
293
324
|
augmentsNested.reverse();
|
|
294
325
|
|
|
@@ -300,6 +331,7 @@ module.exports = class DocDataFactory {
|
|
|
300
331
|
methods: methodsProcessed,
|
|
301
332
|
staticMethods,
|
|
302
333
|
instanceMethods,
|
|
334
|
+
typeParameters,
|
|
303
335
|
events: this._getMembers( events, {
|
|
304
336
|
callback: item => {
|
|
305
337
|
item.name = item.name.replace( 'event:', '' );
|
|
@@ -391,11 +423,12 @@ module.exports = class DocDataFactory {
|
|
|
391
423
|
itemData.readonly = doclet.readonly;
|
|
392
424
|
itemData.defaultvalue = typeof doclet.defaultvalue !== 'undefined' && doclet.defaultvalue !== null ?
|
|
393
425
|
doclet.defaultvalue.toString() : null;
|
|
426
|
+
itemData.label = doclet.label;
|
|
394
427
|
itemData.optional = doclet.optional;
|
|
395
428
|
itemData.scope = doclet.scope;
|
|
396
429
|
itemData.fires = doclet.fires;
|
|
397
|
-
|
|
398
430
|
itemData.types = getTypes( doclet );
|
|
431
|
+
itemData.typeParameters = doclet.typeParameters || null;
|
|
399
432
|
|
|
400
433
|
if ( doclet.params ) {
|
|
401
434
|
itemData.params = this._getMembers( doclet.params, { parentDoclet: options.parentDoclet } );
|
|
@@ -431,6 +464,19 @@ module.exports = class DocDataFactory {
|
|
|
431
464
|
} );
|
|
432
465
|
}
|
|
433
466
|
|
|
467
|
+
if ( doclet.typeParameters ) {
|
|
468
|
+
itemData.typeParameters = doclet.typeParameters.map( typeParameter => {
|
|
469
|
+
if ( typeParameter.description ) {
|
|
470
|
+
typeParameter.description = this._descriptionParser.parseDescription( typeParameter.description, {
|
|
471
|
+
doclet: options.parentDoclet,
|
|
472
|
+
buildInfo: this._options.buildInfo
|
|
473
|
+
} );
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
return typeParameter;
|
|
477
|
+
} );
|
|
478
|
+
}
|
|
479
|
+
|
|
434
480
|
return Object.assign( base, itemData );
|
|
435
481
|
}
|
|
436
482
|
|
|
@@ -586,6 +632,13 @@ function prepareBadges( item, context ) {
|
|
|
586
632
|
} );
|
|
587
633
|
break;
|
|
588
634
|
|
|
635
|
+
case 'internal':
|
|
636
|
+
badges.push( {
|
|
637
|
+
class: 'orange',
|
|
638
|
+
text: 'internal'
|
|
639
|
+
} );
|
|
640
|
+
break;
|
|
641
|
+
|
|
589
642
|
case 'protected':
|
|
590
643
|
badges.push( {
|
|
591
644
|
class: 'orange',
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2017-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A helper function used for searching for a proper doclet structure when creating a link
|
|
10
|
+
* from a guide or an API page.
|
|
11
|
+
*
|
|
12
|
+
* The main goal of this function is to avoid editing the same logic in many places.
|
|
13
|
+
*
|
|
14
|
+
* @param {DataCollection} docletCollection
|
|
15
|
+
* @param {Object} options
|
|
16
|
+
* @param {String} [options.module]
|
|
17
|
+
* @param {String} [options.structure]
|
|
18
|
+
* @param {String} options.member
|
|
19
|
+
* @param {String} [options.label]
|
|
20
|
+
* @param {Object} [options.query={}]
|
|
21
|
+
* @param {Boolean} [options.query.skipModule=false]
|
|
22
|
+
* @param {Boolean} [options.query.memberOnly=false]
|
|
23
|
+
* @returns {Object|null}
|
|
24
|
+
*/
|
|
25
|
+
module.exports = function findTargetDoclet( docletCollection, options ) {
|
|
26
|
+
const { module, structure, member, label, query } = options;
|
|
27
|
+
const { skipModule, memberOnly } = ( query || {} );
|
|
28
|
+
|
|
29
|
+
if ( !structure ) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Try to find an instance member...
|
|
34
|
+
let collection = docletCollection.get( `ln:${ structure }#${ member }` );
|
|
35
|
+
|
|
36
|
+
// ...or a static member.
|
|
37
|
+
if ( collection.isEmpty ) {
|
|
38
|
+
collection = docletCollection.get( `ln:${ structure }.${ member }` );
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// When the advanced search is enabled, try to find also...
|
|
42
|
+
if ( !memberOnly ) {
|
|
43
|
+
// ...a definition within the same module.
|
|
44
|
+
if ( collection.isEmpty ) {
|
|
45
|
+
collection = docletCollection.get( `ln:${ structure }~${ member }` );
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// To save a backward compatibility, let's try to find a structure without defining a member.
|
|
49
|
+
if ( collection.isEmpty && structure.endsWith( '~' + member ) ) {
|
|
50
|
+
collection = docletCollection.get( `ln:${ structure }` );
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Then, search for an event declaration (`...~Classname#event:eventName`).
|
|
54
|
+
if ( collection.isEmpty && member === 'event' ) {
|
|
55
|
+
collection = docletCollection.get( `ln:${ structure }#${ member }:${ label }` );
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// (`...~Classname#eventName`). CKEditor 4 / JSDuck.
|
|
59
|
+
if ( collection.isEmpty && member === 'event' ) {
|
|
60
|
+
collection = docletCollection.get( `ln:${ structure }#${ label }` );
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Search for a module definition only if requested.
|
|
64
|
+
if ( !skipModule && collection.isEmpty ) {
|
|
65
|
+
collection = docletCollection.get( `ln:${ module }` );
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if ( collection.isEmpty ) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
let targetDoclet;
|
|
74
|
+
|
|
75
|
+
if ( label && collection.size > 1 ) {
|
|
76
|
+
targetDoclet = collection.getByLabel( label );
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if ( !targetDoclet ) {
|
|
80
|
+
targetDoclet = collection.getFirst();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return targetDoclet;
|
|
84
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2017-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
const DEDICATED_PAGE_DOCLET_KINDS = [
|
|
9
|
+
'module', 'class', 'typedef', 'mixin', 'interface', 'namespace'
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Set of utils used in helpers to generate links to API definitions.
|
|
14
|
+
*/
|
|
15
|
+
module.exports = {
|
|
16
|
+
/**
|
|
17
|
+
* A regular expression used for extracting a member name from doclet full name, member of or just a name.
|
|
18
|
+
*/
|
|
19
|
+
MEMBER_NAME_REGEXP: /([{}\-\w$]+)(?::([A-Z0-9a-z_:{}]+))?$/,
|
|
20
|
+
// ^ Sync with the `LONG_NAME_LABEL_REGEXP` value.
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A regular expression used for removing a label (if specified) from a member name.
|
|
24
|
+
* The regexp is used in `MEMBER_NAME_REGEXP` as a group, so the particular group should be synced.
|
|
25
|
+
*/
|
|
26
|
+
LONG_NAME_LABEL_REGEXP: /(?::([A-Z0-9a-z_:{}]+))?$/,
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A regular expression used for separating a definition (a class, an interface, etc.) and a member name.
|
|
30
|
+
*/
|
|
31
|
+
LONG_NAME_MEMBER_SEPARATOR_REGEXP: /[#.]/,
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @param {Object} doclet
|
|
35
|
+
* @param {String} doclet.kind
|
|
36
|
+
* @returns {Boolean}
|
|
37
|
+
*/
|
|
38
|
+
hasDedicatedApiPages( doclet ) {
|
|
39
|
+
return DEDICATED_PAGE_DOCLET_KINDS.includes( doclet.kind );
|
|
40
|
+
}
|
|
41
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2017-
|
|
2
|
+
* @license Copyright (c) 2017-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -17,6 +17,13 @@ module.exports = data => {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
parsed.forEach( ( item, index ) => {
|
|
20
|
+
if ( item.kind === 'event' ) {
|
|
21
|
+
// Remove `event:` from an event name.
|
|
22
|
+
if ( item.name.startsWith( 'event' ) ) {
|
|
23
|
+
item.name = item.name.replace( /^event[:-]/, '' );
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
20
27
|
if ( item.classdesc ) {
|
|
21
28
|
const description = item.classdesc;
|
|
22
29
|
delete parsed[ index ].classdesc;
|