-
Notifications
You must be signed in to change notification settings - Fork 25
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
Generate Typescript documentation from wit files #1157
Generate Typescript documentation from wit files #1157
Conversation
|
The core changes are done, but I still need to debug an issue with the npm tests. After these changes Jest is not able to resolve the module imports, even though |
… .d.ts files using the `jco types` command. This command is better for our use case than `jco transpile` because it generates the declarations directly from the source .wit files, whereas `jco transpile` uses the WASM binaries to generate them. This means that `jco types` has access to the documentation that's written in the wit interfaces, and `jco transpile` does not. Since we're generating the interfaces in a separate step, I'm disabling typescript in the original `jco transpile` step. This is just a precaution to avoid confusion or possible conflicting declaration files interferring with each other.
…is correctly propagating through the build process.
…rpose of this is so that both processes use the same `CodegenFileSystem` instance. If they used separate instances, then the files generated in one function would get deleted by the next.
8e79c75
to
096ad6d
Compare
crates/codegen/runtime/npm/package/wasm/generated/interfaces/nomic-foundation-slang-parser.d.ts
Show resolved
Hide resolved
crates/codegen/runtime/npm/package/wasm/generated/interfaces/nomic-foundation-slang-cst.d.ts
Show resolved
Hide resolved
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.
Left a few questions.
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 think there is still one remaining issue, but otherwise, LGTM.
…#1169) When generating documentation for `TerminalKind` and `NonterminalKind`, generate the EBNF grammar for the current variant and include that in the final output. This affects the Wit output and Rust output (using templates `cst.wit.jinja2` and `(terminal|nonterminal)_kind.rs.jinja2`). * [x] Depends on #1157 * [x] Depends on NomicFoundation/jco#3 Closes #1165
This PR uses the
jco types
command to generate Typescript definitions for the wasm crates instead ofjco transpile
. The reason is thatjco transpile
generates ts definitions by decoding WASM component binaries, whereasjco types
parses .wit files directly and uses that information. This means that theResolve
instance created duringtypes
has access to the type documentation info, and the one created duringtranspile
does not.I've modified
infra check npm
with a new step which callsjco types
and handles the resulting .d.ts files. When callingjco transpile
we're now passing the option--no-typescript
to avoid generating conflicting typescript outputs.These changes depend on NomicFoundation/jco#1, which augments the
types
command to accept the same configuration file that we pass totranspile
. Without this, the codegen intypes
will not be able to generate Typescript enums for Rust enums, or any other customization that we want.