Skip to content

Generate the Legacy Flags reference from source - #14720

Merged
ArmandPhilippot merged 10 commits into
mainfrom
armand/generate-legacy-flags
Oct 26, 2026
Merged

ArmandPhilippot merged 10 commits into
mainfrom
armand/generate-legacy-flags

Conversation

@ArmandPhilippot

@ArmandPhilippot ArmandPhilippot commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Description (required)

Extends the existing docgen.mjs script to automatically generate the legacy-flags.mdx file, in the same way as for configuration-reference.mdx. This generates both the page introduction (from config.legacy) and the legacy flags using their respective JSDoc.

I think it can be helpful for:

  • devs: configuration references are always generated from types/public/config.ts (except experimental flags...), and they don't have to wonder if this requires a docs update.
  • docs: we review changes once, and we can always catch rendering issues with the CI PR.

I tested the docgen script locally, and this seems to work fine:

$ node ./scripts/docgen.mjs
Fetch `src/types/public/config.ts` from withastro/astro#main: 0.004ms
Parse types and generate configuration reference: 92.164ms
Update configuration-reference.mdx: 0.224ms
Update legacy-flags.mdx: 0.041ms

The additional time seems reasonable. But, if anyone want to test by themselves; they'll need those changes: withastro/astro#18378

The possible caveat is: we don't have a fallback placeholder when there are no legacy flags. But, looking at when the last one was introduced, we always keep the legacy object. So, I think the easy fix is to put Currently no legacy flags are available. to the JSDoc when this happens, instead of an inline comment.

References

@astrobot-houston

astrobot-houston commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the tracking.ignoredKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
reference/legacy-flags.mdx Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Preview deployment

✅ Deployment complete!

@ArmandPhilippot
ArmandPhilippot marked this pull request as ready for review October 15, 2026 16:11

@yanthomasdev yanthomasdev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good work! Added two suggestions regarding the behavior when no legacy flags are found in the core repo.

Comment thread scripts/docgen.mjs
* Options prefixed with `legacy.` are documented on that page instead of the configuration reference.
*/
const LEGACY_NAME = 'legacy';
const LEGACY_PREFIX = `${LEGACY_NAME}.`;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Like you mentioned in the description, I think it's the best approach to add a small warning when no legacy flags are available. It's a small addition so I am going to make suggestions for the change.

Suggested change
const LEGACY_PREFIX = `${LEGACY_NAME}.`;
const LEGACY_PREFIX = `${LEGACY_NAME}.`;
/** Displayed on the legacy flags page when no `legacy` options are documented. */
const NO_LEGACY_FLAGS = `Currently no legacy flags are available.\n`;

Comment thread scripts/docgen.mjs
Comment on lines +110 to +111
configResult = formatLinks(configResult, 'configuration-reference');
legacyResult = formatLinks(legacyIntro + legacyResult, 'legacy-flags');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And maybe we also want to error if no legacy intro is found at all?

Suggested change
configResult = formatLinks(configResult, 'configuration-reference');
legacyResult = formatLinks(legacyIntro + legacyResult, 'legacy-flags');
// Without an intro, the source is likely missing the legacy flags docs entirely,
// so it should fail instead of overwriting the page with an empty one.
if (!legacyIntro) {
throw new Error(`Missing @docs JSDoc comment with a description for @name ${LEGACY_NAME}`);
}
configResult = formatLinks(configResult, 'configuration-reference');
legacyResult = formatLinks(legacyIntro + (legacyResult || NO_LEGACY_FLAGS), 'legacy-flags');

@ArmandPhilippot ArmandPhilippot Oct 15, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, I'm not sure what the best approach is, and I was hoping for some brainstorming. So, thanks for bringing that up!

I think throwing an error for the intro makes sense as a safety net!

But, we probably want "Currently no legacy flags are available." to also appear in the JSDoc directly for people accessing legacy in the editor? So, I'm torn regarding NO_LEGACY_FLAGS. My current approach was to add it to the JSDoc (and document that in AD²). Adding it here might cause it to appear twice. But, it's also something easy to miss when removing legacy flags...

The changes still go through the nightly CI PR, so maybe it's enough to catch something wrong?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks, @yanthomasdev! I tested a few things locally and I still think the Error is a nice addition. Pushed with e705c8a

I still think "Currently no legacy flags are available." should be in the JSDoc, and we might end with the same sentence twice with NO_LEGACY_FLAGS. So, maybe we should try this and see if it's possible that we're forgetting to update the JSDoc. What do you think?

@ArmandPhilippot
ArmandPhilippot merged commit 5130890 into main Oct 26, 2026
9 checks passed
@ArmandPhilippot
ArmandPhilippot deleted the armand/generate-legacy-flags branch October 26, 2026 11:18
awwa pushed a commit to awwa/docs that referenced this pull request Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants