Repository navigation
build(aio) + docs: miscellaneous updates to the doc-gen #24000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c5f1798
14fcd3b
9e1050c
dfab9ab
c364efc
1f9e43a
981ee7c
b0aa39b
be016e7
d552300
54b7a39
5fe50e6
44e2f93
54b0103
e682cd2
686c6d6
bf87296
3c24fd1
d927c14
8ea4779
14acfc2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| .api-body { | ||
|
|
||
| max-width: 1200px; | ||
|
|
||
| table { | ||
|
|
||
| th { | ||
| text-transform: none; | ||
| font-size: 16px; | ||
| font-weight: bold; | ||
| } | ||
|
|
||
| tr { | ||
| border-bottom: 1px solid $lightgray; | ||
| } | ||
|
|
||
| td { | ||
| vertical-align: middle; | ||
| } | ||
|
|
||
| hr { | ||
| margin: 16px 0; | ||
| } | ||
|
|
||
| tr:last-child { | ||
| border-bottom: none; | ||
| } | ||
|
|
||
| &.item-table { | ||
| td { | ||
| padding: 32px; | ||
| } | ||
| } | ||
|
|
||
| &.list-table { | ||
| td { | ||
| padding: 16px 24px; | ||
| } | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,12 +42,19 @@ module.exports = new Package('angular-api', [basePackage, typeScriptPackage]) | |
| return EXPORT_DOC_TYPES.concat(['decorator', 'directive', 'pipe', 'module']); | ||
| }) | ||
|
|
||
| /** | ||
| * 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) { | ||
| return API_DOC_TYPES_TO_RENDER.concat(['member', 'function-overload']); | ||
| .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); | ||
| }) | ||
|
|
||
| // Where do we get the source files? | ||
|
|
@@ -112,8 +119,8 @@ module.exports = new Package('angular-api', [basePackage, typeScriptPackage]) | |
| parseTagsProcessor.tagDefinitions.concat(getInjectables(requireFolder(__dirname, './tag-defs'))); | ||
| }) | ||
|
|
||
| .config(function(computeStability, splitDescription, addNotYetDocumentedProperty, EXPORT_DOC_TYPES, API_DOC_TYPES) { | ||
| computeStability.docTypes = EXPORT_DOC_TYPES; | ||
| .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 | ||
| splitDescription.docTypes = API_DOC_TYPES; | ||
| addNotYetDocumentedProperty.docTypes = API_DOC_TYPES; | ||
|
|
@@ -155,6 +162,16 @@ module.exports = new Package('angular-api', [basePackage, typeScriptPackage]) | |
| }); | ||
| }) | ||
|
|
||
| .config(function(filterContainedDocs, API_CONTAINED_DOC_TYPES) { | ||
| filterContainedDocs.docTypes = API_CONTAINED_DOC_TYPES; | ||
| }) | ||
|
|
||
| .config(function(checkContentRules, API_DOC_TYPES, API_CONTAINED_DOC_TYPES) { | ||
| addMinLengthRules(checkContentRules); | ||
| addHeadingRules(checkContentRules, API_DOC_TYPES); | ||
| addAllowedPropertiesRules(checkContentRules, API_CONTAINED_DOC_TYPES); | ||
| }) | ||
|
|
||
| .config(function(computePathsProcessor, EXPORT_DOC_TYPES, generateApiListDoc) { | ||
|
|
||
| const API_SEGMENT = 'api'; | ||
|
|
@@ -188,3 +205,45 @@ module.exports = new Package('angular-api', [basePackage, typeScriptPackage]) | |
| autoLinkCode.docTypes = API_DOC_TYPES; | ||
| autoLinkCode.codeElements = ['code', 'code-example', 'code-pane']; | ||
| }); | ||
|
|
||
|
|
||
| function addMinLengthRules(checkContentRules) { | ||
| const createMinLengthRule = require('./content-rules/minLength'); | ||
| const paramRuleSet = checkContentRules.docTypeRules['parameter'] = checkContentRules.docTypeRules['parameter'] || {}; | ||
| const paramRules = paramRuleSet['name'] = paramRuleSet['name'] || []; | ||
| paramRules.push(createMinLengthRule()); | ||
| } | ||
|
|
||
| function addHeadingRules(checkContentRules, API_DOC_TYPES) { | ||
| const createNoMarkdownHeadingsRule = require('./content-rules/noMarkdownHeadings'); | ||
| const noMarkdownHeadings = createNoMarkdownHeadingsRule(); | ||
| const allowOnlyLevel3Headings = createNoMarkdownHeadingsRule(1, 2, '4,'); | ||
|
|
||
| API_DOC_TYPES.forEach(docType => { | ||
| let rules; | ||
| const ruleSet = checkContentRules.docTypeRules[docType] = checkContentRules.docTypeRules[docType] || {}; | ||
|
|
||
| rules = ruleSet['description'] = ruleSet['description'] || []; | ||
| rules.push(noMarkdownHeadings); | ||
|
|
||
| rules = ruleSet['shortDescription'] = ruleSet['shortDescription'] || []; | ||
| rules.push(noMarkdownHeadings); | ||
|
|
||
| rules = ruleSet['usageNotes'] = ruleSet['usageNotes'] || []; | ||
| rules.push(allowOnlyLevel3Headings); | ||
| }); | ||
| } | ||
|
|
||
| function addAllowedPropertiesRules(checkContentRules, API_CONTAINED_DOC_TYPES) { | ||
| API_CONTAINED_DOC_TYPES.forEach(docType => { | ||
| const ruleSet = checkContentRules.docTypeRules[docType] = checkContentRules.docTypeRules[docType] || {}; | ||
|
|
||
| const rules = ruleSet['usageNotes'] = ruleSet['usageNotes'] || []; | ||
| rules.push((doc, prop, value) => value && !isMethod(doc) && | ||
| `Invalid property: "${prop}" is not allowed on "${doc.docType}" docs.`); | ||
| }); | ||
| } | ||
|
|
||
| function isMethod(doc) { | ||
| return doc.hasOwnProperty('parameters') && !doc.isGetAccessor && !doc.isSetAccessor; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do constructors count?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think so yes, constructors are a kind of method according to this definition. |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,15 @@ | ||
| module.exports = function computeApiBreadCrumbs(EXPORT_DOC_TYPES) { | ||
| module.exports = function computeApiBreadCrumbs(API_DOC_TYPES_TO_RENDER) { | ||
| return { | ||
| $runAfter: ['paths-computed'], | ||
| $runBefore: ['rendering-docs'], | ||
| $process(docs) { | ||
| // Compute the breadcrumb for each doc by processing its containers | ||
| docs.forEach(doc => { | ||
| if (EXPORT_DOC_TYPES.indexOf(doc.docType) !== -1) { | ||
| doc.breadCrumbs = [ | ||
| { text: 'API', path: '/api' }, | ||
| { text: '@angular/' + doc.moduleDoc.id, path: doc.moduleDoc.path }, | ||
| { text: doc.name, path: doc.path } | ||
| ]; | ||
| if (API_DOC_TYPES_TO_RENDER.indexOf(doc.docType) !== -1) { | ||
| doc.breadCrumbs = []; | ||
| doc.breadCrumbs.push({ text: 'API', path: '/api' }); | ||
| if (doc.moduleDoc) doc.breadCrumbs.push({ text: '@angular/' + doc.moduleDoc.id, path: doc.moduleDoc.path }); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when it is a module? I'll add a test |
||
| doc.breadCrumbs.push({ text: doc.name, path: doc.path }); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this rule mean that
usageNotesare only allowed in methods?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite. This rule only runs on docs that are of the types given in
API_CONTAINED_DOC_TYPES. It just turns out that all methods and properties are of the samedocType(i.e.member) so we have to have this additional check here.So since the rule doesn't run on other docTypes (e.g.
classorfunction) they are not constrained by it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, this means that
usageNotesare not allowed in members, except for methods (where they are allowed)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right and also
function-overload,get-accessor-info,set-accessor-infoandparameterdocs