-
Notifications
You must be signed in to change notification settings - Fork 440
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
API Descriptions Update #1940
base: main
Are you sure you want to change the base?
API Descriptions Update #1940
Conversation
Thanks for the PR! This section of the codebase is owned by @saschanaz - if they write a comment saying "LGTM" then it will be merged. |
We still depend on that, so we can't just remove it until we get a new mdn/content dependency? |
I know |
src/build.ts
Outdated
|
||
const OWNER = "mdn"; | ||
const REPO = "content"; | ||
const BASE_PATH = "files/en-us/web/api"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think maybe we should add a submodule so that we can make the build more reproducible locally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can do that
I will get started on that 😃
Hello @saschanaz, |
Maybe |
Hello:) |
I mean |
|
@@ -289,7 +297,11 @@ declare var ByteLengthQueuingStrategy: { | |||
new(init: QueuingStrategyInit): ByteLengthQueuingStrategy; | |||
}; | |||
|
|||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream) */ | |||
/** | |||
* Of the {{domxref('Compression Streams API','','',' ')}} is an API for compressing a stream of data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks weird. Now that we are at it, maybe we should remove:
TypeScript-DOM-lib-generator/src/build.ts
Lines 94 to 113 in cede2ca
const removeVerboseIntroductions: [RegExp, string][] = [ | |
[ | |
/^(The|A) ${name} interface of (the\s*)*((?:(?!API)[A-Za-z\d\s])+ API)/, | |
"This $3 interface ", | |
], | |
[ | |
/^(The|A) ${name} (interface|event|object) (is|represents|describes|defines)?/, | |
"", | |
], | |
[ | |
/^An object implementing the ${name} interface (is|represents|describes|defines)/, | |
"", | |
], | |
[/^The ${name} is an interface representing/, ""], | |
[/^This type (is|represents|describes|defines)?/, ""], | |
[ | |
/^The (((?:(?!API)[A-Za-z\s])+ API)) ${name} (represents|is|describes|defines)/, | |
"The $1 ", | |
], | |
]; |
Because I don't think it makes sense to deal with all kinds of human language without accidentally breaking things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be easier if we converted the Markdown to HTML. I can utilize Cheerio like the mdn and get the summary like mdn. If you think this is a good way to do it, I can implement it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why that's needed here, can you explain more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh you mean the domxref thing. Hmm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I was talking about the sentence unnaturally starting with "Of the Compression Stream API is an API"... (It's because the above code cuts the initial part of the sentence.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the reason that I made all these regexes is to avoid the weird template code. But if I convert the markdown to HTML first, I think it would be easier to extract the data without the weird templates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If using Cheerio is easy to remove domxref thing then I guess it's worth trying!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If using Cheerio is easy to remove domxref thing then I guess it's worth trying!
Okay
package.json
Outdated
@@ -13,6 +13,7 @@ | |||
], | |||
"scripts": { | |||
"build": "tsc && node ./lib/build.js", | |||
"generate": "tsc && node ./lib/generateDescriptions.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be part of build
instead (ideally called by lib/build.js?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can do that :)
@@ -289,7 +297,11 @@ declare var ByteLengthQueuingStrategy: { | |||
new(init: QueuingStrategyInit): ByteLengthQueuingStrategy; | |||
}; | |||
|
|||
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream) */ | |||
/** | |||
* Of the {{domxref('Compression Streams API','','',' ')}} is an API for compressing a stream of data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why that's needed here, can you explain more?
…ction and integrate it into build process
…ocessing and clean up output
return trimmed | ||
.replace(/\{\{domxref\(["'][^"']+["'],\s*["']([^"']+)["']\)\}\}/g, "$1") // Extract second argument from domxref | ||
.replace(/\{\{domxref\(["']([^"']+)["']\)\}\}/g, "$1") // Extract single-argument domxref | ||
.replace(/\{\{[^}]+\}\}/g, "") // Remove other MDN templates like {{CSSRef}} | ||
.replace(/<[^>]+>/g, "") // Remove HTML tags |
Check failure
Code scanning / CodeQL
Incomplete multi-character sanitization High
<script
We need to figure out a way to compile the markdown without the weird templates. |
fixes #1937