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

class_name doc comments before class are overridden by doc comments after it #100703

Closed
idbrii opened this issue Dec 21, 2024 · 2 comments
Closed

Comments

@idbrii
Copy link
Contributor

idbrii commented Dec 21, 2024

Tested versions

Reproducible in v4.3.stable.official [77dcf97]

Class doc comments were added in d1231be, but I haven't checked if it occurred in that build.

System information

Godot v4.3.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2060 (NVIDIA; 32.0.15.6590) - Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz (12 Threads)

Issue description

If you put it before class_name but have other ## comments followed by a blank line, they override the class doc comment.

It seems like the first ## in a file should be the doc comment and other should either be appended to it or ignored. Using the last one seems less likely to be correct.

Workaround

Make sure any following doc strings are attached to another line (no blank whitespace):

## Force the global rotation to stay at 0 (never rotate).
class_name NilRotation
extends Node2D


## Run every frame.
func _process(_dt):
    global_rotation = 0

Steps to reproduce

Put doc comment before (or after!) class_name but have other ## comments, they override the doc comment:

## Force the global rotation to stay at 0 (never rotate).
class_name NilRotation
extends Node2D


## Run every frame. (Oops, this becomes the class doc string.)

func _process(_dt):
    global_rotation = 0

completely wrong comment

Or write a doc comment that contains a blank line for space:

class_name NilRotation
extends Node2D
## Force the global rotation to stay at 0 (never rotate).

## Sometimes you don't want rotation to change.


func _process(_dt):
    global_rotation = 0

missing the first line

You could argue these are both incorrect ways of writing class doc comments. If the implementation is simpler to assign the last doc comment for the class, then that's fine. But it's surprising as a user. Especially since doc comments usually precede what they annotate.

Minimal reproduction project (MRP)

trivially reproducible in new project.

@miv391
Copy link
Contributor

miv391 commented Dec 21, 2024

I tested this with v4.4.dev7.mono.official [46c8f8c5c] but I cannot reproduce the problem with either of the provided ways. The first ## comment is always displayed in the tooltip or on the help page.

@dalexeev
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants