-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
:ditto:
doesn't work with :inherit:
#11362
Comments
What about this case: class Parent
# foo
def foo; end
# bar
def bar; end
end
class Child < Parent
# :inherit:
def foo; end
# :ditto:
def bar; end
end You could reasonably expect the documentation for |
It probably works that way because Another thing to consider is how they should work if you did like: class Child < Parent
# :inherit:
def foo; end
# :ditto:
#
# :inherit:
def bar; end
end I would think it should output: foo
bar But currently you get: |
The technical reason is probably that I was wondering why in your last example When considering concrete use cases, I could think of overriding methods with some additional text that amends the parent docs and is shared among several methods. class Parent
# This does foo.
def foo; end
# This does bar.
def bar; end
end
class Child < Parent
# :inherit:
#
# And it's done by a child.
def foo; end
# :ditto:
def bar; end
end In this case again, I would clearly expect the doc for |
I have a module like: module Athena::Console::Style::Interface
# Helper method for asking `ACON::Question` questions.
abstract def ask(question : String, default : _)
end Then an implementation of the module (cut down for this example): struct Athena::Console::Style::Athena
include Athena::Console::Style::Interface
# :inherit:
def ask(question : String, default : _)
self.ask ACON::Question.new question, default
end
# :ditto:
def ask(question : ACON::Question::Base)
# ...
end
end It made sense to me to want to copy the docs from the interface implementation on the other overload, and can't just use |
A use case in #11368 is as follows. Currently we have: class Array(T)
include Indexable::Mutable(T)
# The quick brown fox jumps over a lazy dog.
def fill(value : T, start : Int, count : Int) : self
# ...
end
# :ditto:
@[Deprecated("Use `#fill(value, start, count)` instead")]
def fill(value : T, *, from start : Int, count : Int) : self
fill(value, start, count)
end
end That PR makes the first overload available in module Indexable::Mutable(T)
# The quick brown fox jumps over a lazy dog.
def fill(value : T, start : Int, count : Int) : self
# ...
end
end
class Array(T)
# :inherit:
def fill(value : T, start : Int, count : Int) : self
to_unsafe_slice.fill(value, start, count)
self
end
# :ditto:
@[Deprecated("Use `#fill(value, start, count)` instead")]
def fill(value : T, *, from start : Int, count : Int) : self
fill(value, start, count)
end
end Now the deprecated overload's documentation is incorrect, and the original doc must be copied to one of |
Given the following class setup:
Produces:
I would have expected the
:ditto:
to run after copying the docs from the parent method.The text was updated successfully, but these errors were encountered: