Method: YARD::Parser::Ruby::AstNode#pretty_print

Defined in:
lib/yard/parser/ruby/ast_node.rb

#pretty_print(q) ⇒ nil

Returns pretty prints the node.

Returns:

  • (nil)

    pretty prints the node

[View source]

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
313
314
315
316
317
318
319
# File 'lib/yard/parser/ruby/ast_node.rb', line 287

def pretty_print(q)
  objs = self.dup + [:__last__]
  objs.unshift(type) if type && type != :list

  options = []
  if @docstring
    options << ['docstring', docstring]
  end
  if @source_range || @line_range
    options << ['line', line_range]
    options << ['source', source_range]
  end
  objs.pop if options.size == 0

  q.group(3, 's(', ')') do
    q.seplist(objs, nil, :each) do |v|
      if v == :__last__
        q.seplist(options, nil, :each) do |arr|
          k, v2 = *arr
          q.group(3) do
            q.text k
            q.group(3) do
              q.text ': '
              q.pp v2
            end
          end
        end
      else
        q.pp v
      end
    end
  end
end