godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.75k stars 20.12k forks source link

BBCode is inconsistent when used in inspector tooltips with @export variables. #94336

Open wyattbiker opened 1 month ago

wyattbiker commented 1 month ago

Tested versions

v4.3.beta2.official [b75f0485b]

System information

Linux Kubuntu 23.04 KDE Plasma Version: 5.27.4 KDE Frameworks Version: 5.104.0 Qt Version: 5.15.8

Issue description

Adding tooltips to @export variables does not support many bbcodes.

image

Steps to reproduce

Create an empty 2D scene. E.g. Control Add an external script to it. E.g. control.gd Add the following to script and save:

extends Control

## [p]Hello[/p]Notice no paragraph.
## [bgcolor=RED]Should be background red.[/bgcolor][br][i][color=green]THIS IS ITALIC AND GREEN.[/color][/i]
## [br]Click for more info url works [url=https://yahoo.com]https://yahoo.com[/url]
## [p][right]This is a paragraph but did not break[/right]
## [br][font_size=30]Should be 10[/font] font
## [br]Strangely enough the [ br ] acts as [br] paragraph, although not documented.
@export var maximum_speed:int=100

Now hover over the exported variable maximum_speed, in the inspector. You will see that only some of the bbcodes work. For example[p], [bgcolor], [right]are ignored and shown as text. As a matter of fact I have discovered an undocumented [br]break in lieu of [p]paragraph code.

Minimal reproduction project (MRP)

Test project Archive.zip

dalexeev commented 1 month ago

See the documentation:

Godot's class reference supports BBCode-like tags. They add nice formatting to the text which could also be used in the documentation. See also class reference bbcode. Note that this is slightly different from the RichTextLabel BBCode.

In the future, we could unify the RichTextLabel BBCode / Editor Help tags parser, since there is code duplication.

Calinou commented 1 month ago

Note that it might not be worth supporting all BBCode tags in documentation, as they can encourage non-standard theming that can be difficult to read on some backgrounds ([color]).

Instead, the use of a standard syntax including admonitions should be encouraged as much as possible. This would also help third-party docs feel more like built-in documentation, leading to better integration of add-ons.

wyattbiker commented 1 month ago

I agree, some of the codes may not be suitable for tooltips. I did not realize there was an alternate document for describing these, as I was just using the RichTextLabel bbcode documentation. The paragraph mentioning alternate usages is not obvious in https://docs.godotengine.org/en/stable/tutorials/ui/bbcode_in_richtextlabel.html

Maybe a See Also blue box highlighting or enhancing that paragraph would suffice.

Something like

Note that the BBCode tags can also be used to some extent in tooltips for @export script variables as well as in the XML source of the class reference. For more information, see Class reference primer.