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 documentations to concern methods [ci skip] #35886

Merged
merged 2 commits into from Apr 17, 2019

Conversation

okuramasafumi
Copy link
Contributor

Summary

Add some documentations to concern methods (included and class_methods).
append_features is :nodoc: because users don't care about it.

@okuramasafumi
Copy link
Contributor Author

I modified documentations so that (I believe) they're more useful for end users.

@okuramasafumi
Copy link
Contributor Author

@kamipo Thank you for your comments. I force-pushed a commit following your advice.
I removed where it mentions Ruby's default included method.

@@ -137,6 +140,23 @@ def included(base = nil, &block)
end
end

# Define class methods from given block.
# You can define multiple +class_methods+ blocks.
Copy link
Member

Choose a reason for hiding this comment

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

hmm... actually multiple class_methods works, but seems it is not by design.
Is it worth to mention about multiple class_methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I found it interesting that we can have multipleclass_methods while we cannot have multiple included.
Should it raise an exception when we have multiple class_methods, for the sake of symmetry?

Copy link
Member

Choose a reason for hiding this comment

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

It seems worth discussing (I'd say less worth to disallow things aren't broken though).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It might be good to put deprecation warning first when we have multiple class_methods.
If so, it's not a good idea to document multiple class_methods. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

We don't always describe all behaviors in the API doc (e.g. #28490 (comment)).
Regardless of whether it is deprecated or not I don't think the multiple class_methods is valid use case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, I'll remove multiple case from an example.

@okuramasafumi
Copy link
Contributor Author

OK, I removed multiple class_methods and instead added the fact that we can define private class methods easily.

#
# private
#
# def bar; puts 'bar'; end
Copy link
Member

Choose a reason for hiding this comment

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

Can you follow the Coding Conventions?

Indent and no blank line after private/protected.

https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#write-your-code

# end
# end
#
# Buzz = Class.new.include(Example)
Copy link
Member

Choose a reason for hiding this comment

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

Buzz = Class.new.include(Example) is not usual to me.
Can you use actual class Buzz?

@kamipo kamipo merged commit 72842b3 into rails:master Apr 17, 2019
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.

None yet

2 participants