Class: HelpDoc

Inherits:
Object
  • Object
show all
Defined in:
app/models/help_doc.rb

Class Method Summary collapse

Class Method Details

.find_for(role_type, extension_dir = '') ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'app/models/help_doc.rb', line 5

def self.find_for(role_type, extension_dir='')
  results = [] 
  if extension_dir.blank?
    Radiant::ExtensionLoader.enabled_extension_paths.each do |ext_path|
      results << help_docs(ext_path, role_type)
    end
  else
    results << help_docs(Radiant::ExtensionPath.for(extension_dir), role_type)
  end
  results.reject(&:blank?).flatten
end

.formatted_contents_from(doc_path) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'app/models/help_doc.rb', line 17

def self.formatted_contents_from(doc_path)
  if doc_path.end_with?('markdown') || doc_path.end_with?('md')
    HelpDoc.parsed_markdown(doc_path)
  elsif doc_path.end_with?('textile')
    HelpDoc.parsed_textile(doc_path)
  else
    HelpDoc.parsed_rdoc(doc_path)
  end
end

.parsed_markdown(doc_path) ⇒ Object



31
32
33
# File 'app/models/help_doc.rb', line 31

def self.parsed_markdown(doc_path)
  MarkdownFilter.filter(File.read(doc_path))
end

.parsed_rdoc(doc_path) ⇒ Object



27
28
29
# File 'app/models/help_doc.rb', line 27

def self.parsed_rdoc(doc_path)
  RDoc::Markup::ToHtml.new.convert(File.read(doc_path))
end

.parsed_textile(doc_path) ⇒ Object



35
36
37
# File 'app/models/help_doc.rb', line 35

def self.parsed_textile(doc_path)
  ::RedCloth.new(File.read(doc_path)).to_html
end