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

Xml documentation comments imported into View Variables #5430

Open
wants to merge 33 commits into
base: master
Choose a base branch
from

Conversation

Mervill
Copy link
Member

@Mervill Mervill commented Sep 8, 2024

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

  • fix xml tags inside the <summary> block breaking the doc string.
    • Most of the tags are now good enough, I would like to try implementing <inheritdoc/> but it might be in a follow-up PR.
  • actually add <GenerateDocumentationFile> to the csproj files.
    • I spent some time in the MSBuild mines and I found a way to get the xml doc to write to the Resources folder cleanly. Right now it's only enabled for the Robust DLLS. If you want to test it locally you can add <ViewVariables>true</ViewVariables> to the Content DLLS. You may need to an an empty Resources\ViewVariables\ folder for the build to work properly.
  • post-compile script to move the generated xml files into the Resources folder
    • See above.
  • post-compile process to trim down the size of the xml files (discard all method definitions)
    • XmlDocTool implemented and working 👍
  • Add support for <viewvariables> block inside the xml comments that can add docs tailor-made for vv

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

@EmoGarbage404
Copy link
Member

images

@Mervill
Copy link
Member Author

Mervill commented Sep 10, 2024

vv-list

@mirrorcult
Copy link
Contributor

insanely zased

@mirrorcult
Copy link
Contributor

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

@Mervill
Copy link
Member Author

Mervill commented Sep 10, 2024

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
Copy link
Member Author

Mervill commented Sep 10, 2024

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

@Mervill
Copy link
Member Author

Mervill commented Sep 14, 2024

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
Copy link
Member Author

Mervill commented Sep 14, 2024

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.

@Mervill Mervill marked this pull request as ready for review September 14, 2024 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants