Method: YARD::Parser::SourceParser.after_parse_file

Defined in:
lib/yard/parser/source_parser.rb

.after_parse_file {|parser| ... } ⇒ Proc

Registers a callback to be called after an individual file is parsed. The block passed to this method will be called on subsequent parse calls.

To register a callback that is called after the entire list of files is processed, see after_parse_list.

Examples:

Printing the length of each file after it is parsed

SourceParser.after_parse_file do |parser|
  puts "#{parser.file} is #{parser.contents.size} characters"
end
YARD.parse('lib/**/*.rb')
# prints:
"lib/foo.rb is 1240 characters"
"lib/foo_bar.rb is 248 characters"

Yields:

  • (parser)

    the yielded block is called once after each file that is parsed. This might happen many times for a single codebase.

Yield Parameters:

  • parser (SourceParser)

    the parser object that parsed the file.

Yield Returns:

  • (void)

    the return value for the block is ignored.

Returns:

  • (Proc)

    the yielded block

See Also:

Since:

  • 0.7.0

[View source]

321
322
323
# File 'lib/yard/parser/source_parser.rb', line 321

def after_parse_file(&block)
  after_parse_file_callbacks << block
end