Skip to content
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

Merged
merged 3 commits into from
Aug 20, 2017
Merged

Add a README documenting everything #51

merged 3 commits into from
Aug 20, 2017

Conversation

domenic
Copy link
Member

@domenic domenic commented Aug 19, 2017

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.

@domenic domenic requested review from Sebmaster and TimothyGu August 19, 2017 04:25
Copy link
Member

@TimothyGu TimothyGu left a 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");
Copy link
Member

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], {
Copy link
Member

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;
}
```
Copy link
Member

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
Copy link
Member

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:

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;

Copy link
Member Author

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
Copy link
Member

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.)

Copy link
Member

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]`
Copy link
Member

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.
Copy link
Member

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.

Copy link
Member Author

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

soruce directory

@Zirro
Copy link
Member

Zirro commented Aug 19, 2017

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 - create(), createImpl(), more? - could be helpful as well.

(Thanks for the invitation!)

@Sebmaster
Copy link
Member

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.

@domenic
Copy link
Member Author

domenic commented Aug 19, 2017

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.

@TimothyGu
Copy link
Member

I'll have to educate myself on how the exported API looks like for typedefs and unions and such

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.

@domenic domenic merged commit 0e4eb1d into master Aug 20, 2017
@domenic domenic deleted the readme branch August 20, 2017 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a readme
4 participants