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

Generate documentation from doc comments #178

Closed
bend-n opened this issue Mar 13, 2023 · 9 comments · Fixed by #748
Closed

Generate documentation from doc comments #178

bend-n opened this issue Mar 13, 2023 · 9 comments · Fixed by #748
Labels
c: register Register classes, functions and other symbols to GDScript feature Adds functionality to the library

Comments

@bend-n
Copy link
Contributor

bend-n commented Mar 13, 2023

gdscript now has doccomments, so it would be neat, if, say

/// oh my god this is a [b]awesome[/b] function!
/// see also [member cool] and [constant E]
fn on_selected(index: i32) { }

would then generate documentation that you can view in the editor:

image

or you could even take it a step further, and convert markdown into bbcode so that it meshes better with the rust system.

@Bromeon Bromeon added feature Adds functionality to the library c: register Register classes, functions and other symbols to GDScript labels Mar 13, 2023
@Bromeon
Copy link
Member

Bromeon commented Mar 13, 2023

or you could even take it a step further, and convert markdown into bbcode so that it meshes better with the rust system.

This would be the way to go. We could start simple, even supporting formats like code, bold or italics would already help a lot.

If I remember correctly, /// text doc-comments should be visible as #[doc="text"] attributes, so they could be picked up by #[godot_api].

@bend-n
Copy link
Contributor Author

bend-n commented Mar 13, 2023

Yeah converting basic markdown isnt that hard, it just takes a couple regexes.
i just noticed that my code there doesnt use [codeblock] :v
actually i think [codeblock] is a bbcode extension, so i cant be blamed

The annotations and such would be slightly more difficult, iirc rust doc uses [Struct] and [Struct::property] which would need to be translated to [Struct] and [method Struct.property] || [method property].

@Bromeon
Copy link
Member

Bromeon commented Mar 13, 2023

Oh nice!

One thing to keep in mind is that proc-macros are a heavy burden on compile time, and regex replacement can be relatively expensive, especially if it's done "poorly" (i.e. each regex match replaces the entire doc-string, causing new allocations and copying). Likely not an issue for small games, this could affect someone with a larger number of documented classes/methods/properties. Would need to be measured though.

@Dheatly23
Copy link
Contributor

Just in case if things slow down, at least it should be (default) disabled in debug build. My reasoning is that docs isn't very useful in prototyping stage, and if one wants to release their addons/games it's nice to have docs for end user.

@Bromeon
Copy link
Member

Bromeon commented Mar 13, 2023

We do that in gdnative for async and serde, but I'm not sure if doc-generation is "advanced" or "expensive" enough to warrant extra opt-in from the user. Ideally we get a performant implementation, so this isn't an issue in the first place.

@lilizoey
Copy link
Member

we could maybe use https://crates.io/crates/rustdoc-json for help with parsing the docs similar to rustdoc, however it does rely on the currently unstable rustdoc JSON backend.

@lilizoey
Copy link
Member

there isn't a way to do this yet in gdextension, there is a draft PR for it though godotengine/godot#75415

@lilizoey lilizoey added the status: upstream Depending on upstream fix (typically Godot) label Jun 27, 2023
@StatisMike
Copy link
Contributor

Passing new PR in this topi, as it seems to be accepted and basically stopped only from 4.2 only because it was in feature-freeze. Most probably it will come in 4.3 release, so we could begin to prepare for it.

godotengine/godot#83747

@lokimckay
Copy link
Contributor

lokimckay commented Jun 6, 2024

The PR StatisMike mentioned is merged, so this issue should be unblocked now

@Bromeon Bromeon removed the status: upstream Depending on upstream fix (typically Godot) label Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: register Register classes, functions and other symbols to GDScript feature Adds functionality to the library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants