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

Hide private enums from documentation #84396

Merged
merged 1 commit into from
Feb 9, 2024

Conversation

quirkylemon
Copy link
Contributor

@quirkylemon quirkylemon commented Nov 3, 2023

This loops through all the enums and checks if it has a description (doc comment) or if it is public. it also renames the variable e to a more descriptive name
fixes #84119

@YuriSizov YuriSizov added this to the 4.3 milestone Nov 3, 2023
@YuriSizov YuriSizov changed the title hide private enums Hide private enums from documentation Nov 3, 2023
@quirkylemon
Copy link
Contributor Author

I think it is working properly

@quirkylemon quirkylemon marked this pull request as ready for review November 4, 2023 19:33
Copy link

@daveTheOldCoder daveTheOldCoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this PR and it worked correctly.

@Mickeon Mickeon requested a review from YuriSizov January 28, 2024 14:45
Copy link
Contributor

@Mickeon Mickeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested myself and works as intended.

@akien-mga akien-mga requested a review from dalexeev January 29, 2024 11:56
Comment on lines -1417 to +1435
if (cd.enums.has(e)) {
if (cd.enums[e].is_deprecated) {
DEPRECATED_DOC_TAG;
}

if (cd.enums[e].is_experimental) {
EXPERIMENTAL_DOC_TAG;
}
if (cd.enums[key].is_deprecated) {
DEPRECATED_DOC_TAG;
}
if (cd.enums[key].is_experimental) {
EXPERIMENTAL_DOC_TAG;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand, it is not guaranteed that cd.enums has key. Above:

if (cd.enums.has(key)) {
    if (cd.enums[key].description.strip_edges().is_empty() && E.key.begins_with("_")) {
        continue;
    }
}

Copy link
Contributor Author

@quirkylemon quirkylemon Jan 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So should we still be checking if cd.enums.has(key) or should we skip any enum that doesn't have a key?
Edit: if I understand it correctly cd.enums will always have key

editor/editor_help.cpp Outdated Show resolved Hide resolved
@akien-mga akien-mga requested review from AThousandShips and removed request for YuriSizov February 7, 2024 09:08
key = key.get_slice(".", 1);
}
if (cd.enums.has(key)) {
if (cd.enums[key].description.strip_edges().is_empty() && E.key.begins_with("_")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Above the enums are filtered on script docs, but not here, is that an oversight?

Suggested change
if (cd.enums[key].description.strip_edges().is_empty() && E.key.begins_with("_")) {
if (cd.is_script_doc && cd.enums[key].description.strip_edges().is_empty() && E.key.begins_with("_")) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct me if I'm wrong but we shouldn't have to check cd.is_script_doc every time because it doesn't change per enum.
the reason we are checking if the description is empty or if the name starts with "_" is it is possible for enums that don't need documentation generated to be in the for loop.

Copy link
Member

@AThousandShips AThousandShips Feb 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then there should be some other flag to control this as the filtering is on script docs only

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I didn't realize we only filter on script docs.

Comment on lines 1382 to 1385
bool has_enums = false;
if (enums.size()) {
for (KeyValue<String, DocData::EnumDoc> &E : cd.enums) {
if (cd.is_script_doc && cd.is_script_doc && E.key.begins_with("_") && E.value.description.strip_edges().is_empty()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool has_enums = false;
if (enums.size()) {
for (KeyValue<String, DocData::EnumDoc> &E : cd.enums) {
if (cd.is_script_doc && cd.is_script_doc && E.key.begins_with("_") && E.value.description.strip_edges().is_empty()) {
bool has_enums = enums.size() && !cd.is_script_doc;
if (enums.size() && !has_enums) {
for (KeyValue<String, DocData::EnumDoc> &E : cd.enums) {
if (E.key.begins_with("_") && E.value.description.strip_edges().is_empty()) {

No need to check these every time, the loop accepts enums if they're non-script doc ones, so we can skip this part

Might be a more elegant way to do this just a suggestion, but the loop is unnecessary if it's not a script doc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah you're right.

Copy link
Member

@AThousandShips AThousandShips left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, would need to verify the comment about the enum key though, I'd suggest keeping it as it was to avoid any weirdness

@quirkylemon
Copy link
Contributor Author

Should I go ahead and combine the commits?
Also what does "LGTM" mean?

@AThousandShips
Copy link
Member

Looks Good To Me :)

Yes please squash

@quirkylemon
Copy link
Contributor Author

whenever I do git rebase it says there are 1382 commits to push. this has happened before and it didn't mess anything up but it did send a message in every pr that was in it. Is there any way to fix it?

@AThousandShips
Copy link
Member

It's just because you're updating your branch, the others should be just the normal ones, just that the branch doesn't contain them upstream

@quirkylemon
Copy link
Contributor Author

Squashed!!
and sorry about all the issues.

@AThousandShips
Copy link
Member

No problem at all! It's a learning experience :)

@akien-mga
Copy link
Member

Apologies for yet another nitpick, but could you amend the commit message to be a bit more explicit (and ideally start with a capital letter like other commits)? The title of this PR would be a good option, for a changelog reader I think the "from documentation" part is important to get the context.

I can do it myself too if needed.

@quirkylemon
Copy link
Contributor Author

Done

@akien-mga akien-mga merged commit b1d135c into godotengine:master Feb 9, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@quirkylemon quirkylemon deleted the hide-private-enums branch February 10, 2024 23:45
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.

GdScript documentation comments - enums always appear in the help window
7 participants