Module: OrigenTesters::Doc::Generator

Extended by:
ActiveSupport::Concern
Defined in:
lib/origen_testers/doc/generator.rb,
lib/origen_testers/doc/generator/flow.rb,
lib/origen_testers/doc/generator/test.rb,
lib/origen_testers/doc/generator/tests.rb,
lib/origen_testers/doc/generator/flow_line.rb,
lib/origen_testers/doc/generator/test_group.rb

Defined Under Namespace

Classes: Flow, FlowLine, Test, TestGroup, Tests

Instance Method Summary collapse

Instance Method Details

#at_flow_startObject

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.



44
45
# File 'lib/origen_testers/doc/generator.rb', line 44

def at_flow_start
end

#at_run_startObject Also known as: reset_globals

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.



48
49
50
51
52
# File 'lib/origen_testers/doc/generator.rb', line 48

def at_run_start
  flow.at_run_start
  @@tests = nil
  @@flows = nil
end

#doc_commentsObject



109
110
111
# File 'lib/origen_testers/doc/generator.rb', line 109

def doc_comments
  @doc_comments ||= []
end

#doc_comments_capture(comment) ⇒ Object



105
106
107
# File 'lib/origen_testers/doc/generator.rb', line 105

def doc_comments_capture(comment)
  doc_comments << "#{comment}"
end

#doc_comments_consumeObject



113
114
115
116
117
# File 'lib/origen_testers/doc/generator.rb', line 113

def doc_comments_consume
  c = doc_comments
  doc_comments_discard
  c
end

#doc_comments_discardObject



119
120
121
# File 'lib/origen_testers/doc/generator.rb', line 119

def doc_comments_discard
  @doc_comments = []
end

#filter_source(source) ⇒ Object

The source of all program files is passed in here before executing. This will replace all comments with a method call containing the comment so that they can be captured.



92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/origen_testers/doc/generator.rb', line 92

def filter_source(source) # :nodoc:
  src = ''
  source.split(/\r?\n/).each do |line|
    if line !~ /^\s*#-/ && line =~ /^\s*#(.*)/
      comment = Regexp.last_match[1].gsub("'", "\\\\'")
      src << "Origen.interface.doc_comments_capture('#{comment}')\n"
    else
      src << "#{line}\n"
    end
  end
  src
end

#flow(filename = nil) ⇒ Object

Returns the current flow (as defined by the name of the current top level flow source file).

Pass in a filename argument to have a specific flow returned instead.

If the flow does not exist yet it will be created.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/origen_testers/doc/generator.rb', line 27

def flow(filename = nil)
  unless filename
    if Origen.file_handler.current_file
      filename = Origen.file_handler.current_file.basename('.rb').to_s
    else
      filename = 'anonymous'
    end
  end
  f = filename.to_sym
  return flows[f] if flows[f]
  p = Flow.new
  p.inhibit_output if Origen.interface.resources_mode?
  p.filename = f
  flows[f] = p
end

#flow_generatorsObject

Returns an array containing all flow generators. All Origen program generators must implement this method



81
82
83
84
85
86
87
# File 'lib/origen_testers/doc/generator.rb', line 81

def flow_generators
  g = []
  flows.each do |_name, sheet|
    g << sheet
  end
  g
end

#flowsObject

Returns a hash containing all flows



62
63
64
# File 'lib/origen_testers/doc/generator.rb', line 62

def flows
  @@flows ||= {}
end

#sheet_generatorsObject

Returns an array containing all sheet generators where a sheet generator is a flow, test instance, patset or pat group sheet. All Origen program generators must implement this method



69
70
71
72
73
74
75
76
77
# File 'lib/origen_testers/doc/generator.rb', line 69

def sheet_generators # :nodoc:
  g = []
  [flows].each do |sheets|
    sheets.each do |_name, sheet|
      g << sheet
    end
  end
  g
end

#testsObject Also known as: test_instances

Returns a container for all generated tests.



56
57
58
# File 'lib/origen_testers/doc/generator.rb', line 56

def tests
  @@tests ||= Tests.new
end