From 531d47d6c1c6d60cf4631121708977383f2e3aa2 Mon Sep 17 00:00:00 2001 From: zzak Date: Sun, 28 Apr 2013 14:19:18 +0000 Subject: [PATCH] * lib/pp.rb: Update PP module overview by @geopet git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ lib/pp.rb | 39 ++++++++++++++++++++++++++------------- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index a3164ac37e..32866d1c46 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sun Apr 28 23:19:00 2013 Zachary Scott + + * lib/pp.rb: Update PP module overview by @geopet + Sun Apr 28 22:04:37 2013 Hiroshi Shirosaki * ext/openssl/ossl_bn.c (ossl_bn_initialize): fix buffer overflow on diff --git a/lib/pp.rb b/lib/pp.rb index 134991bd71..18cc473509 100644 --- a/lib/pp.rb +++ b/lib/pp.rb @@ -25,14 +25,19 @@ module Kernel 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: # #, @group_queue=#], []]>, @buffer=[], @newline="\n", @group_stack=[#], @buffer_width=0, @indent=0, @maxwidth=79, @output_width=2, @output=#> # -# Or the pretty-printed version: +# Pretty-printed output returns this: # #, # @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 # # It returns obj(s). # -# = 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 #pretty_print(pp) 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 +# #pretty_print 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 + 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, $> is assumed. # If +width+ is omitted, 79 is assumed. # # PP.pp returns +out+.