Class: ExDocIncludeProcessor

Inherits:
Asciidoctor::Extensions::IncludeProcessor
  • Object
show all
Defined in:
lib/ex-doc-include.rb

Instance Method Summary collapse

Instance Method Details

#handles?(target) ⇒ Boolean

Returns:



68
69
70
# File 'lib/ex-doc-include.rb', line 68

def handles? target
  target.end_with? '.h', '.hpp', '.cpp'
end

#process(doc, reader, target, attributes) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/ex-doc-include.rb', line 72

def process doc, reader, target, attributes
  if not attributes.key? 'expand'
    target_name = File.basename(target,'.*')
    expanded_target =  "#{target_name}.html"
    if attributes.key? 'out-dir'
      expanded_target = attributes["out-dir"] + "/" + expanded_target
    end
    
    Asciidoctor.convert("include::#{target}[expand=true]", to_file: expanded_target, attributes: doc.attributes)

    text =  if attributes.key? 'link' then attributes["link"] else target_name end
    content = ["link:#{expanded_target}[#{text}]"]
  else
    content = 
      IO.readlines(target)
      .map( &DocBlocksExtractor.new() )
      .compact
    #content = ["linked"]
  end
    reader.push_include content, target, target, 1, attributes
    return reader
end