-
Notifications
You must be signed in to change notification settings - Fork 446
Expand GitHub style references in ChangeLog to URL #1547
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
base: master
Are you sure you want to change the base?
Conversation
lib/rdoc/parser/changelog.rb
Outdated
| if base&.match(%r[\A([^:/]+:/+[^/]+/)[^/]+/[^/]+/]) | ||
| repo, host = $&, $1 | ||
| contents = contents.dup | ||
| contents.gsub!(/\b(?:(?i:fix(?:e[sd])?) +)\K#(\d+\b)|\bGH-(\d+)\b|\(\K\#(\d+)(?=\))/) do |
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.
Could you add a comment with example substitutions for easy to understand? For example:
# base: https://github.com/ruby/ruby/
# Fix #15791 -> [Fix #15791](https://github.com/ruby/ruby/pull/15791)
# ...
lib/rdoc/parser/changelog.rb
Outdated
| if base&.match(%r[\A([^:/]+:/+[^/]+/)[^/]+/[^/]+/]) | ||
| repo, host = $&, $1 | ||
| contents = contents.dup | ||
| contents.gsub!(/\b(?:(?i:fix(?:e[sd])?) +)\K#(\d+\b)|\bGH-(\d+)\b|\(\K\#(\d+)(?=\))/) do |
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.
Could you unify escape style to \K# or \K\#?
| contents.gsub!(/\b(?:(?i:fix(?:e[sd])?) +)\K#(\d+\b)|\bGH-(\d+)\b|\(\K\#(\d+)(?=\))/) do | |
| contents.gsub!(/\b(?:(?i:fix(?:e[sd])?) +)\K\#(\d+\b)|\bGH-(\d+)\b|\(\K\#(\d+)(?=\))/) do |
lib/rdoc/parser/changelog.rb
Outdated
| repo, host = $&, $1 | ||
| contents = contents.dup | ||
| contents.gsub!(/\b(?:(?i:fix(?:e[sd])?) +)\K#(\d+\b)|\bGH-(\d+)\b|\(\K\#(\d+)(?=\))/) do | ||
| "[#$&](#{repo}pull/#{$1 || $2 || $3})" |
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.
.../issues/#{N} is better than .../pull/#{N} because .../issues/#{N} works for both of issues and pull requests:
| "[#$&](#{repo}pull/#{$1 || $2 || $3})" | |
| "[#$&](#{repo}issues/#{$1 || $2 || $3})" |
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 think /pull/ also works as well as /issues/, that is the conversion is bidirectional.
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.
Oh... I didn't know 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.
I chose pull just because ruby/ruby is not using GitHub Issues.
lib/rdoc/parser/changelog.rb
Outdated
| repo, host = $&, $1 | ||
| contents = contents.dup | ||
| contents.gsub!(/\b(?:(?i:fix(?:e[sd])?) +)\K#(\d+\b)|\bGH-(\d+)\b|\(\K\#(\d+)(?=\))/) do | ||
| "[#$&](#{repo}pull/#{$1 || $2 || $3})" |
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.
Could you unify #{...} style?
| "[#$&](#{repo}pull/#{$1 || $2 || $3})" | |
| "[#{$&}](#{repo}pull/#{$1 || $2 || $3})" |
|
🚀 Preview deployment available at: https://51e1142a.rdoc-6cd.pages.dev (commit: 5e609fc) |
| contents.gsub!(/\b(?:(?i:fix(?:e[sd])?) +)\K\#(\d+\b)|\bGH-(\d+)\b|\(\K\#(\d+)(?=\))/) do | ||
| "[#{$&}](#{repo}pull/#{$1 || $2 || $3})" | ||
| end | ||
| contents.gsub!(%r[(?<![-\w#/@]|\]\[)([-\w]+/[-\w]+)(?:@(\h{8,40})|\#(\d+))(?![-\w#/@]|\]\[)]) do |
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.
Could you add an example comment here too?
Currently, ruby/ruby formats ChangeLog and expands such references to links.
But such links in ChangeLog that is a plain text does not make sense.
I think it is suitable to be done at conversion from ChangeLog to HTML