Actions
Misc #19304
openKernel vs Object documentation
Misc #19304:
Kernel vs Object documentation
Status:
Assigned
Assignee:
Description
The restating of the problems raised in #19300, from scratch.
I believe it is rather a topic of community significance and would be happy if it is possible to discuss on dev-meeting, even if the outcome would probably "let's change RDoc in this or that way".
So, the problem statement:
-
Kernel
module defines two "types" of methods: private ones, that pretend to be global (likeputs
), but actually available from inside every object; and public ones (like#class
or#frozen?
) that are present in every object includingKernel
. - Since the beginning of times, docs provided an illusion that the second type of the methods belongs to
Object
class, which is, in fact, devoid of its own definitions, just includesKernel
. This was handled by special RDoc hack (which, basically, forcefully reattached definition of public methods if they are defined inKernel
, toObject
) - The RDoc hack was working in C code only, so after introduction of
kernel.rb
the illusion started to crumble: methods like#tap
,#then
,#class
are now documented as belonging toKernel
(breaking the tradition of public methods being documented inObject
) - This is all inconsistent and confusing, and I believe, adds to friction both for newcomers and curious investigators of the language!
Additionally, I believe:
- That the distinction of "two kinds of methods" is useful (saying from a practical experience with explaining Ruby while mentoring, writing articles, and discussing with colleagues)
- But, considering everything, I agree with what @Eregon (Benoit Daloze) and @nobu (Nobuyoshi Nakada) say in #19300: pretending that methods belong not to the module they really belong to is not the optimal way to document things!
So, the options I see (save for "do nothing and let things sort themselves somehow"):
- Change Ruby's implementation so public methods would really belong to
Object
. Actually, I don't believe anybody would agree to experiment on this scale, so just listing it here for completeness. - Just remove the RDoc hack; all methods would belong to
Kernel
, and maybe some introductory free-form text will instruct that they are different. Pro: Easy to do. Contra: TheKernel
docs would be super-confusing. - Continue to maintain the hack in RDoc and extend it to
kernel.rb
(so methods like#clone
and#frozen?
would be still inObject
). Pro: Relatively easy to do, will maintain structure many people used to. Contra: This is still a lie, methods belong toKernel
, notObject
. - Adjust RDoc to a) be able to separately list public and private methods in two different lists, and add intro for
Kernel
explaining how to treat those. Pro: Probably the best correspondence to reality? Contra: Not sure how easy it is to change RDoc this way; and other renderers (like ruby-doc.com and rubyapi.org) would need to adjust themselves.
So far, (4) looks the most reasonable (if (1) is 100% impossible, that is!)
Actions