| 
									
										
										
										
											2017-04-21 13:10:52 +01:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							| 
									
										
										
										
											2020-05-19 12:08:49 -07:00
										 |  |  |  * Copyright Google LLC All Rights Reserved. | 
					
						
							| 
									
										
										
										
											2017-04-21 13:10:52 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Use of this source code is governed by an MIT-style license that can be | 
					
						
							|  |  |  |  * found in the LICENSE file at https://angular.io/license
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | const Package = require('dgeni').Package; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const basePackage = require('../angular-base-package'); | 
					
						
							|  |  |  | const typeScriptPackage = require('dgeni-packages/typescript'); | 
					
						
							| 
									
										
										
										
											2021-03-21 11:07:34 +00:00
										 |  |  | const {API_SOURCE_PATH, API_TEMPLATES_PATH, requireFolder, CONTENTS_PATH} = require('../config'); | 
					
						
							|  |  |  | const API_SEGMENT = 'api'; | 
					
						
							| 
									
										
										
										
											2019-05-17 18:49:21 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | module.exports = | 
					
						
							|  |  |  |     new Package('angular-api', [basePackage, typeScriptPackage]) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // Register the processors
 | 
					
						
							| 
									
										
										
										
											2020-05-13 17:01:10 +01:00
										 |  |  |         .processor(require('./processors/mergeParameterInfo')) | 
					
						
							|  |  |  |         .processor(require('./processors/processPseudoClasses')) | 
					
						
							| 
									
										
										
										
											2019-05-17 18:49:21 -07:00
										 |  |  |         .processor(require('./processors/convertPrivateClassesToInterfaces')) | 
					
						
							|  |  |  |         .processor(require('./processors/generateApiListDoc')) | 
					
						
							|  |  |  |         .processor(require('./processors/addNotYetDocumentedProperty')) | 
					
						
							|  |  |  |         .processor(require('./processors/mergeDecoratorDocs')) | 
					
						
							|  |  |  |         .processor(require('./processors/extractDecoratedClasses')) | 
					
						
							|  |  |  |         .processor(require('./processors/extractPipeParams')) | 
					
						
							|  |  |  |         .processor(require('./processors/matchUpDirectiveDecorators')) | 
					
						
							|  |  |  |         .processor(require('./processors/addMetadataAliases')) | 
					
						
							| 
									
										
										
										
											2019-12-06 13:41:15 +01:00
										 |  |  |         .processor(require('./processors/addGlobalApiData')) | 
					
						
							|  |  |  |         .processor(require('./processors/updateGlobalApiPath')) | 
					
						
							| 
									
										
										
										
											2019-05-17 18:49:21 -07:00
										 |  |  |         .processor(require('./processors/computeApiBreadCrumbs')) | 
					
						
							|  |  |  |         .processor(require('./processors/filterContainedDocs')) | 
					
						
							|  |  |  |         .processor(require('./processors/processClassLikeMembers')) | 
					
						
							|  |  |  |         .processor(require('./processors/markBarredODocsAsPrivate')) | 
					
						
							|  |  |  |         .processor(require('./processors/filterPrivateDocs')) | 
					
						
							| 
									
										
										
										
											2019-07-02 01:02:56 +03:00
										 |  |  |         .processor(require('./processors/filterMembers')) | 
					
						
							| 
									
										
										
										
											2019-05-17 18:49:21 -07:00
										 |  |  |         .processor(require('./processors/computeSearchTitle')) | 
					
						
							|  |  |  |         .processor(require('./processors/simplifyMemberAnchors')) | 
					
						
							|  |  |  |         .processor(require('./processors/computeStability')) | 
					
						
							|  |  |  |         .processor(require('./processors/removeInjectableConstructors')) | 
					
						
							| 
									
										
										
										
											2021-03-21 11:07:34 +00:00
										 |  |  |         .processor(require('./processors/processSpecialElements')) | 
					
						
							| 
									
										
										
										
											2019-05-17 18:49:21 -07:00
										 |  |  |         .processor(require('./processors/collectPackageContentDocs')) | 
					
						
							|  |  |  |         .processor(require('./processors/processPackages')) | 
					
						
							|  |  |  |         .processor(require('./processors/processNgModuleDocs')) | 
					
						
							|  |  |  |         .processor(require('./processors/fixupRealProjectRelativePath')) | 
					
						
							|  |  |  |         .processor(require('./processors/processAliasDocs')) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         /** | 
					
						
							|  |  |  |          * These are the API doc types that will be rendered to actual files. | 
					
						
							|  |  |  |          * This is a super set of the exported docs, since we convert some classes to | 
					
						
							|  |  |  |          * more Angular specific API types, such as decorators and directives. | 
					
						
							|  |  |  |          */ | 
					
						
							|  |  |  |         .factory(function API_DOC_TYPES_TO_RENDER(EXPORT_DOC_TYPES) { | 
					
						
							| 
									
										
										
										
											2021-03-21 11:07:34 +00:00
										 |  |  |           return EXPORT_DOC_TYPES.concat(['decorator', 'directive', 'ngmodule', 'pipe', 'package', 'element']); | 
					
						
							| 
									
										
										
										
											2019-05-17 18:49:21 -07:00
										 |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         /** | 
					
						
							|  |  |  |          * These are the doc types that are contained within other docs | 
					
						
							|  |  |  |          */ | 
					
						
							|  |  |  |         .factory(function API_CONTAINED_DOC_TYPES() { | 
					
						
							|  |  |  |           return [ | 
					
						
							|  |  |  |             'member', 'function-overload', 'get-accessor-info', 'set-accessor-info', 'parameter' | 
					
						
							|  |  |  |           ]; | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         /** | 
					
						
							|  |  |  |          * These are the doc types that are API docs, including ones that will be merged into | 
					
						
							|  |  |  |          * container docs, | 
					
						
							|  |  |  |          * such as members and overloads. | 
					
						
							|  |  |  |          */ | 
					
						
							|  |  |  |         .factory(function API_DOC_TYPES(API_DOC_TYPES_TO_RENDER, API_CONTAINED_DOC_TYPES) { | 
					
						
							|  |  |  |           return API_DOC_TYPES_TO_RENDER.concat(API_CONTAINED_DOC_TYPES); | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         .factory(require('./readers/package-content')) | 
					
						
							| 
									
										
										
										
											2021-03-21 11:07:34 +00:00
										 |  |  |         .factory(require('./readers/element')) | 
					
						
							| 
									
										
										
										
											2019-05-17 18:49:21 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // Where do we get the source files?
 | 
					
						
							|  |  |  |         .config(function( | 
					
						
							|  |  |  |             readTypeScriptModules, readFilesProcessor, collectExamples, tsParser, | 
					
						
							| 
									
										
										
										
											2021-03-21 11:07:34 +00:00
										 |  |  |             packageContentFileReader, specialElementFileReader) { | 
					
						
							| 
									
										
										
										
											2019-05-17 18:49:21 -07:00
										 |  |  |           // Tell TypeScript how to load modules that start with with `@angular`
 | 
					
						
							|  |  |  |           tsParser.options.paths = {'@angular/*': [API_SOURCE_PATH + '/*']}; | 
					
						
							|  |  |  |           tsParser.options.baseUrl = '.'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           // API files are typescript
 | 
					
						
							|  |  |  |           readTypeScriptModules.basePath = API_SOURCE_PATH; | 
					
						
							|  |  |  |           readTypeScriptModules.ignoreExportsMatching = [/^_|^ɵɵ|^VERSION$/]; | 
					
						
							|  |  |  |           readTypeScriptModules.hidePrivateMembers = true; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-05 21:25:39 +00:00
										 |  |  |           // NOTE: This list should be in sync with the folders/files in `goldens/public-api`.
 | 
					
						
							| 
									
										
										
										
											2019-05-17 18:49:21 -07:00
										 |  |  |           readTypeScriptModules.sourceFiles = [ | 
					
						
							|  |  |  |             'animations/index.ts', | 
					
						
							|  |  |  |             'animations/browser/index.ts', | 
					
						
							|  |  |  |             'animations/browser/testing/index.ts', | 
					
						
							|  |  |  |             'common/http/index.ts', | 
					
						
							|  |  |  |             'common/http/testing/index.ts', | 
					
						
							|  |  |  |             'common/index.ts', | 
					
						
							|  |  |  |             'common/testing/index.ts', | 
					
						
							|  |  |  |             'common/upgrade/index.ts', | 
					
						
							|  |  |  |             'core/index.ts', | 
					
						
							| 
									
										
										
										
											2019-12-19 21:25:42 +01:00
										 |  |  |             'core/global/index.ts', | 
					
						
							| 
									
										
										
										
											2019-05-17 18:49:21 -07:00
										 |  |  |             'core/testing/index.ts', | 
					
						
							|  |  |  |             'elements/index.ts', | 
					
						
							|  |  |  |             'forms/index.ts', | 
					
						
							| 
									
										
										
										
											2021-01-05 21:25:39 +00:00
										 |  |  |             'localize/index.ts', | 
					
						
							|  |  |  |             'localize/init/index.ts', | 
					
						
							| 
									
										
										
										
											2019-05-17 18:49:21 -07:00
										 |  |  |             'platform-browser/index.ts', | 
					
						
							|  |  |  |             'platform-browser/animations/index.ts', | 
					
						
							|  |  |  |             'platform-browser/testing/index.ts', | 
					
						
							|  |  |  |             'platform-browser-dynamic/index.ts', | 
					
						
							|  |  |  |             'platform-browser-dynamic/testing/index.ts', | 
					
						
							|  |  |  |             'platform-server/index.ts', | 
					
						
							| 
									
										
											  
											
												feat(platform-server): allow shimming the global env sooner (#40559)
`@angular/platform-server` provides the foundation for rendering an
Angular app on the server. In order to achieve that, it uses a
server-side DOM implementation (currently [domino][1]).
For rendering on the server to work as closely as possible to running
the app on the browser, we need to make DOM globals (such as `Element`,
`HTMLElement`, etc.), which are normally provided by the browser,
available as globals on the server as well.
Currently, `@angular/platform-server` achieves this by extending the
`global` object with the DOM implementation provided by `domino`. This
assignment happens in the [setDomTypes()][2] function, which is
[called in a `PLATFORM_INITIALIZER`][3]. While this works in most cases,
there are some scenarios where the DOM globals are needed sooner (i.e.
before initializing the platform). See, for example, #24551 and #39950
for more details on such issues.
This commit provides a way to solve this problem by exposing a
side-effect-ful entry-point (`@angular/platform-server/init`), that
shims the `global` object with DOM globals. People will be able to
import this entry-point in their server-rendered apps before
bootstrapping the app (for example, in their `main.server.ts` file).
(See also [#39950 (comment)][4].)
In a future update, the [`universal` schematics][5] will include such an
import by default in newly generated projects.
[1]: https://www.npmjs.com/package/domino
[2]: https://github.com/angular/angular/blob/0fc8466f1be392917e0c/packages/platform-server/src/domino_adapter.ts#L17-L21
[3]: https://github.com/angular/angular/blob/0fc8466f1be392917e0c/packages/platform-server/src/server.ts#L33
[4]: https://github.com/angular/angular/issues/39950#issuecomment-747598403
[5]: https://github.com/angular/angular-cli/blob/cc51432661eb4ab4b6a3/packages/schematics/angular/universal
PR Close #40559
											
										 
											2021-02-11 19:24:52 +02:00
										 |  |  |             'platform-server/init/index.ts', | 
					
						
							| 
									
										
										
										
											2019-05-17 18:49:21 -07:00
										 |  |  |             'platform-server/testing/index.ts', | 
					
						
							|  |  |  |             'platform-webworker/index.ts', | 
					
						
							|  |  |  |             'platform-webworker-dynamic/index.ts', | 
					
						
							|  |  |  |             'router/index.ts', | 
					
						
							|  |  |  |             'router/testing/index.ts', | 
					
						
							|  |  |  |             'router/upgrade/index.ts', | 
					
						
							|  |  |  |             'service-worker/index.ts', | 
					
						
							|  |  |  |             'upgrade/index.ts', | 
					
						
							|  |  |  |             'upgrade/static/index.ts', | 
					
						
							| 
									
										
										
										
											2019-03-22 09:42:52 +00:00
										 |  |  |             'upgrade/static/testing/index.ts', | 
					
						
							| 
									
										
										
										
											2019-05-17 18:49:21 -07:00
										 |  |  |           ]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-21 11:07:34 +00:00
										 |  |  |           // Special elements and packages docs are not extracted directly from TS code.
 | 
					
						
							|  |  |  |           readFilesProcessor.fileReaders.push(packageContentFileReader, specialElementFileReader); | 
					
						
							| 
									
										
										
										
											2019-05-17 18:49:21 -07:00
										 |  |  |           readFilesProcessor.sourceFiles = [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               basePath: API_SOURCE_PATH, | 
					
						
							| 
									
										
										
										
											2021-03-21 11:07:34 +00:00
										 |  |  |               include: API_SOURCE_PATH + '/**/PACKAGE.md', | 
					
						
							|  |  |  |               fileReader: 'packageContentFileReader' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               basePath: CONTENTS_PATH + '/special-elements', | 
					
						
							|  |  |  |               include: CONTENTS_PATH + '/special-elements/*/**/*.md', | 
					
						
							|  |  |  |               fileReader: 'specialElementFileReader' | 
					
						
							| 
									
										
										
										
											2019-05-17 18:49:21 -07:00
										 |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               basePath: API_SOURCE_PATH, | 
					
						
							| 
									
										
										
										
											2021-03-21 11:07:34 +00:00
										 |  |  |               include: API_SOURCE_PATH + '/examples/**/*', | 
					
						
							|  |  |  |               fileReader: 'exampleFileReader' | 
					
						
							| 
									
										
										
										
											2019-05-17 18:49:21 -07:00
										 |  |  |             } | 
					
						
							|  |  |  |           ]; | 
					
						
							| 
									
										
										
										
											2021-03-21 11:07:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-17 18:49:21 -07:00
										 |  |  |           collectExamples.exampleFolders.push('examples'); | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-21 11:07:34 +00:00
										 |  |  |         // Configure element ids and paths
 | 
					
						
							|  |  |  |         .config(function(computeIdsProcessor, computePathsProcessor) { | 
					
						
							|  |  |  |           computeIdsProcessor.idTemplates.push({ | 
					
						
							|  |  |  |             docTypes: ['element'], | 
					
						
							|  |  |  |             getId(doc) { | 
					
						
							|  |  |  |               // path should not have a suffix
 | 
					
						
							|  |  |  |               return doc.fileInfo.relativePath.replace(/\.\w*$/, ''); | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             getAliases(doc) { return [doc.name, doc.id]; } | 
					
						
							|  |  |  |           }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           computePathsProcessor.pathTemplates.push({ | 
					
						
							|  |  |  |             docTypes: ['element'], | 
					
						
							|  |  |  |             pathTemplate: API_SEGMENT + '/${id}', | 
					
						
							|  |  |  |             outputPathTemplate: '${path}.json' | 
					
						
							|  |  |  |           }); | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-17 18:49:21 -07:00
										 |  |  |         // Configure jsdoc-style tag parsing
 | 
					
						
							|  |  |  |         .config(function(parseTagsProcessor, getInjectables, tsHost) { | 
					
						
							|  |  |  |           // Load up all the tag definitions in the tag-defs folder
 | 
					
						
							|  |  |  |           parseTagsProcessor.tagDefinitions = parseTagsProcessor.tagDefinitions.concat( | 
					
						
							|  |  |  |               getInjectables(requireFolder(__dirname, './tag-defs'))); | 
					
						
							|  |  |  |           // We don't want license headers to be joined to the first API item's comment
 | 
					
						
							|  |  |  |           tsHost.concatMultipleLeadingComments = false; | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         .config(function( | 
					
						
							|  |  |  |             computeStability, splitDescription, addNotYetDocumentedProperty, | 
					
						
							|  |  |  |             API_DOC_TYPES_TO_RENDER, API_DOC_TYPES) { | 
					
						
							|  |  |  |           computeStability.docTypes = API_DOC_TYPES_TO_RENDER; | 
					
						
							|  |  |  |           // Only split the description on the API docs
 | 
					
						
							| 
									
										
										
										
											2021-03-21 11:07:34 +00:00
										 |  |  |           splitDescription.docTypes = API_DOC_TYPES.concat(['package-content', 'element']); | 
					
						
							| 
									
										
										
										
											2019-05-17 18:49:21 -07:00
										 |  |  |           addNotYetDocumentedProperty.docTypes = API_DOC_TYPES; | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         .config(function(mergeDecoratorDocs) { | 
					
						
							|  |  |  |           mergeDecoratorDocs.propertiesToMerge = [ | 
					
						
							|  |  |  |             'shortDescription', | 
					
						
							|  |  |  |             'description', | 
					
						
							|  |  |  |             'security', | 
					
						
							|  |  |  |             'deprecated', | 
					
						
							|  |  |  |             'see', | 
					
						
							|  |  |  |             'usageNotes', | 
					
						
							|  |  |  |           ]; | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         .config(function(checkContentRules, API_DOC_TYPES, API_CONTAINED_DOC_TYPES) { | 
					
						
							|  |  |  |           addMinLengthRules(checkContentRules); | 
					
						
							|  |  |  |           addHeadingRules(checkContentRules, API_DOC_TYPES); | 
					
						
							|  |  |  |           addAllowedPropertiesRules(checkContentRules, API_CONTAINED_DOC_TYPES); | 
					
						
							|  |  |  |           checkContentRules.failOnContentErrors = true; | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         .config(function(filterContainedDocs, API_CONTAINED_DOC_TYPES) { | 
					
						
							|  |  |  |           filterContainedDocs.docTypes = API_CONTAINED_DOC_TYPES; | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-02 01:02:56 +03:00
										 |  |  |         .config(function(filterMembers) { | 
					
						
							| 
									
										
										
										
											2020-05-13 17:01:10 +01:00
										 |  |  |           filterMembers.notAllowedPatterns.push(/^ɵ/); | 
					
						
							| 
									
										
										
										
											2019-07-02 01:02:56 +03:00
										 |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-17 18:49:21 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         .config(function(computePathsProcessor, EXPORT_DOC_TYPES, generateApiListDoc) { | 
					
						
							|  |  |  |           generateApiListDoc.outputFolder = API_SEGMENT; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           computePathsProcessor.pathTemplates.push({ | 
					
						
							|  |  |  |             docTypes: ['package'], | 
					
						
							|  |  |  |             getPath: function computeModulePath(doc) { | 
					
						
							|  |  |  |               doc.moduleFolder = `${API_SEGMENT}/${doc.id.replace(/\/index$/, '')}`; | 
					
						
							|  |  |  |               return doc.moduleFolder; | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             outputPathTemplate: '${moduleFolder}.json' | 
					
						
							|  |  |  |           }); | 
					
						
							|  |  |  |           computePathsProcessor.pathTemplates.push({ | 
					
						
							|  |  |  |             docTypes: EXPORT_DOC_TYPES.concat(['decorator', 'directive', 'ngmodule', 'pipe']), | 
					
						
							|  |  |  |             pathTemplate: '${moduleDoc.moduleFolder}/${name}', | 
					
						
							|  |  |  |             outputPathTemplate: '${moduleDoc.moduleFolder}/${name}.json', | 
					
						
							|  |  |  |           }); | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         .config(function(templateFinder) { | 
					
						
							|  |  |  |           // Where to find the templates for the API doc rendering
 | 
					
						
							|  |  |  |           templateFinder.templateFolders.unshift(API_TEMPLATES_PATH); | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         .config(function( | 
					
						
							|  |  |  |             convertToJsonProcessor, postProcessHtml, API_DOC_TYPES_TO_RENDER, API_DOC_TYPES, | 
					
						
							|  |  |  |             autoLinkCode) { | 
					
						
							|  |  |  |           convertToJsonProcessor.docTypes = | 
					
						
							|  |  |  |               convertToJsonProcessor.docTypes.concat(API_DOC_TYPES_TO_RENDER); | 
					
						
							|  |  |  |           postProcessHtml.docTypes = | 
					
						
							| 
									
										
										
										
											2021-04-23 15:58:13 +01:00
										 |  |  |               postProcessHtml.docTypes.concat(API_DOC_TYPES_TO_RENDER); | 
					
						
							| 
									
										
										
										
											2019-05-17 18:49:21 -07:00
										 |  |  |           autoLinkCode.docTypes = API_DOC_TYPES; | 
					
						
							|  |  |  |           autoLinkCode.codeElements = ['code', 'code-example', 'code-pane']; | 
					
						
							|  |  |  |         }); | 
					
						
							| 
									
										
										
										
											2018-05-16 17:51:35 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function addMinLengthRules(checkContentRules) { | 
					
						
							|  |  |  |   const createMinLengthRule = require('./content-rules/minLength'); | 
					
						
							| 
									
										
										
										
											2019-04-04 11:41:52 -07:00
										 |  |  |   const paramRuleSet = checkContentRules.docTypeRules['parameter'] = | 
					
						
							|  |  |  |       checkContentRules.docTypeRules['parameter'] || {}; | 
					
						
							| 
									
										
										
										
											2018-05-16 17:51:35 +01:00
										 |  |  |   const paramRules = paramRuleSet['name'] = paramRuleSet['name'] || []; | 
					
						
							|  |  |  |   paramRules.push(createMinLengthRule()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-18 19:29:34 +01:00
										 |  |  | function addHeadingRules(checkContentRules, API_DOC_TYPES) { | 
					
						
							| 
									
										
										
										
											2018-05-16 17:51:35 +01:00
										 |  |  |   const createNoMarkdownHeadingsRule = require('./content-rules/noMarkdownHeadings'); | 
					
						
							|  |  |  |   const noMarkdownHeadings = createNoMarkdownHeadingsRule(); | 
					
						
							|  |  |  |   const allowOnlyLevel3Headings = createNoMarkdownHeadingsRule(1, 2, '4,'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-18 19:29:34 +01:00
										 |  |  |   API_DOC_TYPES.forEach(docType => { | 
					
						
							|  |  |  |     let rules; | 
					
						
							| 
									
										
										
										
											2019-04-04 11:41:52 -07:00
										 |  |  |     const ruleSet = checkContentRules.docTypeRules[docType] = | 
					
						
							|  |  |  |         checkContentRules.docTypeRules[docType] || {}; | 
					
						
							| 
									
										
										
										
											2018-05-18 19:29:34 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     rules = ruleSet['description'] = ruleSet['description'] || []; | 
					
						
							|  |  |  |     rules.push(noMarkdownHeadings); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     rules = ruleSet['shortDescription'] = ruleSet['shortDescription'] || []; | 
					
						
							|  |  |  |     rules.push(noMarkdownHeadings); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     rules = ruleSet['usageNotes'] = ruleSet['usageNotes'] || []; | 
					
						
							| 
									
										
										
										
											2018-05-16 17:51:35 +01:00
										 |  |  |     rules.push(allowOnlyLevel3Headings); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function addAllowedPropertiesRules(checkContentRules, API_CONTAINED_DOC_TYPES) { | 
					
						
							|  |  |  |   API_CONTAINED_DOC_TYPES.forEach(docType => { | 
					
						
							| 
									
										
										
										
											2019-04-04 11:41:52 -07:00
										 |  |  |     const ruleSet = checkContentRules.docTypeRules[docType] = | 
					
						
							|  |  |  |         checkContentRules.docTypeRules[docType] || {}; | 
					
						
							| 
									
										
										
										
											2018-05-18 19:29:34 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const rules = ruleSet['usageNotes'] = ruleSet['usageNotes'] || []; | 
					
						
							| 
									
										
										
										
											2019-04-04 11:41:52 -07:00
										 |  |  |     rules.push( | 
					
						
							|  |  |  |         (doc, prop, value) => value && | 
					
						
							|  |  |  |             // methods are allowed to have usage notes
 | 
					
						
							|  |  |  |             !isMethod(doc) && | 
					
						
							|  |  |  |             // options on decorators are allowed to ahve usage notes
 | 
					
						
							|  |  |  |             !(doc.containerDoc && doc.containerDoc.docType === 'decorator') && | 
					
						
							|  |  |  |             `Invalid property: "${prop}" is not allowed on "${doc.docType}" docs.`); | 
					
						
							| 
									
										
										
										
											2018-05-16 17:51:35 +01:00
										 |  |  |   }); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-05-18 06:33:12 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | function isMethod(doc) { | 
					
						
							|  |  |  |   return doc.hasOwnProperty('parameters') && !doc.isGetAccessor && !doc.isSetAccessor; | 
					
						
							|  |  |  | } |