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

Allow API to reside at submodule of crate #642

Merged
merged 1 commit into from
Jan 6, 2024

Conversation

jayvdb
Copy link
Contributor

@jayvdb jayvdb commented Dec 8, 2023

Split off from #638

Potentially crate_name args should be renamed.

@jayvdb jayvdb force-pushed the allow-api-not-at-crate-root branch 5 times, most recently from 222df41 to 517a062 Compare December 8, 2023 02:06
@jayvdb jayvdb marked this pull request as ready for review December 8, 2023 02:19
@ahl
Copy link
Collaborator

ahl commented Dec 15, 2023

Is this fixing a bug or is this adding some new functionality? I'm not sure I understand the utility.

@jayvdb
Copy link
Contributor Author

jayvdb commented Dec 15, 2023

This is new functionality, needed in order to have the generated cli & httpmock be a module that resides beside the generated client.

Currently the generator uses format_ident!(..) which only supports foo - this PR allows it to support foo::bar.

It is needed for #638 , where the types+client, mocks and cli are three separate generated modules, and lib.rs is a manually authored file that combines those generated files and potentially adds other human authored functionality. The top level lib.rs does not contain the types+client. Therefore the mocks and cli need to be told where to find the types+client within the crate.

@franklin-ai is using this approach to be able to greater control over our crate lib.rs, re-exporting at the top level only a subset of the generated mods, and including lots of other human written code, such as impls on the generated types.

@jayvdb jayvdb force-pushed the allow-api-not-at-crate-root branch from be990a6 to b809a36 Compare January 6, 2024 09:24
@jayvdb
Copy link
Contributor Author

jayvdb commented Jan 6, 2024

ping @ahl . there are a bunch of other improvements which depend on this, some with a PR, others waiting on it getting merged.

@ahl
Copy link
Collaborator

ahl commented Jan 6, 2024

good enough; thanks

@ahl ahl merged commit 359f4f5 into oxidecomputer:main Jan 6, 2024
5 checks passed
@jayvdb jayvdb deleted the allow-api-not-at-crate-root branch January 6, 2024 19:26
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.

2 participants