diff options
author | Nobuyoshi Nakada <[email protected]> | 2021-01-21 21:03:55 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2021-01-24 16:46:19 +0900 |
commit | 127f735c1e5e0771076caf2a74390757a42fb177 (patch) | |
tree | b3c29e902f9b84fc4db07f1f541c506b7c5ffd1a /lib/rdoc | |
parent | b88d1e6b44164bca0c2b85ea6639469813e1e1d8 (diff) |
[ruby/rdoc] Tweak log entry markdown
* add 3 levels to headings
* prefix commit log to labels to make unique IDs
https://github.com/ruby/rdoc/commit/5074c13209
Diffstat (limited to 'lib/rdoc')
-rw-r--r-- | lib/rdoc/parser/changelog.rb | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/rdoc/parser/changelog.rb b/lib/rdoc/parser/changelog.rb index 763ba03d2c..eca4b56ec9 100644 --- a/lib/rdoc/parser/changelog.rb +++ b/lib/rdoc/parser/changelog.rb @@ -229,11 +229,29 @@ class RDoc::Parser::ChangeLog < RDoc::Parser out = [] entries.each do |entry, (author, date, body)| title = RDoc::Markup::Heading.new(3, "#{date} #{author}") + title.extend(Aref) + title.aref = "label-#{entry}" out << title - out.concat RDoc::Markdown.parse(body).parts + out.concat parse_log_entry(body, entry) end out end + + def parse_log_entry(content, sha) + RDoc::Markdown.parse(content).parts.each do |body| + case body + when RDoc::Markup::Heading + body.level += 3 + label = body.aref.sub(/\Alabel-/, "label-#{sha}-") + body.extend(Aref) + body.aref = label + end + end + end + + module Aref + attr_accessor :aref + end end end |