Module: Cocoadex

Defined in:
lib/cocoadex/model.rb,
lib/cocoadex.rb,
lib/cocoadex/parser.rb,
lib/cocoadex/keyword.rb,
lib/cocoadex/version.rb,
lib/cocoadex/tokenizer.rb,
lib/cocoadex/serializer.rb,
lib/cocoadex/models/class.rb,
lib/cocoadex/docset_helper.rb,
lib/cocoadex/models/docset.rb,
lib/cocoadex/models/entity.rb,
lib/cocoadex/models/method.rb,
lib/cocoadex/models/element.rb,
lib/cocoadex/models/callback.rb,
lib/cocoadex/models/constant.rb,
lib/cocoadex/models/function.rb,
lib/cocoadex/models/property.rb,
lib/cocoadex/models/data_type.rb,
lib/cocoadex/models/parameter.rb,
lib/cocoadex/models/generic_ref.rb,
lib/cocoadex/models/result_code.rb,
lib/cocoadex/models/seq_node_element.rb,
lib/cocoadex/tools/completion_helper.rb,
lib/cocoadex/models/nested_node_element.rb

Overview

Defined Under Namespace

Classes: Callback, Class, CompletionHelper, Constant, ConstantGroup, DataType, DocSet, DocSetHelper, Element, Entity, Function, GenericRef, Keyword, Method, Model, NestedNodeElement, Parameter, Parser, Property, ResultCode, SequentialNodeElement, Serializer, Tokenizer

Constant Summary collapse

CONFIG_DIR =
File.expand_path("~/.cocoadex")
VERSION =
"1.6"

Class Method Summary collapse

Class Method Details

.config_file(subpath) ⇒ Object

path to a file in the default configuration directory



52
53
54
# File 'lib/cocoadex.rb', line 52

def self.config_file subpath
  File.expand_path(File.join(Cocoadex::CONFIG_DIR,subpath))
end

.indent(text, level = 2) ⇒ Object

add leading whitespace to lines



57
58
59
# File 'lib/cocoadex.rb', line 57

def self.indent text, level=2
  text.split("\n").collect {|row| "#{' '*level}#{row}"}.join("\n" )
end

.search(term, load_first = false) ⇒ Object

output documentation text for a given search term



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/cocoadex.rb', line 22

def self.search term, load_first=false
  term = term.strip
  unless term.empty?
    objects = Keyword.find(term)
    if objects.size == 0
      puts "No matches found"
    elsif objects.size == 1 or load_first
      puts objects.first.print
    else
      template = IO.read(view_path('multiple'))
      puts ERB.new(template, nil, '<>').result(binding)
    end
  end
end

.trailing_indent(text, base_level = 2, inside_level = 4) ⇒ Object

add leading whitespace to lines, increasing indent after the first line



63
64
65
66
67
68
# File 'lib/cocoadex.rb', line 63

def self.trailing_indent text, base_level=2, inside_level=4
  text.split("\n").each_with_index.collect do |row, index|
    level = index == 0 ? base_level : inside_level
    "#{' '*level}#{row}"
  end.join("\n")
end

.view_path(name) ⇒ Object

retrieve a view template by name



47
48
49
# File 'lib/cocoadex.rb', line 47

def self.view_path name
  File.join(File.dirname(__FILE__),'..','views',"#{name}.erb")
end

.widthObject

The maximum line width



38
39
40
# File 'lib/cocoadex.rb', line 38

def self.width
  Bri.width
end

.width=(width) ⇒ Object



42
43
44
# File 'lib/cocoadex.rb', line 42

def self.width= width
  Bri.width = width
end