Skip to content
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

fix: Render userScripts_legacy.register as userScripts.register (Legacy) #12677

Closed
wants to merge 1 commit into from

Conversation

Rob--W
Copy link
Member

@Rob--W Rob--W commented Feb 26, 2025

Summary

Render userScripts_legacy.register as userScripts.register (legacy) in the example overview at https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Examples

See mdn/webextensions-examples#579

Problem

There are two versions of the userScripts.register API. In the API sidebar, documentation, BCD, etc., they are distinguished by the "(Legacy)" suffix. The documentation is at:

The current macro assumes that the URL slug and API name are identical. This is not the case for userScripts.register, so the examples.json index uses userScripts_legacy.register to refer to the legacy API. However, that causes the example to be rendered as "userScripts_legacy.register", which is not the name of the API.

Solution

The patch fixes the issue by special-casing this one exception, and rendering the anchor label as userScripts.register (Legacy).

@Rob--W Rob--W requested a review from a team as a code owner February 26, 2025 14:37
@github-actions github-actions bot added the macros tracking issues related to kumascript macros label Feb 26, 2025
@caugner
Copy link
Contributor

caugner commented Feb 26, 2025

@Rob--W MDN no longer uses yari kumascript macros here. Instead, these are now implemented in our new build system here: https://github.com/mdn/rari/blob/6f284f49f1a7421b7fba5eaf14e23af154c7170f/crates/rari-doc/src/templ/templs/webext_all_examples.rs#L8

@caugner caugner closed this Feb 26, 2025
@Rob--W
Copy link
Member Author

Rob--W commented Feb 26, 2025

After setting up mdn locally, I can confirm that with rari it renders as desired. This is because rari's implementation looks up the anchor label from the short_title of a page, instead of embedding the

None above is content, and since it is not specified, the logic looks up the anchor text from the rendered page, at https://github.com/mdn/rari/blob/6f284f49f1a7421b7fba5eaf14e23af154c7170f/crates/rari-doc/src/html/links.rs#L90:

            let content = if let Some(content) = content {
                Cow::Borrowed(content)
            } else {
                let content = page.short_title().unwrap_or(page.title());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
macros tracking issues related to kumascript macros
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants