Class: RDoc::Parser::ChangeLog::Git::LogEntry
- Inherits:
-
Struct
- Object
- Struct
- RDoc::Parser::ChangeLog::Git::LogEntry
- Defined in:
- lib/rdoc/parser/changelog.rb
Constant Summary collapse
- HEADING_LEVEL =
3
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#base ⇒ Object
Returns the value of attribute base.
-
#commit ⇒ Object
Returns the value of attribute commit.
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#date ⇒ Object
Returns the value of attribute date.
-
#email ⇒ Object
Returns the value of attribute email.
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #aref ⇒ Object
-
#initialize(base, commit, author, email, date, contents) ⇒ LogEntry
constructor
A new instance of LogEntry.
- #label(context = nil) ⇒ Object
- #legacy_aref ⇒ Object
- #legacy_label(context = nil) ⇒ Object
- #level ⇒ Object
-
#pretty_print(q) ⇒ Object
:nodoc:.
- #text ⇒ Object
Constructor Details
#initialize(base, commit, author, email, date, contents) ⇒ LogEntry
Returns a new instance of LogEntry.
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
# File 'lib/rdoc/parser/changelog.rb', line 276 def initialize(base, commit, , email, date, contents) case contents when String if base&.match(%r[\A([^:/]+:/+[^/]+/)[^/]+/[^/]+/]) repo, host = $&, $1 contents = contents.dup # base: https://github.com/ruby/ruby/ # Fix #15791 -> Fix [#15791](https://github.com/ruby/ruby/pull/15791) # GH-15791 -> [GH-15791](https://github.com/ruby/ruby/pull/15791) # (#15791) -> ([#15791](https://github.com/ruby/ruby/pull/15791)) contents.gsub!(/\b(?:(?i:fix(?:e[sd])?) +)\K\#(\d+\b)|\bGH-(\d+)\b|\(\K\#(\d+)(?=\))/) do "[#{$&}](#{repo}pull/#{$1 || $2 || $3})" end # repo#PR, repo@HASH # ruby/ruby#15791 -> [ruby/ruby#15791](https://github.com/ruby/ruby/pull/15791) # ruby/ruby@a8a989b6 -> [ruby/ruby@a8a989b6](https://github.com/ruby/ruby/commit/a8a989b6) # ref in branckets is not extended # [ruby/net-imap#543][ruby/ruby#15791] -> [ruby/net-imap#543][ruby/ruby#15791] contents.gsub!(%r[(?<![-\w#/@]|\]\[)([-\w]+/[-\w]+)(?:@(\h{8,40})|\#(\d+))(?![-\w#/@]|\]\[)]) do path = defined?($2) ? "commit/#{$2}" : "pull/#{$3}" "[#{$&}](#{host}#{$1}/#{path})" end end contents = ::RDoc::Markdown.parse(contents).parts.each do |body| case body when Markup::Heading body.level += HEADING_LEVEL + 1 end end case first = contents[0] when Markup::Paragraph contents[0] = Markup::Heading.new(HEADING_LEVEL + 1, first.text) end end super end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author
273 274 275 |
# File 'lib/rdoc/parser/changelog.rb', line 273 def @author end |
#base ⇒ Object
Returns the value of attribute base
273 274 275 |
# File 'lib/rdoc/parser/changelog.rb', line 273 def base @base end |
#commit ⇒ Object
Returns the value of attribute commit
273 274 275 |
# File 'lib/rdoc/parser/changelog.rb', line 273 def commit @commit end |
#contents ⇒ Object
Returns the value of attribute contents
273 274 275 |
# File 'lib/rdoc/parser/changelog.rb', line 273 def contents @contents end |
#date ⇒ Object
Returns the value of attribute date
273 274 275 |
# File 'lib/rdoc/parser/changelog.rb', line 273 def date @date end |
#email ⇒ Object
Returns the value of attribute email
273 274 275 |
# File 'lib/rdoc/parser/changelog.rb', line 273 def email @email end |
Instance Method Details
#accept(visitor) ⇒ Object
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 |
# File 'lib/rdoc/parser/changelog.rb', line 345 def accept(visitor) visitor.accept_heading self begin if visitor.respond_to?(:code_object=) code_object = visitor.code_object visitor.code_object = self end contents.each do |body| body.accept visitor end ensure if visitor.respond_to?(:code_object) visitor.code_object = code_object end end end |
#aref ⇒ Object
318 319 320 |
# File 'lib/rdoc/parser/changelog.rb', line 318 def aref commit end |
#label(context = nil) ⇒ Object
326 327 328 |
# File 'lib/rdoc/parser/changelog.rb', line 326 def label(context = nil) aref end |
#legacy_aref ⇒ Object
322 323 324 |
# File 'lib/rdoc/parser/changelog.rb', line 322 def legacy_aref "label-#{commit}" end |
#legacy_label(context = nil) ⇒ Object
330 331 332 |
# File 'lib/rdoc/parser/changelog.rb', line 330 def legacy_label(context = nil) legacy_aref end |
#level ⇒ Object
314 315 316 |
# File 'lib/rdoc/parser/changelog.rb', line 314 def level HEADING_LEVEL end |
#pretty_print(q) ⇒ Object
:nodoc:
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
# File 'lib/rdoc/parser/changelog.rb', line 362 def pretty_print(q) # :nodoc: q.group(2, '[log_entry: ', ']') do q.text commit q.text ',' q.breakable q.group(2, '[date: ', ']') { q.text date } q.text ',' q.breakable q.group(2, '[author: ', ']') { q.text } q.text ',' q.breakable q.group(2, '[email: ', ']') { q.text email } q.text ',' q.breakable q.pp contents end end |
#text ⇒ Object
334 335 336 337 338 339 340 341 342 343 |
# File 'lib/rdoc/parser/changelog.rb', line 334 def text case base when nil "#{date}" when /%s/ "{#{date}}[#{base % commit}]" else "{#{date}}[#{base}#{commit}]" end + " {#{}}[mailto:#{email}]" end |