ImGuiNET / ImGui.NET

An ImGui wrapper for .NET.
MIT License
1.9k stars 304 forks source link

XML documentation? #119

Open pixtur opened 5 years ago

pixtur commented 5 years ago

My biggest hurdle of using imgui is the lack of built in documentation. I know that the end of line comments in imgui.h are all over the place and probably not always useful without a context, but it would be extremely helpful to convert a line like this...

IMGUI_API void          Dummy(const ImVec2& size);                                      // add a dummy item of given size. unlike InvisibleButton(), Dummy() won't take the mouse click or be navigable into.

into ...

///<summary>
/// add a dummy item of given size. unlike InvisibleButton(), Dummy() won't take the mouse click or be navigable into.
///</summary>
public static void Dummy(Vector2 size);

I would be very happy to contribute manual formatting of the original header file to help with this.

mellinoe commented 5 years ago

I would like to have this, but it's not feasible to manually add XML comments for everything. The vast majority of the code here is generated from pre-parsed JSON definitions (from https://github.com/cimgui/cimgui), so anytime they were regenerated, the comments would be lost. The best solution would be to have the Lua script pull out the comments and make them available in the JSON file. Then, I could just put them into an XML comment during the generation phase.

pixtur commented 5 years ago

Thank your for this answer. I'm not familiar with lua, but it appears that the script is already extracting the comments for the most part. Sadly only to strip them. Maybe I can add a feature request to cimgui.

I have been wondering if I should ask ocornut to change the documentation style of the header file into something that is machine readable. But seeing the lua script I realized that this would require a huge amount of work and probably would break many scripts in the dear imgui eco system.

mellinoe commented 5 years ago

I have been wondering if I should ask ocornut to change the documentation style of the header file into something that is machine readable. But seeing the lua script I realized that this would require a huge amount of work and probably would break many scripts in the dear imgui eco system.

IMO, the current style of (most) comments in imgui.h should be easily parseable. Indeed, as you noticed, the current parser already strips them out, so it's just a matter of preserving them and associating them with the appropriate function/struct. There's obviously stuff in there that will be harder to parse out (like descriptive block comments for sections), but the majority of functions have a clean, short comment at the end of their declaring line which by itself is a great improvement over what ImGui.NET has currently (nothing). Eventually parsing things like this would also be great, but are harder.

sonoro1234 commented 5 years ago

@mellinoe @pixtur @ocornut Just pushed this https://github.com/cimgui/cimgui/tree/keep_text as an initial phase waiting for your comments

My comments

mellinoe commented 5 years ago

@sonoro1234 That is pretty cool! I'll be taking a closer look sometime soon.