Skip to content

Conversation

Bashamega
Copy link
Contributor

Migrate to be using the json API
closes #2151
closes #2086
closes #2078

* The
* setValueCurveAtTime() method of the
* AudioParam interface schedules the parameter's value to change
* following a curve defined by a list of values.
Copy link
Contributor

Choose a reason for hiding this comment

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

newline-to-space normalization seems to be needed.

import fs from "fs/promises";
const basePath = new URL("../../inputfiles/mdn/files/en-us/", import.meta.url);
import { readFile } from "fs/promises";
const inputFile = new URL("../../inputfiles/mdn/mdnData.json", import.meta.url);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe just inputfiles/mdn.json? And you can do import * as data from "(path)" with { type: "json" }

import { readFile } from "fs/promises";
const inputFile = new URL("../../inputfiles/mdn/mdnData.json", import.meta.url);

interface MetaDataEntry {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should treat meta and data separately, let's do Metadata.

@Bashamega
Copy link
Contributor Author

I have updated it @saschanaz,
But the import JSON file didn't work for some reason.
This is the error: https://github.com/microsoft/TypeScript-DOM-lib-generator/actions/runs/18124591077/job/51576830796?pr=2171

Comment on lines 1858 to 1863
/**
* The **`console.trace()`** static method outputs a stack trace to the console.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/trace_static)
*/
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/trace_static) */
trace(...data: any[]): void;
Copy link
Member

Choose a reason for hiding this comment

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

Seems like these docs are missing?

Copy link
Contributor

@saschanaz saschanaz left a comment

Choose a reason for hiding this comment

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

I think you reverted too early. The module error doesn't happen locally.

| (startswith("/en-us/docs/web/api/") or startswith("/en-us/docs/webassembly/reference/javascript_interface/")))
)
| { mdn_url, pageType, summary } ] }' \
> mdn.json
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do bash magic when we can filter it in the script instead?

@Bashamega
Copy link
Contributor Author

The module error also occurs on my local machine (Ubuntu), @saschanaz.

I used the bash magic because it significantly reduces the output size — most of the data isn’t needed.
For comparison:

Current (filtered and formatted): 2.5 MB

Original (unfiltered, unformatted): 28.7 MB

That’s over 11× larger (28.7 MB vs 2.5 MB), so I think the extra shell step is worth it.
Plus, the command is still quite readable.

@Bashamega
Copy link
Contributor Author

I’ve added support for _static, so there is no missing comments now, @jakebailey.

@saschanaz
Copy link
Contributor

saschanaz commented Oct 1, 2025

The module error also occurs on my local machine (Ubuntu), @saschanaz.

Are you seeing the exact same module error? Because that error says you don't have lib/build.js, which means typescript silently failed to compile anything at all. Can you check what's in lib/ in that case?

I used the bash magic because it significantly reduces the output size — most of the data isn’t needed. For comparison:

Current (filtered and formatted): 2.5 MB

Original (unfiltered, unformatted): 28.7 MB

That’s over 11× larger (28.7 MB vs 2.5 MB), so I think the extra shell step is worth it. Plus, the command is still quite readable.

Hmm, fair. I think we should still fetch and filter in typescript instead, as bash usage would break on Windows.

@saschanaz
Copy link
Contributor

Or well, in JS, to save a build step.

@Bashamega
Copy link
Contributor Author

Bashamega commented Oct 1, 2025

Hmm, fair. I think we should still fetch and filter in typescript instead, as bash usage would break on Windows.

I don't think that this is an issue, since no one would actually run it, but sure, I will write a script to generate the file

@Bashamega
Copy link
Contributor Author

Are you seeing the exact same module error? Because that error says you don't have lib/build.js, which means typescript silently failed to compile anything at all. Can you check what's in lib/ in that case?
Yes, it is the same error

@saschanaz
Copy link
Contributor

Can you check what's in lib/ in that case?

@Bashamega
Copy link
Contributor Author

image Here

@Bashamega
Copy link
Contributor Author

I have removed the bash magic @saschanaz

Copy link
Contributor

@saschanaz saschanaz left a comment

Choose a reason for hiding this comment

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

Looks good, but this will need to update with the latest main branch.

# Example: https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1463
- run: npm i
- name: Update MDN Data
run: node scripts/generateMDN
Copy link
Contributor

Choose a reason for hiding this comment

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

We are not really generating but more fetching.

really not a fan of camelCasing on file paths though 🫠

I do recognize we have deploy/ which is mostly written by Orta than me, and we do have jsonc files that preexisted, but any new files have been hyphen-cased...

}
}

function extractSlug(slug: string): string[] {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why reorder the function? Almost thought this is an entirely new function with the same name.. Keeping its position should help reducing the diff.

@Bashamega
Copy link
Contributor Author

I have renamed it, and rebased it @saschanaz

interface RTCRtpTransceiver {
/**
* The **`setCodecPreferences()`** method of the RTCRtpTransceiver interface is used to set the codecs that the transceiver allows for decoding _received_ data, in order of decreasing preference.
* The setCodecPreferences() method of the RTCRtpTransceiver interface is used to set the codecs that the transceiver allows for decoding received data, in order of decreasing preference.
Copy link
Member

Choose a reason for hiding this comment

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

Are we just generally losing all markup?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, because the JSON doesn't have Markdown

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, because the JSON doesn't have Markdown

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah. We could hack around by matching the first occurrence of the name though...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR is big as is, maybe a separate PR

Copy link
Contributor

Choose a reason for hiding this comment

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

Technically hacking around would reduce the size of the PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

(You can open PR on my fork and then I can try it)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I will hack it today

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.

Migrate to MDN metadata.json
4 participants