summaryrefslogtreecommitdiff
path: root/lib/rdoc/parser/changelog.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-07 05:22:50 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-07 05:22:50 +0000
commit85e3560a3bfb1652128d3336400f852b863f6c07 (patch)
tree0310bf56d334b36c224603b6bfe930f7385f0faf /lib/rdoc/parser/changelog.rb
parent08f0db2c68a9e306f3a637e9d32d9e7b8b1f2e92 (diff)
* lib/rdoc/markup/to_joined_paragraph.rb: Completed documentation
* lib/rdoc/parser/c.rb: ditto * lib/rdoc/parser/changelog.rb: ditto * lib/rdoc/servlet.rb: ditto * lib/rdoc/store.rb: ditto * lib/rdoc/store.rb: Improved HTML error page. Completed documentation * lib/rdoc/parser/ruby.rb: Fixed bug attaching a comment to A::B = 42 * test/rdoc/test_rdoc_parser_ruby.rb: Test for above * test/rdoc/test_rdoc_comment.rb: Removed garbage git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/parser/changelog.rb')
-rw-r--r--lib/rdoc/parser/changelog.rb51
1 files changed, 50 insertions, 1 deletions
diff --git a/lib/rdoc/parser/changelog.rb b/lib/rdoc/parser/changelog.rb
index 6a21506a93..fd7114daee 100644
--- a/lib/rdoc/parser/changelog.rb
+++ b/lib/rdoc/parser/changelog.rb
@@ -1,11 +1,28 @@
require 'time'
+##
+# A ChangeLog file parser.
+#
+# This parser converts a ChangeLog into an RDoc::Markup::Document. When
+# viewed as HTML a ChangeLog page will have an entry for each day's entries in
+# the sidebar table of contents.
+#
+# This parser is meant to parse the MRI ChangeLog, but can be used to parse any
+# {GNU style Change
+# Log}[http://www.gnu.org/prep/standards/html_node/Style-of-Change-Logs.html].
+
class RDoc::Parser::ChangeLog < RDoc::Parser
include RDoc::Parser::Text
parse_files_matching(/(\/|\\|\A)ChangeLog[^\/\\]*\z/)
+ ##
+ # Attaches the +continuation+ of the previous line to the +entry_body+.
+ #
+ # Continued function listings are joined together as a single entry.
+ # Continued descriptions are joined to make a single paragraph.
+
def continue_entry_body entry_body, continuation
return unless last = entry_body.last
@@ -21,6 +38,9 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
end
end
+ ##
+ # Creates an RDoc::Markup::Document given the +groups+ of ChangeLog entries.
+
def create_document groups
doc = RDoc::Markup::Document.new
doc.omit_headings_below = 2
@@ -39,6 +59,10 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
doc
end
+ ##
+ # Returns a list of ChangeLog entries an RDoc::Markup nodes for the given
+ # +entries+.
+
def create_entries entries
out = []
@@ -52,6 +76,10 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
out
end
+ ##
+ # Returns an RDoc::Markup::List containing the given +items+ in the
+ # ChangeLog
+
def create_items items
list = RDoc::Markup::List.new :NOTE
@@ -69,12 +97,30 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
list
end
+ ##
+ # Groups +entries+ by date.
+
def group_entries entries
- entries.group_by do |title, body|
+ entries.group_by do |title, _|
Time.parse(title).strftime "%Y-%m-%d"
end
end
+ ##
+ # Parses the entries in the ChangeLog.
+ #
+ # Returns an Array of each ChangeLog entry in order of parsing.
+ #
+ # A ChangeLog entry is an Array containing the ChangeLog title (date and
+ # committer) and an Array of ChangeLog items (file and function changed with
+ # description).
+ #
+ # An example result would be:
+ #
+ # [ 'Tue Dec 4 08:33:46 2012 Eric Hodel <drbrain@segment7.net>',
+ # [ 'README.EXT: Converted to RDoc format',
+ # 'README.EXT.ja: ditto']]
+
def parse_entries
entries = []
entry_name = nil
@@ -122,6 +168,9 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
entries
end
+ ##
+ # Converts the ChangeLog into an RDoc::Markup::Document
+
def scan
entries = parse_entries
grouped_entries = group_entries entries