-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Improve GDScript documentation generation & behavior #72095
Conversation
21b1990
to
decf8cf
Compare
4fede92
to
a6d487d
Compare
6f7dd77
to
5fb295c
Compare
Also, for the folks following, I updated the original post with all the things happening in this PR :) Let me know if there are any other wants that I could include here! |
712be4c
to
fb759c2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The editor side of things and the overall approach make sense to me. Needs a review from @godotengine/gdscript still.
a0d4f43
to
7c4f88b
Compare
Removes documentation generation (docgen) from the GDScript compiler to its own file. Adds support for GDScript enums and signal parameters and quite a few other assorted fixes and improvements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed during a PR meeting of the GDScript team.
Great job ocean, you did a really good job. It was a long time coming.
@vnen said that he would review the PR more in depth, but is ok with it at glance.
// ResourceLoader is used in order to have a script-agnostic way to load scripts. | ||
// This forces GDScript to compile the code, which is unnecessary for docgen, but it's a good compromise right now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes me think that perhaps the ScriptServer should be aware of documentation and just as the script language to provide documentation data. This would allow not only GDScript and other languages to optimize the doc gen process.
Of course this is just something to discuss later, no need to worry about it for this PR. I agree that loading the resource is a good compromise for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thanks for working on this!
This is amazing! Thanks a lot! |
Thanks everyone for your time, comments and support 😄 ❤️ |
Not sure if this is relevant, but I'd like the LSP to be integrated with docgen so we can get consistent docgen behavior. |
Rework of GDScript classes' documentation generation (docgen).
Changes:
• Removes docgen code & datastructures from⚠️ ⚠️ ⚠️ Remove unnecessary class specifier path, e.g. ⚠️ ⚠️ ⚠️ this one might be slightly contentious ⚠️ ⚠️ ⚠️
gdscript_compiler.cpp
andgdscript.cpp
• Docgen uses analyzer datatypes instead of less expressive runtime datatypes
• Enums return/parameter types docgen'd properly instead of being
Variant
orint
. Fixes #71117• Makes hyperlinks to unopened classes generate their documentation on-demand rather than show blank screen.
Fixes #72406• Signals parameter types are docgen'd correctly instead of being
Variant
• Added same-line docstrings for variables/constants
• Show external class specifiers e.g.
TileSet.CellNeighbor
instead ofCellNeighbor
,OtherClass.Enum
orInnerClass.Enum
instead of justEnum
•
InnerClass.Enum
instead ofCurrentClass.InnerClass.Enum
orInner3.Enum
instead ofClass.Inner1.Inner2.Inner3.Enum
, when documented insideInner2
• Created a fairly comprehensive set of gdscript files with all/most combinations of types to make sure this works properly (linked below)
Minor changes:
• Removes unused
p_scroll
parameter inEditorHelp::go_to_class()
andp_vscr
inEditorHelp::_goto_desc()
• Removed unused
DocData::EnumDoc
• Normalize docstrings in
EditorHelp
source codeEnums and class specifiers everywhere!
Before (boooooo):
After (yaaaaaay):
Inline docstrings!
Possibly contentious class specifier prefix elimination!
(see below for gdscript class & enum types)
Notice how we are within
Doc1.IC
, and therefore in the highlighted areas only relevant class specifier prefixes are shown. We don't needDoc1.IC
, justIC
. We don't needDoc1.IC.IE
orIC.IE
, justIE
. We don't needDoc1.IC.IIC
orDoc1.IC.IIC.IIE
, justIIC
orIIC.IIE
.Test files!
gdscript_docgen.zip
These are the files I used to test. They are organized as follows:
Doc1
andDoc2
Doc1
andDoc2
have an inner classIC
, which has an inner inner classIIC
.E
,IE
, andIIE
.Doc1
and inner classes, have methods containing all combinations of accessing classes and enums I could think of, both as parameters and return types.As far as I can tell, every type name is as I thought it made the most sense (i.e. remove prefixes which are "obvious"), and click-linking works also.