Skip to content

Conversation

@AugustinMauroy
Copy link
Member

Description

I'm back here 😁

I was reading this page using beta so need to fix this issue

Validation

Capture d’écran 2025-12-13 à 11 46 47

Related Issues

close #419

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run node --run test and all tests passed.
  • I have check code formatting with node --run format & node --run lint.
  • I have build locally and see the changes
  • I've covered new added functionality with unit tests if necessary.

Copilot AI review requested due to automatic review settings December 13, 2025 10:48
@AugustinMauroy AugustinMauroy requested a review from a team as a code owner December 13, 2025 10:48
@vercel
Copy link

vercel bot commented Dec 13, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
api-docs-tooling Ready Ready Preview Dec 20, 2025 4:46pm

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the deprecation documentation generator to display different alert box colors based on the deprecation type. Instead of showing all deprecation types with a red "danger" alert, the system now maps "Documentation" and "End-of-Life (Compilation)" types to blue "info" alerts, "Runtime" and "Runtime (Application)" types to orange "warning" alerts, and falls back to red "danger" for other types.

  • Extracts and parses deprecation type text from various node types (text, inlineCode, links)
  • Implements conditional logic to map deprecation types to appropriate AlertBox severity levels
  • Adds comprehensive unit tests to verify the type-to-level mapping behavior

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/generators/jsx-ast/utils/buildContent.mjs Adds text extraction and type matching logic to determine AlertBox level based on deprecation type keywords
src/generators/jsx-ast/utils/tests/transformHeadingNode.test.mjs New test suite covering the three main code paths: info level (documentation), warning level (runtime), and danger level (fallback)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Dec 13, 2025

Codecov Report

❌ Patch coverage is 60.56911% with 97 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.62%. Comparing base (9ddf8f9) to head (d9dae9f).
⚠️ Report is 4 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
scripts/compare-builds/web.mjs 0.00% 44 Missing ⚠️
scripts/compare-builds/legacy-json.mjs 0.00% 34 Missing ⚠️
src/utils/highlighter.mjs 0.00% 8 Missing ⚠️
scripts/compare-builds/utils.mjs 0.00% 4 Missing ⚠️
src/generators/legacy-json/utils/parseList.mjs 50.00% 3 Missing ⚠️
src/generators/jsx-ast/utils/transformer.mjs 0.00% 2 Missing ⚠️
src/generators/ast/index.mjs 75.00% 1 Missing ⚠️
src/generators/jsx-ast/utils/buildContent.mjs 96.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #518      +/-   ##
==========================================
+ Coverage   79.58%   80.62%   +1.03%     
==========================================
  Files         120      122       +2     
  Lines       12056    12108      +52     
  Branches      841      861      +20     
==========================================
+ Hits         9595     9762     +167     
+ Misses       2458     2343     -115     
  Partials        3        3              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines 211 to 239
// Map user-facing deprecation types to AlertBox levels
// documentation / compilation -> blue (`info`)
// runtime / application -> orange (`warning`)
// fallback -> danger (red)
let level = 'danger';

// Use stricter matching to avoid false positives (e.g., "compilation" inside "End-of-Life")
const normalizedTypeText = typeText
.replace(/[.,]/g, ' ')
.split(/\s+/)
.filter(Boolean);

if (
normalizedTypeText.includes('documentation') ||
normalizedTypeText.includes('compilation')
) {
level = 'info';
} else if (
normalizedTypeText.includes('runtime') ||
normalizedTypeText.includes('application')
) {
level = 'warning';
}

