Module: LabClient::Docs

Included in:
Common, Generator::GeneratorDocs, Klass, Overview, Search
Defined in:
lib/labclient/docs.rb

Overview

Shared Methods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.docsObject



13
14
15
# File 'lib/labclient/docs.rb', line 13

def self.docs
  @docs
end

.jsonObject



9
10
11
# File 'lib/labclient/docs.rb', line 9

def self.json
  @docs.to_json
end

Instance Method Details

#demo(value) ⇒ Object



56
57
58
59
# File 'lib/labclient/docs.rb', line 56

def demo(value)
  @result[:demo_url] = "https://asciinema.org/a/#{value}.js"
  @result[:demo] = "<script id='asciicast-#{value}' src='#{@result[:demo_url]}' data-autoplay='true' data-loop='true' async></script>"
end

#desc(value) ⇒ Object



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

def desc(value)
  @result[:desc] = value
end

#doc(subgroup) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/labclient/docs.rb', line 94

def doc(subgroup)
  @result = {}
  yield

  # Turn Class name into friendly name. Split multiple words
  @group = group_name

  # Docs Navigation Helper
  navigation(subgroup)

  # @result[:name] = name
  Docs.docs[@group] ||= {}
  Docs.docs[@group][subgroup] ||= []
  Docs.docs[@group][subgroup].push @result
end

#example(value) ⇒ Object



61
62
63
# File 'lib/labclient/docs.rb', line 61

def example(value)
  @result[:example] = value
end

#group_nameObject

Allow for Custom Group Name Overrides



75
76
77
# File 'lib/labclient/docs.rb', line 75

def group_name
  @group_name || name.split('::', 2).last.split(/(?=[A-Z])/).join(' ')
end

#help(&block) ⇒ Object

Klass Helper



29
30
31
32
33
34
35
# File 'lib/labclient/docs.rb', line 29

def help(&block)
  # require 'active_support/inflector'
  @group_name ||= group_name.pluralize
  doc 'Reference' do
    block.call
  end
end

#markdown(value) ⇒ Object



47
48
49
50
# File 'lib/labclient/docs.rb', line 47

def markdown(value)
  require 'kramdown' unless defined? Kramdown
  @result[:markdown] = Kramdown::Document.new(value).to_html
end

Helper to Make navigation rendered out once rather than evaluated on Ember



80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/labclient/docs.rb', line 80

def navigation(subgroup)
  # Group
  nav = @group.gsub(' ', '_')

  # Subgroup
  subnav = subgroup.gsub(' ', '_')

  # Title
  subnav += "_#{@result[:title].gsub(' ', '_')}" if @result.key? :title

  @result[:nav] = nav
  @result[:nav] += "-#{subnav}" if subnav
end

#option(name, text) ⇒ Object



69
70
71
72
# File 'lib/labclient/docs.rb', line 69

def option(name, text)
  @result[:options] ||= []
  @result[:options].push(name: name, text: text)
end

#result(value) ⇒ Object



65
66
67
# File 'lib/labclient/docs.rb', line 65

def result(value)
  @result[:result] = value
end

#subtitle(value) ⇒ Object



43
44
45
# File 'lib/labclient/docs.rb', line 43

def subtitle(value)
  @result[:subtitle] = value
end

#title(value) ⇒ Object


DSL Helpers



39
40
41
# File 'lib/labclient/docs.rb', line 39

def title(value)
  @result[:title] = value
end