Module: Shoes::Manual

Defined in:
lib/shoes/manual.rb,
lib/shoes/manual/version.rb

Constant Summary collapse

ROOT_DIR =
File.expand_path(File.join(__FILE__, "../../.."))
VERSION =
"4.0.1"

Class Method Summary collapse

Class Method Details

.load_docs(lang) ⇒ Object



26
27
28
# File 'lib/shoes/manual.rb', line 26

def self.load_docs(lang)
  @docs ||= load_path(lang =~ /\.txt$/ ? lang : File.join(ROOT_DIR, "static/manual-#{lang}.txt"))
end

.load_path(path) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/shoes/manual.rb', line 30

def self.load_path(path)
  str = IO.read(path).force_encoding("UTF-8")
  (str.split(/^= (.+?) =/)[1..-1] / 2).map do |k, v|
    sparts = v.split(/^== (.+?) ==/)
    sections = (sparts[1..-1] / 2).map do |k2, v2|
      meth = v2.split(/^=== (.+?) ===/)
      k2t = k2[/^(?:The )?([\-\w]+)/, 1]
      h = { title: k2, section: k, description: meth[0], methods: (meth[1..-1] / 2) }
      [k2t, h]
    end
    h = { description: sparts[0], sections: sections, class: "toc" + k.downcase.gsub(/\W+/, '') }
    [k, h]
  end
end

.run(lang = 'English') ⇒ Object



18
19
20
21
22
23
24
# File 'lib/shoes/manual.rb', line 18

def self.run(lang = 'English')
  $lang = lang
  load 'shoes/manual/app.rb'
rescue LoadError
  puts "Wasn't able to load Shoes to run the manual. Does your app have Shoes required?"
  raise
end