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

Dedup method comments #1103

Merged
merged 1 commit into from
Sep 2, 2022
Merged

Dedup method comments #1103

merged 1 commit into from
Sep 2, 2022

Conversation

soutaro
Copy link
Member

@soutaro soutaro commented Sep 2, 2022

Fixes #1054

@soutaro soutaro enabled auto-merge September 2, 2022 02:55
@soutaro soutaro merged commit 963de8c into master Sep 2, 2022
@soutaro soutaro deleted the dedup-comments branch September 2, 2022 02:59
@ioquatix
Copy link
Member

ioquatix commented Sep 2, 2022

Do you know why duplicates existed in the first place?

@soutaro
Copy link
Member Author

soutaro commented Sep 2, 2022

I don't think there was a good reason to have it duplicated. It should be just because of a confusion caused by the complicated structure and bad names... 😓

A def declaration with several overloads has duplicated documentations given to the def declaration.

# Doc is for def syntax
def foo: () -> String                  (Overload 1)
       | (Integer) -> Integer          (Overload 2)

# Another doc for another def syntax
def foo: (Integer, Integer) -> void    (Overload 3)
       | ...

And the defs attribute contains the overloads, 1, 2, and 3, not def syntaxes.

This caused the duplication.

@ioquatix
Copy link
Member

ioquatix commented Sep 2, 2022

Would it make sense to have a single source of truth for unique documentation?

In your example case, it seems reasonable that there are 2 distinct "documentation" instances.

@soutaro
Copy link
Member Author

soutaro commented Sep 2, 2022

Not very sure what do you mean with a single source of truth. The RBS::AST::***#comment would be the source of truth, and this #comments method is a utility to help collect every comments attached to a method.

In the example above, there will be two comments, for #foo method.

  • RBS::AST::Members::MethodDefinition object for the first def has the first doc
    • The second object has the second doc
    • This is the source of truth
  • The comments will be distributed to method overloads, so that we can provide hover feature to show the documents from the source code
    • Overload 1 and 2 have the first doc
    • Overload 3 has the second doc
  • The #comments method collects the docs through overloads
    • This is the reason of duplication: There are three overloads and we got three comments
    • Deduping the comments will result in two comment object: the first doc and second doc

@ioquatix
Copy link
Member

ioquatix commented Sep 3, 2022

I'll try it out and see how it works in practice. Thanks for your help.

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

Successfully merging this pull request may close these issues.

Duplicate comments?
2 participants