Add missing documentation to String methods#8447
Conversation
|
Hi @Sija, @asterite, @straight-shoota, @r00ster91, second round. Also i fix bug that i found during creating code samples in |
|
Could you please squash the changes into two commits: One fixing the exception, the other adding the docs? |
a3efda4 to
fb263bf
Compare
|
@straight-shoota yes, of course. |
straight-shoota
left a comment
There was a problem hiding this comment.
-
To avoid confusion, I'd suggest to always specify "byte index" to distinguish from character index. Maybe we should also use "character index" in the other cases as well, but I'm not sure.
Perhaps even rename the arguments tobyte_indexorbyte_offset? I'm not sure that's necessary, though. And it should be a different PR. -
You're sometimes referring to "out of bounds", sometimes "out of range". I'm not sure if one is strictly better than the other but it would be best to use the same terminology everywhere.
-
Regarding: "Returns
true, if [...], otherwisefalse.": IMO the last part should be omitted. It's unnecessary and only clutters the description. It should be evident thatBoolmethods returnfalsein all other cases where it's nottrue. -
Probably also a thing for another PR, but I'd like to standardize some of the argument names. For example
byte_slice(start : Int, count : Int)vs.unsafe_byte_slice(byte_offset, count)(see also 1.). And short argument names likestrorreshould IMO be properly named.
|
@jan-zajic thank you for all your work on docs! |
|
@straight-shoota i made fixes according to yours review + according to your comment: |
|
Thank you very much! |
c713a6b to
ad92398
Compare
|
@jan-zajic Could you please rebase on master? |
5afa152 to
8b21790
Compare
|
@straight-shoota yes, of course. It's done. |
src/string.cr
Outdated
| end | ||
|
|
||
| def byte_index(byte : Int, offset = 0) | ||
| # Returns the index of *byte* in the string, or `nil` if the byte is not present. |
There was a problem hiding this comment.
"Returns the index of the first ocurrence"?
There was a problem hiding this comment.
@straight-shoota what you think about this proposal? Is it not against previous considerations? I think my draft is in line with other docs in string file..
There was a problem hiding this comment.
I'm not sure, did we discuss this before? @RX14's suggestion sounds reasonable, it's more specific.
There was a problem hiding this comment.
Maybe, but it's same with current existing documentation for index method .. So maybe i have to change it too? And please write always complete formulation, what about for example:
1, Returns byte index of the first ocurrence of byte in the string, or nil if not present.
or
2, Returns the index of the first ocurrence of byte in the string, or nil if not present.
or
3, Returns the index of the first ocurrence in the string, or nil if not present.
or
4, Returns byte index of the first ocurrence in the string, or nil if not present.
or?
There was a problem hiding this comment.
Number 2 please.
And I'd like to change #index accordingly, that is add "first occurrence" to the existing phrase. For the regex overload: "first match"
2c0d203 to
32ea1f5
Compare
Co-Authored-By: Johannes Müller <johannes.mueller@smj-fulda.org>
Signed-off-by: Jan Zajic <jan.zajic@corpus.cz>
7c4d8a9 to
2620493
Compare
|
@straight-shoota i rebase this on current master (again). Please can we finally merge this, before another conflicts arise? |
RX14
left a comment
There was a problem hiding this comment.
Just one thing got lost in the rebase I think.
src/string.cr
Outdated
| end | ||
|
|
||
| def byte_index(byte : Int, offset = 0) | ||
| # Returns the index of *byte* in the string, or `nil` if the byte is not present. |
|
@RX14 it's done |
Co-Authored-By: Johannes Müller <johannes.mueller@smj-fulda.org>
n/c