Skip to content

Commit 6821602

Browse files
committed
move to index.ts to keep texts as intact as possible
1 parent 798e533 commit 6821602

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"jsdom": "^11.11.0",
1919
"node-fetch": "^2.1.1",
2020
"print-diff": "^0.1.1",
21-
"styleless-innertext": "^1.1.0",
21+
"styleless-innertext": "^1.1.2",
2222
"typescript": "next",
2323
"webidl2": "^13.0.2"
2424
}

src/idlfetcher.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,7 @@ function getCommentText(text: string) {
137137
.replace(//g, "'")
138138
.split("\n")
139139
.filter(line => !!line)
140-
.join("\n")
141-
// Filters out phrases for nested comments as we retargets them:
142-
// "This operation receives a dictionary, which has these members:"
143-
.replace(/[,.][^,.]+:/g, ".");
140+
.join("\n");
144141
}
145142

146143
function* generateDescriptionPairs(domIntro: Element) {

src/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function emitDom() {
3232

3333
// ${name} will be substituted with the name of an interface
3434
const removeVerboseIntroductions: [RegExp, string][] = [
35-
[/^(The|A) ${name} interface of (the\s*)*([a-z\s]+ API)(\\\'s)?/, 'An interface of the $3 '],
35+
[/^(The|A) ${name} interface of (the\s*)*([a-z\d\s]+ API)(\\\'s)?/, 'An interface of the $3 '],
3636
[/^(The|A) ${name} (interface|event|object) (is|represents|describes|defines)?/, ''],
3737
[/^An object implementing the ${name} interface (is|represents|describes|defines)/, ''],
3838
[/^The ${name} is an interface representing/, ''],
@@ -62,6 +62,7 @@ function emitDom() {
6262
const idl: string = fs.readFileSync(path.join(inputFolder, "idl", filename), { encoding: "utf-8" });
6363
const commentsMapFilePath = path.join(inputFolder, "idl", title + ".commentmap.json");
6464
const commentsMap: Record<string, string> = fs.existsSync(commentsMapFilePath) ? require(commentsMapFilePath) : {};
65+
commentCleanup(commentsMap)
6566
const result = convert(idl, commentsMap);
6667
if (deprecated) {
6768
mapToArray(result.browser.interfaces!.interface).forEach(markAsDeprecated);
@@ -70,6 +71,14 @@ function emitDom() {
7071
return result;
7172
}
7273

74+
function commentCleanup(commentsMap: Record<string, string>) {
75+
for (const key in commentsMap) {
76+
// Filters out phrases for nested comments as we retargets them:
77+
// "This operation receives a dictionary, which has these members:"
78+
commentsMap[key] = commentsMap[key].replace(/[,.][^,.]+:$/g, ".");
79+
}
80+
}
81+
7382
function apiDescriptionsToIdl(descriptions: Record<string, string>) {
7483
const idl: Browser.WebIdl = {
7584
interfaces: {

0 commit comments

Comments
 (0)