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

rustdoc typegen #217

Open
wants to merge 62 commits into
base: master
Choose a base branch
from
Open

rustdoc typegen #217

wants to merge 62 commits into from

Conversation

StuartHarris
Copy link
Member

@StuartHarris StuartHarris commented Mar 9, 2024

STACKED on top of #330

This is an experiment to see what it's like to use rustdoc's JSON output to generate foreign types (in TS, Swift and Kotlin) for crux shared libs.

The JSON has all the information we need, so potentially we can use it to list all the types that implement crux_core::App, find their associated types and follow them to their leaves, even crossing crate boundaries (e.g. to crux_http). After we have gathered the relevant type information, we'd need to generate the foreign types, including any serialisation / deserialisation code).

  • add a codegen subcommand to crux_cli
  • invoke cargo doc and generate JSON output
  • deserialise the output into rustdoc-types
  • gather the relevant type information
  • generate foreign types (or rather, for now, hook into the same serde_generate backend)
  • generate serialisation and deserialisation code (also via serde_generate)

The simple_counter and counter examples in this PR have had their shared_types lib removed. To test them, use the crux_cli binary from this PR to generate the foreign types, e.g.:

cd examples/counter
../../target/debug/crux codegen --lib shared

@StuartHarris StuartHarris force-pushed the rustdoc-typegen branch 2 times, most recently from ed81996 to 13418d4 Compare March 10, 2024 09:18
@StuartHarris StuartHarris force-pushed the rustdoc-typegen branch 2 times, most recently from 6d9d71d to 952a1fe Compare May 29, 2024 13:10
@StuartHarris StuartHarris force-pushed the rustdoc-typegen branch 2 times, most recently from 0d0184d to 875dd59 Compare October 18, 2024 10:55
@StuartHarris StuartHarris force-pushed the rustdoc-typegen branch 4 times, most recently from 4f104e2 to bbfb454 Compare October 28, 2024 16:01
@StuartHarris StuartHarris force-pushed the rustdoc-typegen branch 10 times, most recently from 74b80d9 to c1e63b1 Compare November 25, 2024 16:51
@StuartHarris StuartHarris force-pushed the rustdoc-typegen branch 5 times, most recently from 45251ff to 81d1438 Compare December 5, 2024 14:47
@StuartHarris StuartHarris force-pushed the rustdoc-typegen branch 2 times, most recently from 7ee1e77 to fbe6b6b Compare December 7, 2024 10:13
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.

1 participant