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

Feature request: More accurate types in generated rune API documentation #757

Closed
VorpalBlade opened this issue Jul 21, 2024 · 4 comments · Fixed by #764
Closed

Feature request: More accurate types in generated rune API documentation #757

VorpalBlade opened this issue Jul 21, 2024 · 4 comments · Fixed by #764
Labels
enhancement New feature or request

Comments

@VorpalBlade
Copy link
Contributor

Currently when a generic type (e.g. Option<MyCustomType>) is part of a function signature in an external function. the rune docs only show the outermost type (e.g. Option). It would be very useful to be able to see the full type.

I'm not sure how hard this would be to add, I would be interested in looking into this if this is a "relatively easy" thing.

@udoprog udoprog added the enhancement New feature or request label Jul 21, 2024
@udoprog
Copy link
Collaborator

udoprog commented Jul 21, 2024

Might be relatively straight forward albeit a bit tedious. You'd have to add the generic wherever they are referenced like here for the return type:

pub(crate) return_type: Option<Hash>,

And populate them from the context.

Finally you'd have to pass them into the link function here and modify it to take and recursively build links for generic parameters.

I'm thinking it might be appropriate to define a higher level type which captures both the base type and its generic parameters instead of just exposing a bare hash like we do now. Something like this:

#[cfg(feature = "doc")]
struct FullType {
    base: Option<Hash>,
    generics: Box<[Option<Hash>]>,
}

And then pass that into the link function, replacing any unknown Hash:es with ?.

@udoprog
Copy link
Collaborator

udoprog commented Jul 21, 2024

After landing #759, what we need to do next is to provide the necessary metadata through the MaybeTypeOf trait and pass it along so it can be used by the new context structures.

This also affects Any macro expansion.

@VorpalBlade
Copy link
Contributor Author

That was amazingly quick! Didn't even have time to start looking into doing it myself.

@udoprog
Copy link
Collaborator

udoprog commented Jul 22, 2024

Cheers. Yeah, I think with #765 it's pretty much as good as it can be. Thanks for pointing this out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants