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

Add default values to the editor help, docs, and generated RST #29380

Merged
merged 1 commit into from
Jun 29, 2019

Conversation

bojidar-bg
Copy link
Contributor

@bojidar-bg bojidar-bg commented Jun 1, 2019

Also, make spacing of "=" in the editor help a bit more consistent.

To do:

  • Add default property values to DocData.
  • Export default property values to .xml classes and then to RST.
  • Fix or silence these errors produced while getting the default values.
  • Add default values for abstract classes like BaseButton.
  • Add default values to the Properties listing, and not just description in the in-editor help (and maybe in the rst documentation).
  • Ensure there are no leftover crashes from the whole process.
  • Fix crash at exit from editor/doctool.
  • Update docs to remove default values from the descriptions and run doctool (already works, but I don't want to mess up the diff yet). [Done in doc: Add default values to all properties #30184]

Some screenshots:
Vector3 docs
Button docs
GridContainer docs

Closes #16086

@swarnimarun
Copy link
Contributor

This might be the most awesome feature in 3.2 that very few will realize was added. :D

@swarnimarun
Copy link
Contributor

Also can't we similarly add this to the Properties section it would be much quicker to be able to see all the default values together?
I mean the normal Properties section, not Theme Properties.

@bojidar-bg
Copy link
Contributor Author

@swarnimarun yeah, going to add it to the normal properties section. Honestly, I was thinking of the same, but wasn't really sure about it...

@akien-mga akien-mga added this to the 3.2 milestone Jun 2, 2019
@bojidar-bg bojidar-bg force-pushed the 16086-docs-default-value branch from 0bb9d05 to 4520894 Compare June 3, 2019 17:58
@bojidar-bg bojidar-bg marked this pull request as ready for review June 3, 2019 18:00
@bojidar-bg bojidar-bg requested review from BastiaanOlij, karroffel and a team as code owners June 3, 2019 18:00
@bojidar-bg
Copy link
Contributor Author

Marked as ready for review. While I haven't updated the documentation yet, I would like to have the other things checked first, so that no unnecessary merge conflicts occur.

@akien-mga akien-mga removed request for a team, BastiaanOlij and karroffel June 19, 2019 09:00
@akien-mga
Copy link
Member

Changes look great overall. I agree that running doctool can wait for this to be merged, and be done in a separate PR.

I'm not sure that the way default values are displayed is clear enough for readers. It kind of makes it look like all those have a fixed value instead of a default value. Is this the usual way API docs mention their default values?

@akien-mga
Copy link
Member

I tried the PR locally, I get a segfault running doctool:

Generating new docs...
WARNING: cleanup: ObjectDB Instances still exist!
   At: core/object.cpp:2111.
pure virtual method called
terminate called without an active exception
Aborted (core dumped)

It still works fine though.

@akien-mga
Copy link
Member

Update docs to remove default values from the descriptions and run doctool (already works, but I don't want to mess up the diff yet).

BTW, I'd suggest to make first one commit that adds the default values everywhere (so just running doctool), and later on another commit that removes all the now-unnecessary default values from descriptions. Would be more readable.

@bojidar-bg
Copy link
Contributor Author

I tried the PR locally, I get a segfault running doctool:

And I get segfaults when running the editor, even without this PR. I think it is related to how default values are cleaned up when they are of object type.

I'm not sure that the way default values are displayed is clear enough for readers. It kind of makes it look like all those have a fixed value instead of a default value. Is this the usual way API docs mention their default values?

Suggestions welcome. Maybe putting the default in parenthesis?

int separation (= 8)
# or, to not have a smiley
int separation (default: 8)

@Calinou
Copy link
Member

Calinou commented Jun 19, 2019

@bojidar-bg int separation (default: 8) sounds pretty clear and looks good to me.

@akien-mga
Copy link
Member

I tried the PR locally, I get a segfault running doctool:

And I get segfaults when running the editor, even without this PR. I think it is related to how default values are cleaned up when they are of object type.

I don't get a crash when running doctool without this PR though. Here's the gdb backtrace running doctool with this PR:

pure virtual method called
terminate called without an active exception

Thread 1 "godot-git" received signal SIGABRT, Aborted.
0x000000367ec3ca7a in raise () from /lib64/libc.so.6
(gdb) bt
#0  0x000000367ec3ca7a in raise () from /lib64/libc.so.6
#1  0x000000367ec25524 in abort () from /lib64/libc.so.6
#2  0x000000367fa8d9a3 in __gnu_cxx::__verbose_terminate_handler() [clone .cold.1] () from /lib64/libstdc++.so.6
#3  0x000000367fa938e6 in __cxxabiv1::__terminate(void (*)()) () from /lib64/libstdc++.so.6
#4  0x000000367fa93921 in std::terminate() () from /lib64/libstdc++.so.6
#5  0x000000367fa9463f in __cxa_pure_virtual () from /lib64/libstdc++.so.6
#6  0x0000000003685d29 in ObjectDB::remove_instance (p_object=0x590b5b0) at core/object.cpp:2056
#7  0x0000000003685ab4 in Object::~Object (this=0x590b5b0, __in_chrg=<optimized out>) at core/object.cpp:2014
#8  0x00000000036a54de in Reference::~Reference (this=0x590b5b0, __in_chrg=<optimized out>) at core/reference.cpp:113
#9  0x00000000036b6ee9 in Resource::~Resource (this=0x590b5b0, __in_chrg=<optimized out>) at core/resource.cpp:422
#10 0x0000000002fd6c86 in Curve2D::~Curve2D (this=0x590b5b0, __in_chrg=<optimized out>) at scene/resources/curve.h:150
#11 0x0000000001426ada in memdelete<Reference> (p_class=0x590b5b0) at ./core/os/memory.h:120
#12 0x0000000001425dfa in Ref<Reference>::unref (this=0x61e5098) at ./core/reference.h:282
#13 0x00000000036a4efc in RefPtr::unref (this=0x61e5098) at core/ref_ptr.cpp:82
#14 0x00000000036fb0ed in Variant::clear (this=0x61e5088) at core/variant.cpp:1110
#15 0x00000000013e94d2 in Variant::~Variant (this=0x61e5088, __in_chrg=<optimized out>) at ./core/variant.h:422
#16 0x0000000002f12428 in HashMap<StringName, Variant, HashMapHasherDefault, HashMapComparatorDefault<StringName>, (unsigned char)3, (unsigned char)8>::Pair::~Pair (this=0x61e5080, __in_chrg=<optimized out>)
    at ./core/hash_map.h:61
#17 0x0000000002f143f4 in HashMap<StringName, Variant, HashMapHasherDefault, HashMapComparatorDefault<StringName>, (unsigned char)3, (unsigned char)8>::Element::~Element (this=0x61e5070, 
    __in_chrg=<optimized out>) at ./core/hash_map.h:73
#18 0x0000000002f14423 in memdelete<HashMap<StringName, Variant, HashMapHasherDefault, HashMapComparatorDefault<StringName>, (unsigned char)3, (unsigned char)8>::Element> (p_class=0x61e5070)
    at ./core/os/memory.h:120
#19 0x0000000002f1214a in HashMap<StringName, Variant, HashMapHasherDefault, HashMapComparatorDefault<StringName>, (unsigned char)3, (unsigned char)8>::clear (this=0x6234908) at ./core/hash_map.h:541
#20 0x0000000002f0c996 in HashMap<StringName, Variant, HashMapHasherDefault, HashMapComparatorDefault<StringName>, (unsigned char)3, (unsigned char)8>::~HashMap (this=0x6234908, __in_chrg=<optimized out>)
    at ./core/hash_map.h:602
#21 0x000000000360142e in HashMap<StringName, HashMap<StringName, Variant, HashMapHasherDefault, HashMapComparatorDefault<StringName>, (unsigned char)3, (unsigned char)8>, HashMapHasherDefault, HashMapComparatorD--Type <RET> for more, q to quit, c to continue without paging--
efault<StringName>, (unsigned char)3, (unsigned char)8>::Pair::~Pair (this=0x6234900, __in_chrg=<optimized out>) at ./core/hash_map.h:61
#22 0x000000000360145a in HashMap<StringName, HashMap<StringName, Variant, HashMapHasherDefault, HashMapComparatorDefault<StringName>, (unsigned char)3, (unsigned char)8>, HashMapHasherDefault, HashMapComparatorDefault<StringName>, (unsigned char)3, (unsigned char)8>::Element::~Element (this=0x62348f0, __in_chrg=<optimized out>) at ./core/hash_map.h:73
#23 0x0000000003601489 in memdelete<HashMap<StringName, HashMap<StringName, Variant, HashMapHasherDefault, HashMapComparatorDefault<StringName>, (unsigned char)3, (unsigned char)8>, HashMapHasherDefault, HashMapComparatorDefault<StringName>, (unsigned char)3, (unsigned char)8>::Element> (p_class=0x62348f0) at ./core/os/memory.h:120
#24 0x00000000035fe860 in HashMap<StringName, HashMap<StringName, Variant, HashMapHasherDefault, HashMapComparatorDefault<StringName>, (unsigned char)3, (unsigned char)8>, HashMapHasherDefault, HashMapComparatorDefault<StringName>, (unsigned char)3, (unsigned char)8>::clear (this=0x5047be0 <ClassDB::default_values>) at ./core/hash_map.h:541
#25 0x00000000035fce05 in ClassDB::cleanup () at core/class_db.cpp:1464
#26 0x00000000036a737b in unregister_core_types () at core/register_core_types.cpp:281
#27 0x00000000014243bd in Main::cleanup () at main/main.cpp:2109
#28 0x00000000013e7815 in main (argc=3, argv=0x7fffffffd9e8) at platform/x11/godot_x11.cpp:56

I get a similar crash when closing the editor with this PR:

pure virtual method called
terminate called without an active exception

Thread 1 "godot-git" received signal SIGABRT, Aborted.
0x000000367ec3ca7a in raise () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install lib64drm_intel1-2.4.98-1.mga7.x86_64 lib64pciaccess0-0.14-2.mga7.x86_64
(gdb) bt
#0  0x000000367ec3ca7a in raise () from /lib64/libc.so.6
#1  0x000000367ec25524 in abort () from /lib64/libc.so.6
#2  0x000000367fa8d9a3 in __gnu_cxx::__verbose_terminate_handler() [clone .cold.1] () from /lib64/libstdc++.so.6
#3  0x000000367fa938e6 in __cxxabiv1::__terminate(void (*)()) () from /lib64/libstdc++.so.6
#4  0x000000367fa93921 in std::terminate() () from /lib64/libstdc++.so.6
#5  0x000000367fa9463f in __cxa_pure_virtual () from /lib64/libstdc++.so.6
#6  0x0000000003685d29 in ObjectDB::remove_instance (p_object=0x64c53c0) at core/object.cpp:2056
#7  0x0000000003685ab4 in Object::~Object (this=0x64c53c0, __in_chrg=<optimized out>) at core/object.cpp:2014
#8  0x00000000036a54de in Reference::~Reference (this=0x64c53c0, __in_chrg=<optimized out>) at core/reference.cpp:113
#9  0x00000000036b6ee9 in Resource::~Resource (this=0x64c53c0, __in_chrg=<optimized out>) at core/resource.cpp:422
#10 0x0000000002fd6c86 in Curve2D::~Curve2D (this=0x64c53c0, __in_chrg=<optimized out>) at scene/resources/curve.h:150
#11 0x0000000001426ada in memdelete<Reference> (p_class=0x64c53c0) at ./core/os/memory.h:120
#12 0x0000000001425dfa in Ref<Reference>::unref (this=0x6586bd8) at ./core/reference.h:282
#13 0x00000000036a4efc in RefPtr::unref (this=0x6586bd8) at core/ref_ptr.cpp:82
#14 0x00000000036fb0ed in Variant::clear (this=0x6586bc8) at core/variant.cpp:1110
#15 0x00000000013e94d2 in Variant::~Variant (this=0x6586bc8, __in_chrg=<optimized out>) at ./core/variant.h:422
#16 0x0000000002f12428 in HashMap<StringName, Variant, HashMapHasherDefault, HashMapComparatorDefault<StringName>, (unsigned char)3, (unsigned char)8>::Pair::~Pair (this=0x6586bc0, __in_chrg=<optimized out>)
    at ./core/hash_map.h:61
#17 0x0000000002f143f4 in HashMap<StringName, Variant, HashMapHasherDefault, HashMapComparatorDefault<StringName>, (unsigned char)3, (unsigned char)8>::Element::~Element (this=0x6586bb0, 
    __in_chrg=<optimized out>) at ./core/hash_map.h:73
#18 0x0000000002f14423 in memdelete<HashMap<StringName, Variant, HashMapHasherDefault, HashMapComparatorDefault<StringName>, (unsigned char)3, (unsigned char)8>::Element> (p_class=0x6586bb0)
    at ./core/os/memory.h:120
#19 0x0000000002f1214a in HashMap<StringName, Variant, HashMapHasherDefault, HashMapComparatorDefault<StringName>, (unsigned char)3, (unsigned char)8>::clear (this=0x6564bf8) at ./core/hash_map.h:541
#20 0x0000000002f0c996 in HashMap<StringName, Variant, HashMapHasherDefault, HashMapComparatorDefault<StringName>, (unsigned char)3, (unsigned char)8>::~HashMap (this=0x6564bf8, __in_chrg=<optimized out>)
    at ./core/hash_map.h:602
#21 0x000000000360142e in HashMap<StringName, HashMap<StringName, Variant, HashMapHasherDefault, HashMapComparatorDefault<StringName>, (unsigned char)3, (unsigned char)8>, HashMapHasherDefault, HashMapComparatorD--Type <RET> for more, q to quit, c to continue without paging--
efault<StringName>, (unsigned char)3, (unsigned char)8>::Pair::~Pair (this=0x6564bf0, __in_chrg=<optimized out>) at ./core/hash_map.h:61
#22 0x000000000360145a in HashMap<StringName, HashMap<StringName, Variant, HashMapHasherDefault, HashMapComparatorDefault<StringName>, (unsigned char)3, (unsigned char)8>, HashMapHasherDefault, HashMapComparatorDefault<StringName>, (unsigned char)3, (unsigned char)8>::Element::~Element (this=0x6564be0, __in_chrg=<optimized out>) at ./core/hash_map.h:73
#23 0x0000000003601489 in memdelete<HashMap<StringName, HashMap<StringName, Variant, HashMapHasherDefault, HashMapComparatorDefault<StringName>, (unsigned char)3, (unsigned char)8>, HashMapHasherDefault, HashMapComparatorDefault<StringName>, (unsigned char)3, (unsigned char)8>::Element> (p_class=0x6564be0) at ./core/os/memory.h:120
#24 0x00000000035fe860 in HashMap<StringName, HashMap<StringName, Variant, HashMapHasherDefault, HashMapComparatorDefault<StringName>, (unsigned char)3, (unsigned char)8>, HashMapHasherDefault, HashMapComparatorDefault<StringName>, (unsigned char)3, (unsigned char)8>::clear (this=0x5047be0 <ClassDB::default_values>) at ./core/hash_map.h:541
#25 0x00000000035fce05 in ClassDB::cleanup () at core/class_db.cpp:1464
#26 0x00000000036a737b in unregister_core_types () at core/register_core_types.cpp:281
#27 0x00000000014243bd in Main::cleanup () at main/main.cpp:2109
#28 0x00000000013e7815 in main (argc=4, argv=0x7fffffffd9c8) at platform/x11/godot_x11.cpp:56

Seems to be the same backtrace.

Also, make spacing of "=" in the editor help a bit more consistent.
Closes godotengine#16086
@bojidar-bg bojidar-bg force-pushed the 16086-docs-default-value branch from 4520894 to 0c4c36d Compare June 27, 2019 16:29
@bojidar-bg
Copy link
Contributor Author

bojidar-bg commented Jun 27, 2019

After trying multiple way (x [= 0.0], x = 0.0, and x (default: Color(0, 0, 0, 1))) to represent default values, I finally chose this one:
image
image

Also, added ADD_PROPERTY_DEFAULT and ClassDB:set_property_default_value(cl, nm, dv), and reverted the removal of errors from various getters.

Edit: Also, fixed crash at exit, 🎉.

@akien-mga akien-mga merged commit 52355c6 into godotengine:master Jun 29, 2019
@akien-mga
Copy link
Member

Thanks a ton! 🎉

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

Successfully merging this pull request may close these issues.

Show default value for properties on documentation
7 participants