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 valid XML from doc comments #861

Merged
merged 1 commit into from
Aug 21, 2024

Conversation

andreymal
Copy link
Contributor

@andreymal andreymal commented Aug 16, 2024

Closes #837

Escapes everything (things like Gd<Node> in function parameters must also be escaped)

Removes the empty line before the XML declaration to make XML valid

if matches!(...) in xml_escape looks ugly but makes it ~20% faster no longer relevant, see the old commit if you're curious

@andreymal
Copy link
Contributor Author

andreymal commented Aug 16, 2024

(I have no idea how to run godot::tests::docs::correct)

@GodotRust
Copy link

API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-861

Copy link
Member

@Bromeon Bromeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot, very nice amendment!

godot::tests::docs::correct

Should be run as part of ./check.sh test, no?

godot-macros/src/docs.rs Outdated Show resolved Hide resolved
godot-macros/src/docs.rs Outdated Show resolved Hide resolved
@andreymal
Copy link
Contributor Author

Should be run as part of ./check.sh test, no?

No ¯\(°_o)/¯

@Bromeon
Copy link
Member

Bromeon commented Aug 17, 2024

Ah, it needs the register-docs feature.

@andreymal
Copy link
Contributor Author

xml_escape is now optimized for the case when most strings don't contain special characters.

Since this caused the list of special characters to be present three times, I decided to remove matches!(...) for the sake of simplicity. While it may still improve performance a bit, it's not that important now

@Bromeon
Copy link
Member

Bromeon commented Aug 18, 2024

Thanks! It looks like unit-tests in CI may not have the register-docs feature enabled, so I'm not sure if the things are actually tested? If not, that's something I should fix before merging...

@MrJoermungandr
Copy link

MrJoermungandr commented Aug 18, 2024

Yo I've found that currently the Variable Documentation isnt working so if i do

struct Test {
base: Base<Resource>,
/// # Awesome Doc
/// Immaculate Documentation
#[export]
var: Type
}

it doesnt show in the Inspector. Dont know if thats a seperate issue since its clearly experimaental :)

@andreymal
Copy link
Contributor Author

in the Inspector

@MrJoermungandr you need to #[export] variables to the inspector, see the book https://godot-rust.github.io/book/register/properties.html#exporting-variables

(and don't forget to enable the register-docs feature)

(and this is off-topic here btw)

@MrJoermungandr
Copy link

MrJoermungandr commented Aug 18, 2024

Sry i exported it ofc and also have the feature enabled ^^ i only meant that it says No Description Available mb.
When i extend it in GdScript it works fine.
I can open another Issue tho if thats not the scope of this pr just thought i'll report here first :)

EDIT: Actually masasive brainfart on my side since i didnt actually test with this pr only with the previous functionality im sorry for bothering will check again if this is merged ^^ 🥴

@andreymal
Copy link
Contributor Author

This pull request reveals another issue: if .godot/extension_list.cfg doesn't exist, the documentation shows Rust types instead of Godot types (which is quite expected, this is literally what's written in XML)

Doesn't seem to be related to this pull request, it just helped to reveal this issue

Copy link
Member

@Bromeon Bromeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

We can gladly add further improvements in other PRs, but this is already a nice improvement that deserves merging on its own 🙂

Edit: I'll need to make sure the CI actually runs the unit-test with the register-docs feature. Will do that today.

@Bromeon Bromeon added this pull request to the merge queue Aug 21, 2024
@Bromeon Bromeon removed this pull request from the merge queue due to a manual request Aug 21, 2024
@Bromeon Bromeon added c: register Register classes, functions and other symbols to GDScript feature Adds functionality to the library labels Aug 21, 2024
@Bromeon
Copy link
Member

Bromeon commented Aug 21, 2024

Tried to integrate register-docs into tests but couldn't get it to work in the short time I had. Will do another time...

Merged via the queue into godot-rust:master with commit 7634fe7 Aug 21, 2024
15 checks passed
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 this pull request may close these issues.

Invalid syntax in docs xml
4 participants