Class: AbideDevUtils::CEM::Generate::Reference::MarkdownGenerator
- Inherits:
-
Object
- Object
- AbideDevUtils::CEM::Generate::Reference::MarkdownGenerator
- Defined in:
- lib/abide_dev_utils/cem/generate/reference.rb
Overview
Generates a markdown reference doc
Constant Summary collapse
- SPECIAL_CONTROL_IDS =
%w[dependent cem_options cem_protected].freeze
Instance Method Summary collapse
- #generate(doc_title = 'Reference') ⇒ Object
-
#initialize(benchmarks, module_name, file: 'REFERENCE.md', opts: {}) ⇒ MarkdownGenerator
constructor
A new instance of MarkdownGenerator.
Constructor Details
#initialize(benchmarks, module_name, file: 'REFERENCE.md', opts: {}) ⇒ MarkdownGenerator
Returns a new instance of MarkdownGenerator.
66 67 68 69 70 71 72 |
# File 'lib/abide_dev_utils/cem/generate/reference.rb', line 66 def initialize(benchmarks, module_name, file: 'REFERENCE.md', opts: {}) @benchmarks = benchmarks @module_name = module_name @file = file @opts = opts @md = AbideDevUtils::Markdown.new(@file) end |
Instance Method Details
#generate(doc_title = 'Reference') ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/abide_dev_utils/cem/generate/reference.rb', line 74 def generate(doc_title = 'Reference') @strings = Strings.new(opts: @opts) md.add_title(doc_title) benchmarks.each do |benchmark| unless @opts[:quiet] = AbideDevUtils::Output.progress(title: "Generating Markdown for #{benchmark.title_key}", total: benchmark.controls.length) end md.add_h1(benchmark.title_key) benchmark.controls.each do |control| next if SPECIAL_CONTROL_IDS.include? control.id next if benchmark.framework == 'stig' && control.id_map_type != 'vulnid' control_md = ControlMarkdown.new(control, @md, @strings, @module_name, benchmark.framework, opts: @opts) control_md.generate! .increment unless @opts[:quiet] rescue StandardError => e raise "Failed to generate markdown for control #{control.id}. Original message: #{e.}" end end AbideDevUtils::Output.simple("Saving markdown to #{@file}") unless @opts[:quiet] md.to_file end |