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
More RDoc for Dir.glob #8088
More RDoc for Dir.glob #8088
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took a quick look at this file, it covers a lot of topics and goes into quite a bit of details about the methods that perform globbing.
However, it's difficult for me to review because I'm not sure how it will be used. It's difficult for me to understand how much detail we should be going into and whether or not we should be talking about the globbing methods because I don't know what existing information it replaces.
It would make it easier for me to review if you could also edit the parts that this document replaces.
doc/globbing.rdoc
Outdated
The FNM_CASEFOLD flag specifies that the matching is to be case-insensitive: | ||
|
||
Dir.glob('c*').take(5) | ||
# => ["CONTRIBUTING.md", "COPYING", "COPYING.ja", "ccan", "class.c"] | ||
Dir.glob('c*', flags: File::FNM_CASEFOLD).take(5) | ||
# => ["CONTRIBUTING.md", "COPYING", "COPYING.ja", "ccan", "class.c"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FNM_CASEFOLD
is only useful for File.fnmatch
, and not for any other methods (including Dir.glob
). See the documentation.
doc/globbing.rdoc
Outdated
<tt>'{_a_,_b_}'</tt>, which matches pattern _a_ and pattern _b_; | ||
behaves like | ||
a {regexp union}[https://docs.ruby-lang.org/en/master/Regexp.html#method-c-union] | ||
(e.g., <tt>'(?:_a_|_b_)'</tt>): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think italics work in <tt>
blocks, so the underscores will be generated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The entire block is misaligned (displayed as code). When that's corrected (next push), the italics work.
But the link there is fouled by <tt>'{_a_,_b_}'</tt>
(as we've seen elsewhere), so we get {regexp union}[https://docs.ruby-lang.org/en/master/Regexp.html#method-c-union]
in the output. If I experimentally remove that text, the link is rendered correctly.
doc/globbing.rdoc
Outdated
|
||
==== Flag File::FNM_SYSCASE | ||
|
||
Case sensitivity (sensitive or insensitive) is the same as the system. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should note that it's also only useful for File.fnmatch
and not any other methods.
I share your concern. When I started out, I was not sure where this was heading, but wanted at least to understand the implementations. Now I'm thinking thus:
Works for you? |
Yes I agree. While duplicating the doc across several location isn't the ideal solution, I think it will be the easiest to understand for the reader. |
I'm on it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor comment, otherwise looks good!
dir.rb
Outdated
# - If optional keyword argument +base+ is not given, | ||
# the base directory whose entries are to be matched is <tt>'.'</tt>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be part of the documentation rather than as a specific note for the example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed (as redundant); minor edit to the other passage discussing +base+.
dir.rb
Outdated
# examples below use the {Ruby file tree}[rdoc-ref:Dir@About+the+Examples]): | ||
# {Ruby project file tree}[https://github.com/ruby/ruby]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's sort of issue here, the Ruby file tree
part is duplicated twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for noticing; now fixed.
Co-authored-by: Peter Zhu <peter@peterzhu.ca>
New globbing doc for other files to link to (in future PRs).