Skip to content

Build the JavaScript, CSS and Web APIs documentations from the MDN content repository - #2738

Merged
simon04 merged 7 commits into
mainfrom
mdn
Sep 14, 2026
Merged

simon04 merged 7 commits into
mainfrom
mdn

Conversation

@simon04

@simon04 simon04 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

These three documentations are scraped off developer.mozilla.org one page at a
time, plus one request per page to bcd.developer.mozilla.org for the browser
compatibility table. MDN publishes the same documents as markdown in
mdn/content, so this reads them from there
instead: the scrapers download the repository once and build from disk, sending
no request while a documentation is generated.

Documentation Pages Build time (-j 8)
JavaScript 1300 5.8s
CSS 1029 17s
Web APIs 8108 31s

Web APIs used to be 8108 page requests and 7839 compatibility requests.

How it works

Docs::MdnGit is a FileScraper that downloads the content repository along
with the packages MDN generates the rest of a page out of —
@mdn/browser-compat-data, web-features, web-specs and, for CSS,
mdn-data — and prunes them to what the documentation queries (25MB of JSON
down to 2MB for JavaScript). lib/docs/mdn_content/ holds the page index, the
markdown renderer and an implementation of the 50 KumaScript macros these
documentations use, including the ones MDN renders server-side: {{Compat}},
{{Specifications}}, {{CSSSyntax}} and {{CSSInfo}}.

Every page is known upfront, so nothing is crawled and FixInternalUrlsBehavior
is no longer needed.

Output

Entries Name changes Miscellaneous
JavaScript 1294 → 1300 0 26 → 27
CSS 1107 → 1028 0 912 → 3
Web APIs 7766 → 8107 0 2501 → 1855

No entry is renamed. The CSS and Web APIs entries filters used to name the part
of the platform a page belongs to after a table of specifications that MDN
rendered into every page; that table has been gone for a while, which is why
912 of 1107 CSS entries sat under Miscellaneous. The specifications are now
looked up in browser-compat-data and web-specs, which puts 909 CSS entries
and 852 Web APIs entries back where they belong.

The pages also come out smaller — 13.5MB → 11.7MB for JavaScript — now that
MDN's own wrappers aren't part of them, and a few long-standing scraping
artifacts are gone (the stray > in every specification table, dead links from
unescaped fragments).

Breaking change

MDN has moved its CSS reference under Web/CSS/Reference, so the CSS pages move
with it: css/animation becomes css/properties/animation. This would happen
on any re-scrape from today's MDN, but it lands when this is published.

Unchanged

Docs::Mdn and its filters are untouched; HTML, SVG, Web Extensions, XSLT &
XPath and HTTP still crawl developer.mozilla.org. Those can move over the same
way later, at which point Docs::Mdn and mdn/compat_tables can go.

Known limitations

  • CSS formal syntax is printed one alternative per line, without MDN's column
    alignment or a link on every multiplier.
  • {{SubpagesWithSummaries}} renders the index without the summaries (2 pages).
  • The Baseline indicator carries the status and the date, not MDN's
    "Learn more" / "See full compatibility" links.
  • Two macro calls in Web APIs are left unexpanded by a code fence
    web/api/webtransport_api/index.md forgets to close; MDN renders that page
    the same way.

New dependency

kramdown and kramdown-parser-gfm, in the docs group. Redcarpet flattens
the nested lists MDN writes its definition lists as, and reads two consecutive
GitHub alerts as a single blockquote.

The scrapers reading the MDN content repository need the data packages
MDN generates its compatibility tables out of alongside the documents.
Redcarpet flattens the lists MDN writes its definition lists as, and
reads two consecutive GitHub alerts as a single blockquote. kramdown's
GFM parser nests both the way CommonMark does.
MdnGit reads the markdown of https://github.com/mdn/content rather than
the pages developer.mozilla.org renders out of it, which are the same
documents with their sidebars, compatibility tables and specifications
filled in. It downloads the content repository and the packages MDN
builds those sections out of — browser-compat-data, web-features,
web-specs and mdn-data — and expands the KumaScript macro calls its
authors leave in the markdown itself.

Every page is known upfront, so nothing is crawled and no request is
sent while a documentation is built. Mdn, which crawls, stays behind for
the documentations that haven't moved over.
The 1300 pages of the reference are read off disk rather than crawled,
and their compatibility tables built from a local copy of
browser-compat-data rather than from one request per page to
bcd.developer.mozilla.org. The entries come out unchanged.

The clean_html filter goes: the markup it was undoing is MDN's, and the
documents no longer carry any of it.
All 8108 pages, none of them requested over HTTP.

The entries filter used to name the part of the web platform a page
documents after the specification table MDN rendered into it. That table
has been gone for a while, which left 2501 entries under Miscellaneous;
the specifications are now looked up in browser-compat-data and
web-specs, which puts 852 of them back where they belong.
The formal syntax of a property and the table of its characteristics are
generated out of mdn-data, the way MDN generates them.

As with the web APIs, the entries filter was reading the part of CSS a
page belongs to off a table that no longer exists, leaving 912 of 1107
entries under Miscellaneous; there are 3 left. Note that MDN has since
moved its reference under Web/CSS/Reference, so the pages move with it.
Four things kept a call from being expanded or a link from resolving:

- A call inside an inline code span was skipped along with the ones in
  the code blocks, which are the only ones meant to read literally.
- The tables generated out of mdn-data are written with the same
  cross-references as the prose, so an expansion can hold a call itself.
- An argument is written the way it reads, quoted with backticks as
  often as not, escaped as &lt;color&gt; rather than <color>, and left
  out altogether in {{rfc("7002",,"3.2")}}.
- Neither the fragments of browser-compat-data nor the ones MDN's
  authors write are escaped, and URL.parse rejects both.

The JavaScript and CSS documentations come out with no call left
unexpanded and no dead link; the two remaining in the web APIs are a
code fence upstream forgot to close.
@simon04
simon04 requested a review from a team as a code owner September 14, 2026 12:35
@simon04 simon04 self-assigned this Sep 14, 2026
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedgem/​kramdown-parser-gfm@​1.1.09910010075100
Addedgem/​kramdown@​2.5.291100100100100

View full report

@simon04
simon04 merged commit 43bbb4b into main Sep 14, 2026
3 checks passed
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.

1 participant