[前][次][番号順一覧][スレッド一覧]

ruby-changes:28462

From: zzak <ko1@a...>
Date: Sun, 28 Apr 2013 23:19:27 +0900 (JST)
Subject: [ruby-changes:28462] zzak:r40514 (trunk): * lib/pp.rb: Update PP module overview by @geopet

zzak	2013-04-28 23:19:18 +0900 (Sun, 28 Apr 2013)

  New Revision: 40514

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40514

  Log:
    * lib/pp.rb: Update PP module overview by @geopet

  Modified files:
    trunk/ChangeLog
    trunk/lib/pp.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40513)
+++ ChangeLog	(revision 40514)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Apr 28 23:19:00 2013  Zachary Scott  <zachary@z...>
+
+	* lib/pp.rb: Update PP module overview by @geopet
+
 Sun Apr 28 22:04:37 2013  Hiroshi Shirosaki  <h.shirosaki@g...>
 
 	* ext/openssl/ossl_bn.c (ossl_bn_initialize): fix buffer overflow on
Index: lib/pp.rb
===================================================================
--- lib/pp.rb	(revision 40513)
+++ lib/pp.rb	(revision 40514)
@@ -25,14 +25,19 @@ module Kernel https://github.com/ruby/ruby/blob/trunk/lib/pp.rb#L25
   module_function :pp # :nodoc:
 end
 
-# Pretty-printer for Ruby objects.
+##
+# A pretty-printer for Ruby objects.
 #
-# == Which seems better?
+# All examples assume you have loaded the PP class with:
+#   require 'pp'
 #
-# Standard output by #p like this?
+##
+# == What PP Does
+#
+# Standard output by #p returns this:
 #   #<PP:0x81fedf0 @genspace=#<Proc:0x81feda0>, @group_queue=#<PrettyPrint::GroupQueue:0x81fed3c @queue=[[#<PrettyPrint::Group:0x81fed78 @breakables=[], @depth=0, @break=false>], []]>, @buffer=[], @newline="\n", @group_stack=[#<PrettyPrint::Group:0x81fed78 @breakables=[], @depth=0, @break=false>], @buffer_width=0, @indent=0, @maxwidth=79, @output_width=2, @output=#<IO:0x8114ee4>>
 #
-# Or the pretty-printed version:
+# Pretty-printed output returns this:
 #   #<PP:0x81fedf0
 #    @buffer=[],
 #    @buffer_width=0,
@@ -50,11 +55,11 @@ end https://github.com/ruby/ruby/blob/trunk/lib/pp.rb#L55
 #    @output=#<IO:0x8114ee4>,
 #    @output_width=2>
 #
-# I like the latter.  If you do too, this library is for you.
-#
+##
 # == Usage
 #
 #   pp(obj)             #=> obj
+#   pp obj              #=> obj
 #   pp(obj1, obj2, ...) #=> [obj1, obj2, ...]
 #   pp()                #=> nil
 #
@@ -62,22 +67,30 @@ end https://github.com/ruby/ruby/blob/trunk/lib/pp.rb#L67
 #
 # It returns <tt>obj(s)</tt>.
 #
-# = Output Customization
+##
+# == Output Customization
 #
-# To define your customized pretty printing function for your classes,
-# redefine a method #pretty_print(+pp+) in the class.
+# To define a customized pretty printing function for your classes,
+# redefine method <code>#pretty_print(pp)</code> in the class.
 #
-# It takes an argument +pp+ which is an instance of the class PP.
-# The method should use #text, #breakable, #nest, #group and #pp to print the
+# <code>#pretty_print</code> takes the +pp+ argument, which is an instance of the PP class.
+# The method uses #text, #breakable, #nest, #group and #pp to print the
 # object.
 #
-# = Author
+##
+# == Pretty-Print JSON
+#
+# To pretty-print JSON refer to JSON#pretty_generate.
+#
+##
+# == Author
 # Tanaka Akira <akr@f...>
+
 class PP < PrettyPrint
   # Outputs +obj+ to +out+ in pretty printed format of
   # +width+ columns in width.
   #
-  # If +out+ is omitted, +$>+ is assumed.
+  # If +out+ is omitted, <code>$></code> is assumed.
   # If +width+ is omitted, 79 is assumed.
   #
   # PP.pp returns +out+.

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]