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

[Doc Gen] shows "_" properties #52870

Closed
nonunknown opened this issue Sep 20, 2021 · 4 comments
Closed

[Doc Gen] shows "_" properties #52870

nonunknown opened this issue Sep 20, 2021 · 4 comments

Comments

@nonunknown
Copy link
Contributor

Godot version

v4.0.dev.20210916.official [104a619]

System information

manjaro Gnome 21, AMD R7 200 series, Intel i3 3.0 GHZ,8GB RAM

Issue description

When you create a scrpit with methods and variables starting with "_" in the community this means "private" and shouldnt be shown to the end user documentation, which is not the current behaviour:

image

altought when you open your project, sometimes it doesnt show the "_" started vars and methods!

Steps to reproduce

use the following script as example:

extends RefCounted
class_name StateMachine

## This is a state machine implementation, very optimize w/ code organization on your side

var _states_enter:Array[StringName]
var _states_update:Array[StringName]
var _states_exit:Array[StringName]

var _current_state:int = 0
var _machine_owner:Node = null

## another var
var _hello:bool = false
## hey
func _test() -> void:
	
	pass

## Register all states that the machine contains
## for each state the user should create the following functions: _enter_name, _update_name, _exit_name
func register_states(target:Node, states:Dictionary,initial_state:int = 0) -> void:
	#Register the functions to be called in arrays of stringname (which is faster)
	for st in states:
		_states_enter.append(StringName("_enter_%s" % st))
		_states_update.append(StringName("_update_%s" % st))
		_states_exit.append(StringName("_exit_%s" % st))
		print("Registering State: ", st)
	
	_current_state = initial_state
	_machine_owner = target
	
	#Call the initial state
	target.call(_states_enter[_current_state])
	pass

## change the state to the target one
func change_state(to_state:int) -> void:
	#call the old state's exit
	_machine_owner.call(_states_exit[_current_state])
	#update the current state to the targeted one
	_current_state = to_state
	#call the new state's enter method
	_machine_owner.call(_states_enter[to_state])
	pass

## update the machine, must be called in _process or _physics_process
func update(delta:float) -> void:
	_machine_owner.call(_states_update[_current_state],delta)
	pass

## return the integer of current state according to states dictionary
func get_current_state() -> int: return _current_state

## return the bolean to check the current state
func current_state_is(state:int) -> bool: return state == _current_state

Minimal reproduction project

N/a

@akien-mga
Copy link
Member

Properties prefixed with _ are not private, it's just a convention that some users use. So the behavior of the documentation generator is correct, others might be using _ prefixed variables without meaning for them to be "fake" private, or they might want their "private" properties to be included in the documentation too for their own use.

@nonunknown
Copy link
Contributor Author

nonunknown commented Sep 20, 2021

yep you're right its just a convention, adopted by you guys too in the project source, if I'm correct!

So a tag should be made in case the user whants to expose then!

Show all "_" started members and funcs, place at somewhere in the script:

## @show_private

Ignore all "_" started member and funcs (default):

## @hide_private

expose a specific one (in case hide_private was declared) must be placed at the top of member/func declaration:

## @show this is a member
var _test:bool = false

Also I would like to know what @ThakeeNathees think :D

@Xrayez
Copy link
Contributor

Xrayez commented Sep 20, 2021

So a tag should be made in case the user wants to expose then!

Yes, see also godotengine/godot-proposals#641 and my own godotengine/godot-proposals#2285 to provide some context on what should considered to be "private" versus just "internal" (I really think this kind of differentiation should be core ClassDB feature).

@nonunknown nonunknown changed the title Document Generation shows "_"/private properties [Doc Gen] shows "_" properties Sep 21, 2021
@dalexeev
Copy link
Member

dalexeev commented Jul 5, 2023

@dalexeev dalexeev closed this as completed Jul 5, 2023
@dalexeev dalexeev added this to the 4.0 milestone Jul 5, 2023
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