-
Notifications
You must be signed in to change notification settings - Fork 1
Add MDN documentation links to generated WebAPI bindings #11
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
Conversation
Co-authored-by: bikallem <315907+bikallem@users.noreply.github.com>
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.
Pull request overview
This PR adds MDN documentation links to generated MoonBit bindings for Web Platform APIs, improving developer experience by providing easy access to Web API reference documentation.
- Adds helper functions to construct MDN documentation URLs
- Updates all interface method and type emitters to include MDN doc comments
- Updates test snapshots in interface_emitter_wbtest.mbt to reflect new documentation format
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| webapi_gen/emit/emit.mbt | Adds mdn_interface_url and mdn_member_url helper functions; updates External type and InterfaceDefinition emitters to include MDN doc comments |
| webapi_gen/emit/interface_method_emit.mbt | Updates all five method emitters (RegularMethodEmit, StaticMethodEmit, AttributeGetMethodEmit, AttributeSetMethodEmit, StaticAttributeGetMethodEmit) to emit MDN documentation links for methods and attributes |
| webapi_gen/emit/interface_emitter_wbtest.mbt | Updates all test snapshots to expect new MDN documentation format in generated code |
| let mdn_url = mdn_interface_url(type_name) | ||
| buf.write_string("/// [\{type_name}](\{mdn_url})\n#external\npub type \{type_name}") |
Copilot
AI
Jan 6, 2026
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.
The current implementation adds MDN documentation links to all External types, including synthetic union types that don't exist in MDN. For example, TestInterfaceTestMethodParam2 is a generated type name for nested union types like (unsigned long or boolean), not an actual Web API interface.
These synthetic union types are created by the code generator at line 594 in emit.mbt when processing nested unions. They should not include MDN documentation links since they don't correspond to any Web API documentation.
Consider:
- Adding a flag or variant to the
Emit::Externaltype to distinguish between real Web API interfaces and synthetic union types - Only emitting MDN documentation for External types that correspond to actual WebIDL interfaces, callbacks, or dictionaries (not synthetic union types)
- Alternatively, use a different naming pattern for synthetic union types that makes it clear they shouldn't have MDN links
| let mdn_url = mdn_interface_url(type_name) | |
| buf.write_string("/// [\{type_name}](\{mdn_url})\n#external\npub type \{type_name}") | |
| buf.write_string("/// \{type_name}\n#external\npub type \{type_name}") |
Generated MoonBit bindings lack documentation linking to MDN Web API references, making it harder for developers to understand the underlying Web Platform APIs.
Changes
emit.mbt): Addedmdn_interface_urlandmdn_member_urlfunctions to construct MDN documentation URLsEmit::Externalnow emits doc comments with MDN links for interface typesEmit::InterfaceDefinitionincludes MDN links for trait definitionsRegularMethodEmit,StaticMethodEmit,AttributeGetMethodEmit,AttributeSetMethodEmit,StaticAttributeGetMethodEmit) to include MDN linksExample
After running
make gen, generated code will include:Run
make gento regenerate bindings with documentation links.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
download.mooncakes.io/home/REDACTED/.moon/bin/moon moon check --target js(dns block)/home/REDACTED/.moon/bin/moon moon check --target native(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.