class Asciidoctor::Standoc::Datamodel::AttributesTablePreprocessor
Constants
- BLOCK_END_REGEXP
- BLOCK_START_REGEXP
- MARCO_REGEXP
- TEMPLATES_PATH
Public Instance Methods
process(document, reader)
click to toggle source
search document for block `datamodel_attributes_table`
read include derectives that goes after that in block and transform into yaml2text blocks
# File lib/asciidoctor/standoc/datamodel/attributes_table_preprocessor.rb, line 16 def process(document, reader) input_lines = reader.readlines.to_enum Reader.new(processed_lines(document, input_lines)) end
Private Instance Methods
model_representation(model_path)
click to toggle source
# File lib/asciidoctor/standoc/datamodel/attributes_table_preprocessor.rb, line 39 def model_representation(model_path) template = File.read(File.join( TEMPLATES_PATH, 'model_representation.adoc.erb' )) file_name = File.basename(model_path).gsub(/\.ya?ml/, '') ERB .new(template) .result(binding) end
parse_marco(yaml_path, document)
click to toggle source
# File lib/asciidoctor/standoc/datamodel/attributes_table_preprocessor.rb, line 34 def parse_marco(yaml_path, document) model_representation(yaml_relative_path(yaml_path, document)) .split("\n") end
processed_lines(document, input_lines)
click to toggle source
# File lib/asciidoctor/standoc/datamodel/attributes_table_preprocessor.rb, line 23 def processed_lines(document, input_lines) input_lines.each_with_object([]) do |line, result| if match = line.match(MARCO_REGEXP) yaml_path = match[1] result.push(*parse_marco(yaml_path, document)) else result.push(line) end end end
yaml_relative_path(file_path, document)
click to toggle source
# File lib/asciidoctor/standoc/datamodel/attributes_table_preprocessor.rb, line 50 def yaml_relative_path(file_path, document) directory = File.dirname(document.attributes['docfile'] || '.') document.path_resolver.system_path(file_path, directory) end