-
Notifications
You must be signed in to change notification settings - Fork 440
Verbosity replacers #659
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
Verbosity replacers #659
Conversation
Looks good but I think the function should be in idlfetcher.ts (where |
That would not be a good idea, @saschanaz Processing string replacement AFTER the docs imported in JSON leaves a useful trace of text before and after string replacement. While well-tuned to fit future MDN text, the string replacers are not fool-proof. One day they may produce weird results, and having such trace make diagnostics and tweaking process smoother. As I've worked on this PR, it took me a few iterations to get string replacers right. Being able to see before/after states is key to productivity. There's a lot of text to process, hundreds of replacement matches. With this current implementation, in case of doubt you consult original MDN text sitting in JSON. Otherwise you would have to consult MDN website instead, which can't really scale for 100s of replacers. |
Makes sense. Thanks for clarification. |
Ping @sandersn do you agree? Might be cool to get it in, so new MDN docs look even better, come next release. |
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.
A couple of minor comments, but otherwise looks great.
Good, applied your changes @sandersn and everything tidy and works. Thanks! |
src/index.ts
Outdated
[/^(The|A) ${name} (interface|event|object) (is|represents|represent|describes|defines)?/, ''], | ||
[/^An object implementing the ${name} interface (is|represents|represent|describes|defines)/, ''], | ||
[/^The ${name} is an interface representing/, ''], | ||
[/^This type (is|represents|represent|describes|defines)?/, ''], |
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.
Looks like represent
is not needed anymore for the latest MDN descriptions.
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.
@mihailik We still have one represent
, is it still needed?
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 would keep it in this code. This can slip in at any time again in MDN.
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.
We can fix typos on MDN in any time. Better to fix on MDN rather than to workaround on TSJS.
@mihailik Can you try running |
ce8a662
to
d12ae59
Compare
Updated:
Works good, and spotted this quirk coming from the original upstream text: "IntersectionObserver": "provides a way to asynchronously observe changes in the intersection of a target element with an ancestor element or with a top-level document's viewport.", The actual MDN page for IntersectionObserver doesn't have that quirky text, must be an issue with the import? Note: this is not a result of my changes. Just as I referred above, the MDN fetch process and verbosity string replacers are two separate steps. The mangling happened before verbosity, somewhere in scraping the docs from MDN (or in the way MDN exports the docs maybe?) |
@saschanaz the examples you've mentioned seem fine. Text is meaningful, and fluent enough. However |
CryptoKey currently says:
I thought you would be prefer |
Wiped one more missed
If
As you can see, it's not meant to convert into And the issue with We can introduce another replacer, but it would only target 2 cases: |
So we had some mistakes there:
Thanks for clarification 😀 |
Note that I merged from master but did not re-run fetch-mdn. The results looked funny so I left it alone. |
Thank you, thank you @sandersn! Sorry I left it ferment for long, hope it brewed into a hearty dish :-) And thanks for making TypeScript such a useful tool. Good job folks! |
No problem. I've only been merging PRs here at the beginning of each release, so it's mostly my fault. |
Using a short array of variative
RegExp
s, to match(the|a)
and(object|event|interface)
and(is|represents)
.Replacers are tried in array order, until one succeeds. More tailored replacers can go first, and if those fail -- less clever ones can have a go.
In either case, after replace the first letter of description is re-capitalised again.
It's only 6 replacers, hope easy to review/maintain.