parent.children[index + 1] = createJSXElement(JSX_IMPORTS.AlertBox.name, {
children: slice(
parent.children[index + 1],
TYPE_PREFIX_LENGTH,
undefined,
{
textHandling: { boundaries: 'preserve' },
}
).node.children,
level: 'danger',
children: sliced,
level,
title: 'Type',
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Map user-facing deprecation types to AlertBox levels
// documentation / compilation -> blue (`info`)
// runtime / application -> orange (`warning`)
// fallback -> danger (red)
let level = 'danger';
// Use stricter matching to avoid false positives (e.g., "compilation" inside "End-of-Life")
const normalizedTypeText = typeText
.replace(/[.,]/g, ' ')
.split(/\s+/)
.filter(Boolean);
if (
normalizedTypeText.includes('documentation') ||
normalizedTypeText.includes('compilation')
) {
level = 'info';
} else if (
normalizedTypeText.includes('runtime') ||
normalizedTypeText.includes('application')
) {
level = 'warning';
}
parent.children[index + 1] = createJSXElement(JSX_IMPORTS.AlertBox.name, {
children: slice(
parent.children[index + 1],
TYPE_PREFIX_LENGTH,
undefined,
{
textHandling: { boundaries: 'preserve' },
}
).node.children,
level: 'danger',
children: sliced,
level,
title: 'Type',
});
parent.children[index + 1] = createJSXElement(JSX_IMPORTS.AlertBox.name, {
children: sliced,
level: getLevelFromDeprecationType(type),
title: 'Type',
});
const getLevelFromDeprecationType = (type) => {
   if (TYPES.EOL.includes(type) {...}
   // etc
}

@avivkeller
Copy link
Member

@AugustinMauroy Can you rebase so that #517 compares the build size here?

@github-actions
Copy link

github-actions bot commented Dec 15, 2025

Web Generator

File Base Head Diff
styles.css 118.37 KB 118.30 KB -67.00 B (-0.06%)
Pages (8)
File Base Head Diff
assert.html 331.55 KB 331.56 KB +3.00 B (+0.00%)
assert.js 462.63 KB 462.64 KB +3.00 B (+0.00%)
deprecations.html 502.36 KB 502.30 KB -58.00 B (-0.01%)
deprecations.js 256.70 KB 256.64 KB -58.00 B (-0.02%)
esm.html 158.41 KB 158.40 KB -3.00 B (-0.00%)
esm.js 133.83 KB 133.82 KB -3.00 B (-0.00%)
fs.html 1.30 MB 1.30 MB +6.00 B (+0.00%)
fs.js 1.29 MB 1.29 MB +6.00 B (+0.00%)
globals.html 223.14 KB 223.16 KB +14.00 B (+0.01%)
globals.js 118.28 KB 118.30 KB +14.00 B (+0.01%)
intl.html 60.42 KB 60.44 KB +15.00 B (+0.02%)
intl.js 35.36 KB 35.38 KB +15.00 B (+0.04%)
wasi.html 67.85 KB 67.80 KB -45.00 B (-0.06%)
wasi.js 43.29 KB 43.25 KB -45.00 B (-0.10%)
worker_threads.html 360.12 KB 360.11 KB -4.00 B (-0.00%)
worker_threads.js 409.39 KB 409.39 KB -4.00 B (-0.00%)

Co-Authored-By: Aviv Keller <[email protected]>
*
* @param nodes
*/
const getTextValue = nodes =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned befroe, there's a method to get text value, you can get rid of this.

Copy link
Member

@avivkeller avivkeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm putting an explicit blocker on this until:

  1. Either transformNodeToString is used, or nodes[0].value is used. nodes[0].value should be sufficient, since the node immediately following the prefix slicing is the deprecation type.

  2. getLevelFromDeprecationType does not use .includes to find words. This is extremely prone to false positives. I'd prefer using nodes[0].value.startsWith or similar, since we know the nodes should start with the type.

    • While it's possible (and I haven't checked) that some nodes don't follow this rule due to inconsistencies in core, I'd much rather fix those inconsistencies in core, than make a too-loose check here.

Co-Authored-By: Aviv Keller <[email protected]>
Co-Authored-By: Claudio Wunder <[email protected]>
if (entry.api === 'deprecations' && node.depth === 3) {
// On the 'deprecations.md' page, "Type: <XYZ>" turns into an AlertBox
// Extract the nodes representing the type text
const sliced = slice(
Copy link
Member

@ovflowd ovflowd Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change to:

    const { node: { children: sliced } } = slice(
      parent.children[index + 1],
      TYPE_PREFIX_LENGTH,
      undefined,
      { textHandling: { boundaries: 'preserve' } }
    );

Copy link
Member

@ovflowd ovflowd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM but left some comments.

avivkeller and others added 13 commits December 19, 2025 09:56
* feat(comparisons): SHA unifying, `legacy-json` comparison

* code review;

* fixup!

* fixup!
* chore: reduce dependency count

* fixup!
* fix(changes): reverse change order

* fixup!
Co-Authored-By: Aviv Keller <[email protected]>
Co-Authored-By: Aviv Keller <[email protected]>
Co-Authored-By: Aviv Keller <[email protected]>
Co-Authored-By: Claudio Wunder <[email protected]>
Co-Authored-By: Claudio Wunder <[email protected]>
Copy link
Member

@ovflowd ovflowd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AugustinMauroy your rebase fucked up the whole PR 😓

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Depreacation page is "to red"

4 participants