Module: DocuBot
- Defined in:
- lib/docubot.rb,
lib/docubot/snippet.rb,
lib/docubot/converter.rb
Defined Under Namespace
Modules: Converter, LinkTree
Classes: Bundle, CHMWriter, Glossary, HTMLWriter, Index, MetaSection, Page, Writer
Constant Summary
collapse
- VERSION =
'1.2.0'
- DIR =
File.expand_path( File.dirname( __FILE__ ) )
- TEMPLATE_DIR =
DIR / 'docubot/templates'
- SHELL_DIR =
DIR / 'docubot/shells'
Class Method Summary
collapse
Class Method Details
.convert_to_html(page, source, type) ⇒ Object
16
17
18
19
20
21
22
23
|
# File 'lib/docubot/converter.rb', line 16
def self.convert_to_html( page, source, type )
if converter = DocuBot::Converter.by_type[ type.to_s ]
puts "Converting #{type}: #{source.inspect[0..60]}" if $DEBUG
converter[ page, source ]
else
raise "No converter found for type #{type}"
end
end
|
.handle_snippet(regexp, &handler) ⇒ Object
5
6
7
|
# File 'lib/docubot/snippet.rb', line 5
def self.handle_snippet( regexp, &handler )
@snippets[ regexp ] = handler
end
|
.id_from_text(text) ⇒ Object
30
31
32
|
# File 'lib/docubot.rb', line 30
def self.id_from_text( text )
"#" << text.strip.gsub(/[^\w.:-]+/,'-').gsub(/^[^a-z]+|-+$/i,'')
end
|
.process_snippets(page, html) ⇒ Object
9
10
11
12
|
# File 'lib/docubot/snippet.rb', line 9
def self.process_snippets( page, html )
@snippets.inject(html){ |h,(regexp,handler)| h.gsub( regexp ){ |str| handler[ str, page ] } }
end
|