-
Notifications
You must be signed in to change notification settings - Fork 38
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
[FEATURE] Automatic extraction #58
[FEATURE] Automatic extraction #58
Conversation
Amazing work! I will take a look soon, right now a bit bogged down. I'll also be interested to look more closely at how the upstream projects work, and whether I think the style they use will be sufficient. In particular, it looks like it makes similar decisions to https://github.com/microsoft/TypeScript-DOM-lib-generator, which I used to generate the very first version of this file but later diverged from heavily. One reason I did this was to prevent mostly-empty interfaces from being compatible (e.g. prevent a GPUTexture from being implicitly convertible to a GPUSampler), so I wonder if we can find a solution to that (either with private |
Thanks for looking at this PR. I had looked at TypeScript-DOM-lib-generator but decided against using it because it requires a json object and proposing changes that fix edge cases (like the I created bikeshed-to-ts to handle the rest:
I had seen #11 and was wondering about it, hopefully this gets released soon. In the mean time I can implement a hack similar to interface A {
readonly __brand: unique symbol;
} works but it exposes |
Thanks for the details!
Aha, this makes sense. Unfortunately the spec may not ALWAYS use
Unfortunately I don't. Putting a non-private brand in the There are a number of alternatives out there, which we could consider. I know TypeScript's built-in We definitely want these types to be as high quality as possible, and that probably means at least dropping the |
A thought: Since the bikeshed source is markdown+html-ish, regular expressions could potentially break down in certain cases (like nested |
I feel like we should try to keep nominal typing, the main reason to use TypeScript is type safety/checks and the definitions should provide just that.
yeah, I'll implement the
right now it handles the file line-by-line, which makes dealing with regexes and XML easier so it should be sufficient for now. I am still learning the bikeshed spec though so it might be incorrect, I'll give switching the custom parsing with the bikeshed parser a try and report back. |
I decided to go with adding a I used bikeshed-js to parse the I can get an HTML file from the bikeshed parser now, but I am having trouble wrapping my head around what to do with it. It is much easier to parse HTML but it seems to me that things are not as neatly organized/printed as in the Can we define what needs to be included in the JSDoc comments? |
I wasn't sure whether this would be the case, but I am not too surprised. Indeed there is a ton of HTML generated for bikeshed code, but I wasn't sure if all the metadata would be included in the end. If not, then I guess it's not a good suggestion, sorry :/
That's a good question. Unfortunately there's no immediately obvious answer - there's no strict delineation between "summary" and "detailed algorithm" for various items in our spec, though it did seem like you had hit a pretty good balance here. For requestAdapter for example, I think we want exactly what you got. More generally:
Anyway, we don't have to solve the documentation perfectly right now. Auto-generating even with NO documentation would be a huge help! In fact, we don't even have to fully auto-generate, and in fact right now we probably won't want to, because at any given time there are usually some deprecated items that we still include in the types because implementations (*cough*chrome) isn't quite up to spec yet. I'm imagining this workflow for a developer updating these types:
Someday we probably won't need this, but right now it would be a very nice way to reduce the maintenance burden but maintain the flexibility. |
Agreed, that makes sense to me, I have pushed a commit that changes the generation script to write its result to I don't feel I am equipped to decide which changes should be kept and which shouldn't though :/ |
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.
No worries - thanks for this awesome contribution!
I think for the first version we can basically replace the checked-in version with the generated version, then look through the old version and port any necessary changes into it. I can take care of that.
I'm happy to start landing this and then we can work through the remainder afterward. Left a few minor comments and then LGTM :)
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.
thanks!
Addresses: #48
First pass at auto-generating the type definitions and adding JSDoc style (TypeDoc) comments to the declarations.
I have tested this locally but I haven't tested it with
gpuweb/cts
so it's not ready to merge but I thought I'd submit this PR to start getting feedback early.What it does:
gpuweb/gpuweb
repo as a submodule