space-wizards / RobustToolbox

Robust multiplayer game engine, used by Space Station 14
https://spacestation14.io
Other
551 stars 410 forks source link

Xml documentation comments imported into View Variables #5430

Open Mervill opened 2 months ago

Mervill commented 2 months ago

2024-09-06 22_10_55-Space Station 14

Overview

Adds code that can read the xml files generated by C# documentation comments and display those comments (currently the <summary> block) below types and variables in View Variables windows.

This PR doesn't (yet) actually toggle the xml doc file generation. You should add <GenerateDocumentationFile>True</GenerateDocumentationFile> to the csproj of the project you want to generate docs for then copy the resulting xml file into Resources/ViewVariables. You can use this to test this PR with the xml docs from content as well.

I will do a content PR when this gets merged but to test you need to add:

    <ViewVariables>true</ViewVariables>
    <VVRobustProjectDir>RobustToolbox</VVRobustProjectDir>

to the Content csproj files to get them generating the doc files correctly.

The xml docs are a little big, and they contain a bunch of info we're never going to use like function documentation. It wouldn't be to hard to have a script that discards unneeded entries to optimize the size of the resulting files.

All the individual doc strings are loaded from the client resources folder, we don't send the doc strings over the network.

Since this info comes from the code (just like the type and variable names) we can't really expect to localize this text. That may be a deal-breaker.

TODO

[ ] cleaner code [ ] (?) CVar config? [ ] (?) Improve the UI slightly to better accommodate the new doc strings

EmoGarbage404 commented 2 months ago

images

Mervill commented 2 months ago

vv-list

mirrorcult commented 2 months ago

insanely zased

mirrorcult commented 2 months ago

xmldoc should probably be gitignored since it'll be regenerated anyway

Mervill commented 2 months ago

xmldoc should probably be gitignored since it'll be regenerated anyway

Yes I was hoping someone would weigh in on this. If we want to do this we need a way to keep Resources\ViewVariables from being deleted since the build script can't (yet?) create the folder if it does not exist.

Mervill commented 2 months ago

Actually scratch that last, I can make msbuild create the folder apparently

Mervill commented 2 months ago

There's now an command line program called XmlDocTool that strips function information out of the docs since we wont ever use that data.

The number of excluded entries is pretty dramatic:

XmlDocTool - Robust.Shared: Total Nodes: 4864, Copied Nodes: 2157, Delta: -2707
XmlDocTool - Robust.Client: Total Nodes: 1583, Copied Nodes: 918, Delta: -665
XmlDocTool - Robust.Server: Total Nodes: 318, Copied Nodes: 122, Delta: -196
XmlDocTool - Content.Shared: Total Nodes: 14220, Copied Nodes: 5285, Delta: -8935
XmlDocTool - Content.Client: Total Nodes: 1771, Copied Nodes: 639, Delta: -1132
XmlDocTool - Content.Server: Total Nodes: 12097, Copied Nodes: 3475, Delta: -8622
Mervill commented 2 months ago

Ok there are some minor pain points remaining (gui is a bit scuffed when the comments are big and long), but I think I'm ready for this to exit draft.