-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
Add a README documenting everything #51
Conversation
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 for doing this!
README.md
Outdated
const implModule = require("../implementations/SomeInterface-impl.js"); | ||
|
||
function SomeInterface() { | ||
throw TypeError("Illegal constructor"); |
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.
Missing new
.
README.md
Outdated
} | ||
|
||
const args = []; | ||
args[0] = conversions["DOMString"](args[0], { |
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.
Missing arguments copying. Alternatively arguments[0]
can be used instead.
README.md
Outdated
obj[impl] = new implModule.implementation(constructorArgs, privateData); | ||
return obj; | ||
} | ||
``` |
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.
Export interface = SomeInterface
too?
README.md
Outdated
Notable missing features include: | ||
|
||
- Legacy platform objects, i.e. those using `getter`/`setter`/`deleter` declarations ([in progress](https://github.com/jsdom/webidl2js/pull/48)) | ||
- Partial interfaces |
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 do support partial interfaces:
Lines 128 to 140 in 90c96b2
case "interface": | |
if (!instruction.partial) { | |
break; | |
} | |
if (this.options.suppressErrors && !interfaces.has(instruction.name)) { | |
break; | |
} | |
oldMembers = interfaces.get(instruction.name).idl.members; | |
oldMembers.push(...instruction.members); | |
extAttrs = interfaces.get(instruction.name).idl.extAttrs; | |
extAttrs.push(...instruction.extAttrs); | |
break; |
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.
Ah, I missed the ! on that line
README.md
Outdated
- Class strings (with the semantics of [heycam/webidl#357](https://github.com/heycam/webidl/pull/357)) | ||
- Dictionary types | ||
- Union types | ||
- Callback function types |
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 entirely IIRC.
README.md
Outdated
* webidl2js attempts to generate informative error messages using what it knows. | ||
|
||
For more examples, you can check out the `test/` directory (with the generated output being in `test/__snapshots__`). Alternately, you can install [jsdom](https://www.npmjs.com/package/jsdom), [whatwg-url](https://www.npmjs.com/package/whatwg-url), or [domexception](https://www.npmjs.com/package/domexception) from npm and check out their source code. (Note that browsing them on GitHub will not work, as we do not check the generated files into Git, but instead generate them as part of publishing the package to npm.) | ||
|
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.
Would be good to have an example implementation file.
- Also: add exports.is - Also: use consistent - for bullets
README.md
Outdated
- `[LenientSetter]` | ||
- `[LenientThis]` | ||
- `[NamedConstructor]` | ||
- `[OverrideBuiltins]` |
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.
In progress too.
README.md
Outdated
|
||
### `[Reflect]` | ||
|
||
The `[Reflect]` extended attribute is implemented to call `this.getAttribute` or `this.setAttribute` and process the input our output using [webidl-html-reflector](https://github.com/domenic/webidl-html-reflector), generating both a getter and a setter. If `[Reflect]` is specified, the implementation class does not need to implement any getter or setter logic. |
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.
What's webidl-html-reflector? grepping it in both jsdom and webidl2js returns nothing. We have https://github.com/jsdom/webidl2js/blob/master/lib/reflector.js BTW.
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.
Ah, I forgot that this switched when @Sebmaster created webidl2js instead of my old https://github.com/domenic/webidl-class-generator. (Which I should probably tombstone...)
README.md
Outdated
|
||
The main module's default export is a class which you can construct with a few options: | ||
|
||
- `implSuffix`: a suffix used, if any, to find files within the soruce directory based on the IDL file name. |
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.
soruce directory
Nice work! This will surely make both webidl2js and jsdom easier to approach for new contributors. Perhaps a brief section explaining the most common methods used to work with the generated code - (Thanks for the invitation!) |
We should document the wrapper vs impl instance difference, and how it can bite you if you do something weird with your args? I think we fixed arrays yeah? But there might be other cases where that can become a problem. |
OK, I want to start a new PR documenting the generated wrapper files API, as I think it will require more iteration (e.g. I'll have to educate myself on how the exported API looks like for typedefs and unions and such). We can also cover the wrapper vs. impl difference there. In the meantime I've updated according to the great review comments. Happy for people to do another pass. |
Typedefs are internally converted to its definition (i.e. exactly what you would expect). Nothing too special there. Unions are treated with fully spec-complaint behavior (including nested unions, error checking against indistinguishable member types, and extended attributes on types). For both you can check TypedefsAndUnions.idl and its snapshot. |
Closes #1.
Also review from @Zirro would be cool; not sure why they're not part of the org yet. Will try to fix that.