Class: BitClust::RRDParser

Inherits:
Object show all
Includes:
NameUtils, ParseUtils
Defined in:
lib/bitclust/rrdparser.rb

Overview

Parser for Ruby API reference file (refm/api/src/*)

Defined Under Namespace

Classes: Chunk, Context, Signature

Constant Summary

Constants included from NameUtils

NameUtils::CHAR_TO_MARK, NameUtils::CHAR_TO_NAME, NameUtils::CLASS_NAME_RE, NameUtils::CLASS_PATH_RE, NameUtils::CONST_PATH_RE, NameUtils::CONST_RE, NameUtils::GVAR_RE, NameUtils::LIBNAME_RE, NameUtils::MARK_TO_CHAR, NameUtils::MARK_TO_NAME, NameUtils::METHOD_NAME_RE, NameUtils::METHOD_SPEC_RE, NameUtils::MID, NameUtils::NAME_TO_CHAR, NameUtils::NAME_TO_MARK, NameUtils::TYPEMARK_RE

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ParseUtils

#parse_error

Methods included from NameUtils

build_method_id, classid2name, classname2id, classname?, decodeid, decodename_fs, decodename_url, encodeid, encodename_fs, encodename_rdocurl, encodename_url, functionname?, gvarname?, html_filename, libid2name, libname2id, libname?, method_spec?, methodid2classid, methodid2libid, methodid2mname, methodid2specparts, methodid2specstring, methodid2typechar, methodid2typemark, methodid2typename, methodname?, split_method_id, split_method_spec, typechar2mark, typechar2name, typechar?, typemark2char, typemark2name, typemark?, typename2char, typename2mark, typename?

Constructor Details

#initialize(db) ⇒ RRDParser

Returns a new instance of RRDParser.


66
67
68
# File 'lib/bitclust/rrdparser.rb', line 66

def initialize(db)
  @db = db
end

Instance Attribute Details

#dbObject (readonly)

Returns the value of attribute db


69
70
71
# File 'lib/bitclust/rrdparser.rb', line 69

def db
  @db
end

Class Method Details

.parse(s, lib, params = {"version" => "1.9.0"}) ⇒ Object


32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/bitclust/rrdparser.rb', line 32

def RRDParser.parse(s, lib, params = {"version" => "1.9.0"})
  parser = new(MethodDatabase.dummy(params))
  if s.respond_to?(:to_io)
    io = s.to_io
  elsif s.respond_to?(:to_str)
    s1 = s.to_str
    require 'stringio'
    io = StringIO.new(s1)
  else
    io = s
  end
  l = parser.parse(io, lib, params)
  return l, parser.db
end

.parse_stdlib_file(path, params = {"version" => "1.9.0"}) ⇒ Object


27
28
29
30
# File 'lib/bitclust/rrdparser.rb', line 27

def RRDParser.parse_stdlib_file(path, params = {"version" => "1.9.0"})
  parser = new(MethodDatabase.dummy(params))
  parser.parse_file(path, libname(path), params)
end

.split_doc(source) ⇒ Object


47
48
49
50
51
52
53
54
# File 'lib/bitclust/rrdparser.rb', line 47

def RRDParser.split_doc(source)
  if m = /^=(\[a:.*?\])?( +(.*)|([^=].*))\r?\n/.match(source)
    title = $3 || $4
    s = m.post_match
    return title, s
  end
  return ["", source]
end

Instance Method Details

#parse(f, libname, params = {}) ⇒ Object


77
78
79
80
81
82
# File 'lib/bitclust/rrdparser.rb', line 77

def parse(f, libname, params = {})
  @context = Context.new(@db, libname)
  f = LineInput.new(Preprocessor.wrap(f, params))
  do_parse f
  @context.library
end

#parse_file(path, libname, params = {}) ⇒ Object


71
72
73
74
75
# File 'lib/bitclust/rrdparser.rb', line 71

def parse_file(path, libname, params = {})
  fopen(path, 'r:UTF-8') {|f|
    return parse(f, libname, params)
  }
end