Class: Info
- Inherits:
-
AbstractIndex
- Object
- AbstractIndex
- Info
- Defined in:
- lib/langhelp/parse-info.rb
Defined Under Namespace
Classes: Result
Constant Summary collapse
- NODE_RE =
/^File: (.+?)(?:\.info)?, +Node: (.+?),/
- SECTION_RE =
/^(\*\*\*\*|====|----|\.\.\.\.)/
- INDENTED_RE =
/^ /
- EXTRACT_RE =
/^( -+ .*:|\`.+\'$)/
Constants inherited from AbstractIndex
Constants included from LocalVariables
LocalVariables::ANCHOR_BEGIN, LocalVariables::ANCHOR_END
Constants included from KanjiConverter
Instance Attribute Summary
Attributes inherited from AbstractIndex
Instance Method Summary collapse
Methods inherited from AbstractIndex
Methods included from LocalVariables
Methods included from FilenameString
#abbreviate_filename, #abbreviate_filename!, #normalize_filename!
Methods included from KanjiConverter
Methods included from MkArray
Methods included from EmacsLispString
Constructor Details
This class inherits a constructor from AbstractIndex
Instance Method Details
#init(x) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/langhelp/parse-info.rb', line 38 def init(x) @info_files = arg1 @io = x[:io] @regexp = x[:regexp] || EXTRACT_RE # [in texinfo-4.8/makeinfo/sectioning.c] # /* Organized by level commands. That is, "*" == chapter, "=" == section. */ # static char *scoring_characters = "*=-."; @name = (x[:name] || x[:lang]).to_s @extract = x[:extract] || [:node, :regexp, :section, :description] @results = [] normalize_filename! @info_files end |
#parse ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/langhelp/parse-info.rb', line 92 def parse setup_io #p @io.string.split(/\n/).length lines = @io.read.toeuc.split(/\n/) title_line = nil get_node = @extract.include? :node get_section = @extract.include? :section get_regexp = @extract.include? :regexp get_description = @extract.include? :description lines.each_with_index do |line, i| case line when NODE_RE @info = $1 @node = $2 title_line = i+2 title = lines[title_line] @results << Result.new(@info, @node, nil, title) if get_node when SECTION_RE section_line = i-1 if section_line != title_line @results << Result.new(@info, @node, lines[section_line], nil) if get_section end when @regexp @results << Result.new(@info, @node, line, nil) if get_regexp when /^[\`\w]/ if lines[i+1] =~ INDENTED_RE and get_description @results << Result.new(@info, @node, line, nil) end else end end @parsed = true end |
#to_e(out) ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/langhelp/parse-info.rb', line 129 def to_e(out) parse unless @parsed func = "lh-info" @results.each do |result| book = "(#{result.info})#{result.node}" if result.line out << %Q!# (#{func} #{lisp_dump_string(result.line)}#{SPACES}#{lisp_dump_string(book)})\n! elsif result.title out << %Q!# Node: #{result.title}#{SPACES}(#{func} nil#{SPACES}#{lisp_dump_string(book)})\n! end end end |