Copilot commented on code in PR #1480:
URL: https://github.com/apache/camel-website/pull/1480#discussion_r2702439996
##########
antora-ui-camel/src/partials/article.hbs:
##########
@@ -12,6 +12,22 @@ If you typed the URL of this page manually, please double
check that you entered
{{#with page.title}}
<h1 class="page">{{{this}}}</h1>
{{/with}}
+{{#if page.attributes.deprecated}}
+<div class="admonitionblock warning">
+<table>
+<tbody>
+<tr>
+<td class="icon">
+<i class="fa icon-warning" title="Warning"></i>
Review Comment:
The deprecation warning lacks semantic information for accessibility.
Consider adding `role="alert"` to the outer div and `aria-label="Deprecation
Warning"` to help screen reader users understand the importance of this
message. Additionally, the icon uses title attribute which is not reliably
announced by screen readers - consider using aria-label on the icon element
instead.
```suggestion
<div class="admonitionblock warning" role="alert" aria-label="Deprecation
Warning">
<table>
<tbody>
<tr>
<td class="icon">
<i class="fa icon-warning" aria-label="Warning"></i>
```
##########
antora-ui-camel/src/partials/article.hbs:
##########
@@ -12,6 +12,22 @@ If you typed the URL of this page manually, please double
check that you entered
{{#with page.title}}
<h1 class="page">{{{this}}}</h1>
{{/with}}
+{{#if page.attributes.deprecated}}
+<div class="admonitionblock warning">
+<table>
+<tbody>
+<tr>
+<td class="icon">
+<i class="fa icon-warning" title="Warning"></i>
+</td>
+<td class="content">
+This {{or page.attributes.shortname 'page'}} is deprecated
+</td>
+</tr>
+</tbody>
+</table>
Review Comment:
The deprecation warning uses a table layout but lacks proper table
semantics. While this follows the existing admonitionblock pattern in the
codebase, the table should have a `role="presentation"` attribute or use
semantic div elements instead to improve accessibility for screen readers.
Tables should only be used for tabular data, not for layout purposes.
##########
extensions/promote-deprecated-attribute.js:
##########
@@ -0,0 +1,42 @@
+'use strict'
+
+/**
+ * This Antora extension promotes the 'deprecated' and 'supportlevel' AsciiDoc
+ * document attributes to page attributes so they can be accessed in
+ * Handlebars templates as page.attributes.deprecated and
page.attributes.supportlevel.
+ *
+ * This allows the UI to display warning banners for deprecated components.
+ */
+module.exports.register = function ({ config }) {
+ this.on('documentsConverted', ({ contentCatalog }) => {
Review Comment:
The function signature differs from the existing extension pattern in this
repository. The existing extensions use `register = (registry, context)` while
this uses `register = function ({ config })`. For consistency with the codebase
and to match Antora's extension API, this should follow the same pattern as
other extensions. However, if this is using a different Antora extension event
listener API, this may be acceptable.
```suggestion
module.exports.register = function (registry, context) {
registry.on('documentsConverted', ({ contentCatalog }) => {
```
##########
antora-ui-camel/src/css/doc.css:
##########
@@ -733,15 +733,20 @@
margin: 0.25rem 0 -0.25rem;
}
+.doc .colist > table {
+ border-spacing: 0;
+}
+
.doc .colist > table > tr > :first-child,
.doc .colist > table > tbody > tr > :first-child {
- padding: 0.25em 0.5rem 0;
+ padding: 0.25rem 0.5rem 0 0;
Review Comment:
The padding change from mixed units (`0.25em 0.5rem 0`) to consistent units
(`0.25rem 0.5rem 0 0`) improves unit consistency. However, the change from `em`
to `rem` in the first value alters the sizing behavior - `em` is relative to
the parent element's font size while `rem` is relative to the root font size.
This could cause a slight visual difference in the spacing, though it should
result in more consistent spacing across different contexts, which aligns with
the PR's goal.
```suggestion
padding: 0.25em 0.5rem 0 0;
```
##########
extensions/promote-deprecated-attribute.js:
##########
@@ -0,0 +1,42 @@
+'use strict'
+
+/**
+ * This Antora extension promotes the 'deprecated' and 'supportlevel' AsciiDoc
+ * document attributes to page attributes so they can be accessed in
+ * Handlebars templates as page.attributes.deprecated and
page.attributes.supportlevel.
+ *
+ * This allows the UI to display warning banners for deprecated components.
+ */
+module.exports.register = function ({ config }) {
+ this.on('documentsConverted', ({ contentCatalog }) => {
+ contentCatalog.getPages().forEach((page) => {
+ if (!page.asciidoc) return
+
+ const attributes = page.asciidoc.attributes
+ if (!attributes) return
+
+ // Initialize page attributes if not present
+ if (!page.asciidoc.attributes['page-deprecated']) {
+ // Check if the page has deprecated attribute
+ if (attributes.deprecated !== undefined) {
+ // Promote deprecated to page-deprecated
+ page.asciidoc.attributes['page-deprecated'] = attributes.deprecated
|| 'true'
+ }
+ }
+
+ if (!page.asciidoc.attributes['page-supportlevel']) {
+ // Check for supportlevel attribute (e.g., "Stable-deprecated")
+ if (attributes.supportlevel !== undefined) {
+ page.asciidoc.attributes['page-supportlevel'] =
attributes.supportlevel
+ }
+ }
+
+ if (!page.asciidoc.attributes['page-shortname']) {
+ // Check for shortname attribute (e.g., "nitrite", "component")
+ if (attributes.shortname !== undefined) {
+ page.asciidoc.attributes['page-shortname'] = attributes.shortname
Review Comment:
The extension's documentation states that attributes will be accessible as
`page.attributes.deprecated` and `page.attributes.supportlevel`, but the
implementation sets them as `page.asciidoc.attributes['page-deprecated']` and
`page.asciidoc.attributes['page-supportlevel']`. This creates a mismatch where
the template cannot access these attributes.
To fix this, the extension should set the attributes on the
`page.attributes` object directly instead of on `page.asciidoc.attributes`. The
code should be:
- `page.attributes = page.attributes || {}`
- `page.attributes.deprecated = attributes.deprecated || 'true'`
- `page.attributes.supportlevel = attributes.supportlevel`
- `page.attributes.shortname = attributes.shortname`
Alternatively, if `page.asciidoc.attributes` with the 'page-' prefix is the
correct Antora convention, then the template needs to be updated to access them
correctly.
```suggestion
page.attributes = page.attributes || {}
if (page.attributes.deprecated === undefined) {
// Check if the page has deprecated attribute
if (attributes.deprecated !== undefined) {
// Promote deprecated to page.attributes.deprecated
page.attributes.deprecated = attributes.deprecated || 'true'
}
}
if (page.attributes.supportlevel === undefined) {
// Check for supportlevel attribute (e.g., "Stable-deprecated")
if (attributes.supportlevel !== undefined) {
page.attributes.supportlevel = attributes.supportlevel
}
}
if (page.attributes.shortname === undefined) {
// Check for shortname attribute (e.g., "nitrite", "component")
if (attributes.shortname !== undefined) {
page.attributes.shortname = attributes.shortname
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]