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

Fix docs for Indexable::Mutable#map! #11349

Merged

Conversation

HertzDevil
Copy link
Contributor

#11267 caused TODO: add as constant to overwrite the original documentation. This fixes it.

@straight-shoota
Copy link
Member

Oh that's weird doc association.
Should probably be fixed with #11268, though

@HertzDevil
Copy link
Contributor Author

HertzDevil commented Oct 23, 2021

I don't think so. The following:

# Invokes the given block for each element of `self`, replacing the element
# with the value returned by the block. Returns `self`.
#
# ```
# a = [1, 2, 3]
# a.map! { |x| x * x }
# a # => [1, 4, 9]
# ```
{% begin %}
{% if compare_versions(Crystal::VERSION, "1.1.1") >= 0 %} # TODO: add as constant
def map!(& : T -> _) : self
{% else %}
def map!(&) # it doesn't compile with the type annotation in the 1.0.0 compiler
{% end %}

expands to:

# Invokes the given block for each element of `self`, replacing the element
# with the value returned by the block. Returns `self`.
#
# ```
# a = [1, 2, 3]
# a.map! { |x| x * x }
# a # => [1, 4, 9]
# ```

 # TODO: add as constant
def map!(& : T -> _) : self

Likewise, on versions before 1.1.1 the original documentation will still be completely disconnected from the method. So this probably has nothing to do with trailing comments on the def's line. I also verified that # TODO: add as constant does not appear in the generated docs after this PR.

@straight-shoota straight-shoota added this to the 1.3.0 milestone Oct 27, 2021
@straight-shoota straight-shoota merged commit 9ace4f2 into crystal-lang:master Oct 29, 2021
@HertzDevil HertzDevil deleted the doc/indexable-mutable-map branch October 29, 2021 11:47
@straight-shoota straight-shoota added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:collection labels Dec 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. kind:docs topic:stdlib:collection
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants