[ruby-core:95958] [Ruby master Bug#16373] RDoc for some of the Kernel methods cannot be found in Kernel module
From:
zverok.offline@...
Date:
2019-11-26 13:05:07 UTC
List:
ruby-core #95958
Issue #16373 has been updated by zverok (Victor Shepelev).
I believe that there is some complicated discrepancy between where the method "defined" physically and where it "belongs" logically (though, it is not completely clear to me why some of the methods defined where they are).
If we take two examples: `#then` and `#puts`:
1. Both are defined in `Kernel`
2. `#then` makes more sense as _method every object have_, so you can `any_object.then { ... }`; it doesn't make much sense (even if possible) to do just `then { ... }` (UPD: ugh, it isn't even possible, parser thinks it is `then`-as-keyword... Well, OK, `tap { ... }` is possible, but almost meaningless)
3. `#puts` makes more sense as _method available everywhere without explicit receiver_; in fact `1.puts 'foo'` is NOT possible (`puts` is private)
I believe that if both would be documented as `Kernel` methods, it would be highly misleading.
So, in fact, I believe the real question is "why `#then` defined in `Kernel` and not in `Object`" :) But probably there is some good justification for it (because lot of other making-sense-only-with-receiver methods are also defined there).
----------------------------------------
Bug #16373: RDoc for some of the Kernel methods cannot be found in Kernel module
https://bugs.ruby-lang.org/issues/16373#change-82792
* Author: soutaro (Soutaro Matsumoto)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v:
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
RDoc documentations for some of the `Kernel` methods including `Kernel#then` are registered as `Object` methods. I'd like to propose to move `Kernel` methods listed in `Object` class to `Kernel` class.
The following `ri` results are confusing to me because the `Object` methods are defined in `Kernel` module technically.
```
$ ri Kernel#then
Nothing known about Kernel#then
$ ri Object#then
[Prints documentation]
```
This is because of the implementation of RDoc that it treats `Kernel` methods as if they are defined in `Object`.
- https://github.com/ruby/rdoc/blob/acfb829917336ecbca6036437918c29319db7c04/lib/rdoc/parser/c.rb#L508
I'd like to disable the assignment and make `Kernel` methods listed in `Kernel` module.
**Pros**
- The RDoc structure is more clear and precise
- (This is essential to me that it makes easier to generate annotations for RBS files.)
- Both of `ri Kernel#then` and `ri Object#then` print the documentation
**Cons**
- The document of `Object` class will be almost empty, which may cause confusion for readers while there is a link to included module, `Kernel`
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>