From e4e98edf203bc4a8fe68819cffcab613a2a55925 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Fri, 9 Jul 2021 15:29:29 +0100 Subject: [PATCH] build(docs-infra): add `sealed` markers to classes in API pages (#42807) This change will mark classes as `sealed` unless they have been annotated with an `@extensible` jsdoc tag. Fixes #42802 PR Close #42807 --- .../styles/2-modules/api-pages/_api-pages.scss | 5 ++++- aio/src/styles/2-modules/label/_label-theme.scss | 10 +++++++++- .../angular-api-package/tag-defs/extensible.js | 11 +++++++++++ .../transforms/templates/api/base.template.html | 3 +++ .../transforms/templates/api/class.template.html | 1 - .../templates/api/lib/memberHelpers.html | 8 ++++++++ .../transforms/templates/lib/githubLinks.html | 16 +++++++++++----- docs/PUBLIC_API.md | 8 ++++++++ 8 files changed, 54 insertions(+), 8 deletions(-) create mode 100644 aio/tools/transforms/angular-api-package/tag-defs/extensible.js diff --git a/aio/src/styles/2-modules/api-pages/_api-pages.scss b/aio/src/styles/2-modules/api-pages/_api-pages.scss index 70c09237a2a..d96617e72c1 100644 --- a/aio/src/styles/2-modules/api-pages/_api-pages.scss +++ b/aio/src/styles/2-modules/api-pages/_api-pages.scss @@ -97,7 +97,6 @@ .github-links { a { - .material-icons:hover { background: none; } @@ -167,6 +166,10 @@ margin-top: 8px; } + .final-message { + font-style: italic; + } + .api-heading { @include mixins.font-size(14); margin: 16px; diff --git a/aio/src/styles/2-modules/label/_label-theme.scss b/aio/src/styles/2-modules/label/_label-theme.scss index 1b26c97f42b..cb1c95ca85e 100644 --- a/aio/src/styles/2-modules/label/_label-theme.scss +++ b/aio/src/styles/2-modules/label/_label-theme.scss @@ -8,9 +8,17 @@ &.api-status-label { background-color: constants.$mediumgray; - &.deprecated, &.security, &.impure-pipe { + &.deprecated, + &.security, + &.impure-pipe { background-color: constants.$brightred; } + + a { + color: inherit; + line-height: inherit; + font-size: inherit; + } } &.api-type-label { diff --git a/aio/tools/transforms/angular-api-package/tag-defs/extensible.js b/aio/tools/transforms/angular-api-package/tag-defs/extensible.js new file mode 100644 index 00000000000..a5d6c517165 --- /dev/null +++ b/aio/tools/transforms/angular-api-package/tag-defs/extensible.js @@ -0,0 +1,11 @@ +/** + * Use this tag to indicate that this class can be extended. + * + * This is the opposite of the Java `sealed` keyword. + */ +module.exports = function() { + return { + name: 'extensible', + transforms: function() { return true; } + }; +}; diff --git a/aio/tools/transforms/templates/api/base.template.html b/aio/tools/transforms/templates/api/base.template.html index 19e7e0bd865..b99d9dcfa56 100644 --- a/aio/tools/transforms/templates/api/base.template.html +++ b/aio/tools/transforms/templates/api/base.template.html @@ -26,6 +26,9 @@ {% if doc.deprecated !== undefined %}{% endif %} {% if doc.security !== undefined %}{% endif %} {% if doc.pipeOptions.pure === 'false' %}{% endif %} + {% if doc.docType === 'class' and doc.extensible !== true and not doc.isAbstract %}{% endif %} {% endblock %} diff --git a/aio/tools/transforms/templates/api/class.template.html b/aio/tools/transforms/templates/api/class.template.html index 5c22b539790..6fecb65a349 100644 --- a/aio/tools/transforms/templates/api/class.template.html +++ b/aio/tools/transforms/templates/api/class.template.html @@ -1,6 +1,5 @@ {% import "lib/ngmodule.html" as ngModuleHelpers -%} {% extends 'export-base.template.html' -%} - {% block overview %} {% include "includes/class-overview.html" %} {% endblock %} diff --git a/aio/tools/transforms/templates/api/lib/memberHelpers.html b/aio/tools/transforms/templates/api/lib/memberHelpers.html index 0f0d3896ab4..e65208ccc5e 100644 --- a/aio/tools/transforms/templates/api/lib/memberHelpers.html +++ b/aio/tools/transforms/templates/api/lib/memberHelpers.html @@ -95,6 +95,14 @@ {% if method.shortDescription %} {$ method.shortDescription | marked $} + + {% if method.containerDoc.docType === 'class' and method.name === 'constructor' and not method.containerDoc.isAbstract and method.containerDoc.extensible !== true %} +

+ This class is "final" and should not be extended. + See the public API notes. +

+ {% endif %} + {%- if method.see.length %}

See also: