From e1b447a32304495e1379d154758130a8be530bfb Mon Sep 17 00:00:00 2001 From: zverok Date: Wed, 15 Feb 2023 22:07:21 +0200 Subject: [DOC] Improve ObjectSpace#dump_XXX method docs * remove false call-seq (output from Ruby parsing is cleaner) * explain output: argument in plain words * change parameter name in docs of #dump_shapes (typo) --- ext/objspace/lib/objspace.rb | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'ext') diff --git a/ext/objspace/lib/objspace.rb b/ext/objspace/lib/objspace.rb index 6865fdda4c..47873f5112 100644 --- a/ext/objspace/lib/objspace.rb +++ b/ext/objspace/lib/objspace.rb @@ -11,13 +11,16 @@ module ObjectSpace module_function - # call-seq: - # ObjectSpace.dump(obj[, output: :string]) -> "{ ... }" - # ObjectSpace.dump(obj, output: :file) -> # - # ObjectSpace.dump(obj, output: :stdout) -> nil - # # Dump the contents of a ruby object as JSON. # + # _output_ can be one of: +:stdout+, +:file+, +:string+, or IO object. + # + # * +:file+ means dumping to a tempfile and returning corresponding File object; + # * +:stdout+ means printing the dump and returning +nil+; + # * +:string+ means returning a string with the dump; + # * if an instance of IO object is provided, the output goes there, and the object + # is returned. + # # This method is only expected to work with C Ruby. # This is an experimental method and is subject to change. # In particular, the function signature and output format are @@ -43,16 +46,11 @@ module ObjectSpace end - # call-seq: - # ObjectSpace.dump_all([output: :file]) -> # - # ObjectSpace.dump_all(output: :stdout) -> nil - # ObjectSpace.dump_all(output: :string) -> "{...}\n{...}\n..." - # ObjectSpace.dump_all(output: File.open('heap.json','w')) -> # - # ObjectSpace.dump_all(output: :string, since: 42) -> "{...}\n{...}\n..." - # # Dump the contents of the ruby heap as JSON. # - # _full_ must be a boolean. If true all heap slots are dumped including the empty ones (T_NONE). + # _output_ argument is the same as for #dump. + # + # _full_ must be a boolean. If true, all heap slots are dumped including the empty ones (+T_NONE+). # # _since_ must be a non-negative integer or +nil+. # @@ -104,16 +102,11 @@ module ObjectSpace ret end - # call-seq: - # ObjectSpace.dump_shapes([output: :file]) -> # - # ObjectSpace.dump_shapes(output: :stdout) -> nil - # ObjectSpace.dump_shapes(output: :string) -> "{...}\n{...}\n..." - # ObjectSpace.dump_shapes(output: File.open('shapes.json','w')) -> # - # ObjectSpace.dump_all(output: :string, since: 42) -> "{...}\n{...}\n..." - # # Dump the contents of the ruby shape tree as JSON. # - # If _shapes_ is a positive integer, only shapes newer than the provided + # _output_ argument is the same as for #dump. + # + # If _since_ is a positive integer, only shapes newer than the provided # shape id are dumped. The current shape_id can be accessed using RubyVM.stat(:next_shape_id). # # This method is only expected to work with C Ruby. -- cgit v1.2.1