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

Singleton class syntax support #8

Merged
merged 1 commit into from
Nov 21, 2020

Conversation

KaanOzkan
Copy link
Contributor

Having yard documentation combined with a sig inside the singleton class syntax, class << self, was giving the following warning:

[warn]: in YARD::Handlers::Ruby::DSLHandler: Undocumentable method, missing name

This PR aims to support singleton class syntax by handling the class definition of the singleton similar to before. In the previous implementation singleton class's contents were skipped as it's not of type list. Here in the #process method we explicitly call the existing handler logic if we encounter a singleton class.

Most of the diff is due to moving the handler logic into a separate function.

I tested more extensively locally but in terms of the PR I only unskipped the existing test. If wanted I can add more complex cases.

@codecov
Copy link

codecov bot commented Nov 20, 2020

Codecov Report

Merging #8 (08016c0) into master (f66bb87) will increase coverage by 0.87%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #8      +/-   ##
==========================================
+ Coverage   92.34%   93.21%   +0.87%     
==========================================
  Files           2        2              
  Lines         222      221       -1     
==========================================
+ Hits          205      206       +1     
+ Misses         17       15       -2     
Impacted Files Coverage Δ
spec/yard_sorbet/sig_handler_spec.rb 100.00% <ø> (+1.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f66bb87...08016c0. Read the comment docs.

%i[def defs command].include?(next_statement&.type) && !next_statement.docstring
end

private def process_method_definition(method_node, sig_node)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also did a quick refactoring of the naming here to better represent the variable.

next_statement => method_node
child => sig_node

Copy link
Owner

Choose a reason for hiding this comment

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

😗👌

@dduugg
Copy link
Owner

dduugg commented Nov 21, 2020

Nice refactoring work. I gave it a scan, but I'm mostly trusting the tests. Thanks!

@dduugg dduugg merged commit 60bda6a into dduugg:master Nov 21, 2020
@KaanOzkan KaanOzkan deleted the ko/singleton-class-support branch November 23, 2020 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants