Feature request: BBCode formatting in doc strings
GDScript uses BBCode for formatting code docs.
Currently, the docstrings are shown unparsed:
It would be nice to have them properly formatted. At least source code blocks and some basic formatting tags like [br], [b], etc
It would definitely be nice, but currently it's outside of our control with Zed, unfortunately. We don't have a way to hook into what we get from the language server, as far as I know. We can only hook Zed with the language server and the debugger adapter provided by the engine and receive stuff from the engine as is.
I just checked the extension API that now has the debugger adapter support but couldn't find something that would allow us to see incoming text and transform it. If someone sees something like this moving forward, please let me know!
BBCode is converted to markdown in the language server. It doesn't work properly for the the multi language code blocks at the moment though. But [b] should work just fine.
I see! Thanks for the explanation. It sounds like it's a matter of adding conversion of codeblocks to markdown code fences in the language server upstream then?
Yeah the whole BBCode -> Markdown thing has to be adjusted a bit. It's missing some stuff most notably code blocks.
@HolonProduction may I ask if you could point me to the folder/files that would need changes in Godot? This is probably something I could contribute on my days off within the next few weeks, if nobody is already working on this.
https://github.com/HolonProduction/godot/blob/53be3b78d1634406f1fb29e3802c608a5f5104a1/modules/gdscript/language_server/godot_lsp.h#L1941-L1991
I'm personally a bit hesitant about touching this, since I don't like the general search and replace approach. There are some edge cases that probably aren't possible to solve without using a real parser.
Implementing a quick fix for [codeblocks] shouldn't be that hard though. While you are at it, I'm pretty sure the [codeblock language="gdscript"] syntax doesn't work right now, either.
Best solution I can think of is supporting [codeblock language="gdscript"] and then replacing [language] with [codeblock language="language"] while inside of [codeblocks] before running the normal logic.
@HolonProduction Thank you very much! The current "brute force" approach may have little caveats, though an advantage is it's also very simple code.
You could also do minimal "parsing" just for the codeblock tag, still with simple string processing (find "[codeblock", then scan from there, reading any attributes until a closing "]").
Who's/who are the maintainers of this area? I'm generally fine with contributing whatever is wanted. A bbcode scanner-based parser is a little more code but it's nothing complicated. Before starting something like this I'd just like to get the desired solution validated by the person(s) who decide what goes in to be sure it can go in.
Not sure if we have a dedicated LSP maintainer, probably just falls under the GDScript team, you might wanna ask on Rocket chat about it.
Thing about a full parser is like that it might duplicate stuff from RichtTextLabel and LSP kinda has this problem of not getting updated correctly when other parts change. So maybe we should just stay with the minimal "brute force" way for now 🤔
Makes sense, I'll do that! Thank you.
Note for everyone: This issue should be fixed in a future Godot version, with this change: https://github.com/godotengine/godot/pull/108497
Implemented by godotengine/godot#113099 (superseding godotengine/godot#108497)!
Thank you! I'll keep this open for now for documentation purposes until the 4.6 stable release.