Module: YARD::Doctest

Extended by:
Doctest
Included in:
Doctest
Defined in:
lib/yard-doctest.rb,
lib/yard/doctest/rake.rb,
lib/yard/doctest/example.rb,
lib/yard/doctest/version.rb

Defined Under Namespace

Classes: Example, RakeTask

Constant Summary collapse

VERSION =
'0.1.17'

Instance Method Summary collapse

Instance Method Details

#after(test = nil, &blk) ⇒ Object

Passed block called after each example or specific tests based on passed name.

It is evaluated in the same context as example.


44
45
46
# File 'lib/yard-doctest.rb', line 44

def after(test = nil, &blk)
  hooks[:after] << {test: test, block: blk}
end

#after_run(&blk) ⇒ Object

Passed block called after all examples and evaluated in the different context from examples.

It actually just sends block to `Minitest.after_run`.


56
57
58
# File 'lib/yard-doctest.rb', line 56

def after_run(&blk)
  Minitest.after_run &blk
end

#before(test = nil, &blk) ⇒ Object

Passed block called before each example or specific tests based on passed name.

It is evaluated in the same context as example.


31
32
33
# File 'lib/yard-doctest.rb', line 31

def before(test = nil, &blk)
  hooks[:before] << {test: test, block: blk}
end

#configure {|self| ... } ⇒ Object

Configures YARD doctest.

Yields:

  • (self)

18
19
20
# File 'lib/yard-doctest.rb', line 18

def configure
  yield self
end

#hooksObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns hash with arrays of before/after hooks.


81
82
83
84
85
# File 'lib/yard-doctest.rb', line 81

def hooks
  @hooks ||= {}.tap do |hash|
    hash[:before], hash[:after] = [], []
  end
end

#skip(test) ⇒ Object

Adds definition of test to be skipped.


65
66
67
# File 'lib/yard-doctest.rb', line 65

def skip(test)
  skips << test
end

#skipsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Array of tests to be skipped.


73
74
75
# File 'lib/yard-doctest.rb', line 73

def skips
  @skips ||= []
end