-
-
Notifications
You must be signed in to change notification settings - Fork 398
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
Prefer the README file that has the basename README #1231
Comments
I believe that the list is sorted lexically, which would make sense if README-X was chosen over README.X since: > '-'.ord < '.'.ord
=> true
> ['.', '-'].sort
=> ["-", "."] That said, I believe globs are system dependent, so the behavior certainly isn't guaranteed. This can be problematic in cases where you're trying to deliver consistent docs across platforms. I think a PR to prioritize Sorting the entire list could be done but could be seen as a breaking change, since it would change the behavior for systems that don't sort globs initially. I'm not sure how I feel about that, given that it (a) changes behavior but (b) is undefined behavior. Another heuristic we could use would be to stable-sort by the frequency of '.' in the strings. That should ensure |
I'd be glad to.
Well, it's the most likely scenario. Any project that has a single file extension
That's why I say "single file extension". That's important.
No question, at the very least making it deterministic would be a good step forward.
If we fix the main issue at hand, I don't think the sorting becomes all that important. Though it would still be good to stabilize it. |
Apologies, I was mistaken. It selects the Chinese translation (zh_CN), which makes sense because it's at the end of the list. That must mean it's reversing the list at some point. I'll try to figure out what the existing rules are and report back. |
Here's the order that Dir.glob returns (Ruby 2.6):
go figure |
- sort README files, first by file extension, then by basename - prefer README basename over all other files - prefer file without extension over file with extension
See PR #1233. |
- sort README files, first by file extension, then by basename - prefer README basename over all other files - prefer file without extension over file with extension - don't glob for files if README is missing and files list is empty
- sort README files, first by file extension, then by basename - prefer README basename over all other files - prefer file without extension over file with extension - don't glob for files if README is missing and files list is empty
I'm facing a situation where the translated version of the README (e.g., README-jp.adoc) in a gem is being selected over the primary (English) one (README.adoc). (See https://www.rubydoc.info/gems/asciidoctor/2.0.0). This happens because of how the the README files are globbed.
The README files in the gem are as follows:
The glob used by YARD is
README*
. For some reason, that results in README-jp.adoc being selected as the default. (It appears the result of the glob isn't sorted at all).I think the file with the basename README (e.g., README.adoc) should be preferred over files that are hyphenated. I think most people would agree that this is the master README file in all situations.
(I'm aware I can include a .yardopts file to select a specific README. However, I can't make that change for gems that have already been released).
The text was updated successfully, but these errors were encountered: