Class: PodSections

Inherits:
AbstractIndex show all
Defined in:
lib/langhelp/lh_perl.rb

Constant Summary

Constants inherited from AbstractIndex

AbstractIndex::SPACES

Constants included from LocalVariables

LocalVariables::ANCHOR_BEGIN, LocalVariables::ANCHOR_END

Constants included from KanjiConverter

KanjiConverter::KCONVERTERS

Instance Attribute Summary

Attributes inherited from AbstractIndex

#arg1, #conf, #title

Instance Method Summary collapse

Methods inherited from AbstractIndex

#initialize, #output_title

Methods included from LocalVariables

#insert_local_variables

Methods included from FilenameString

#abbreviate_filename, #abbreviate_filename!, #normalize_filename!

Methods included from KanjiConverter

#encoding, #kconv

Methods included from MkArray

#mkarray

Methods included from EmacsLispString

#lisp_dump_string

Constructor Details

This class inherits a constructor from AbstractIndex

Instance Method Details

#init(x = {}) ⇒ Object



22
23
24
25
# File 'lib/langhelp/lh_perl.rb', line 22

def init(x={})
  @perl_pod = x[:perl_pod]
  normalize_filename! @perl_pod
end

#process_pod(pod_source) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/langhelp/lh_perl.rb', line 27

def process_pod(pod_source)
  @sections = []

  heads = {}
  head_order = []
  head = nil
  pod_source.split(/\n/).each do |line|
    case line
    when /^=head\d (.+)$/
      head = $1
      heads[head] = []
      head_order << head
    when /^\s+(perl\w+)\t+(.+)$/
      heads[head] << [$1, $2]
    end
  end

  head_order.each do |head|
    heads[head].each do |pod, desc|
      #printf "%-20s %s\n", pod, desc
      @sections << [head, pod, desc]
    end
  end
end

#to_e(out) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/langhelp/lh_perl.rb', line 52

def to_e(out)
  process_pod(File.read(@perl_pod))
  @sections.each do |head, pod, desc|
    out << format("# %-15s : %s / %-40s#{SPACES}(lh-podsections %s)\n",
                  pod, head, desc, lisp_dump_string(pod))
  end
end