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



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

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



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

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

#doc(subgroup) ⇒ Object



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/labclient/docs.rb', line 107

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



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

def example(value)
  # Ensure there is a new line for the markdown and no extras
  @result[:example] = value.ends_with?("\n") ? value : "#{value}\n"
end

#group_nameObject

Allow for Custom Group Name Overrides Ruby warning of uninitialized variables



84
85
86
87
88
89
90
# File 'lib/labclient/docs.rb', line 84

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

#help(&block) ⇒ Object

Replacing with Docusaurus, Using vanilla markdown This isn’t used in the CLI/Pry at all either Klass Helper



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

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

#markdown(value) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/labclient/docs.rb', line 49

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

  # Use Vanilla Markdown
  @result[:markdown] = value
end

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



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

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

Deprecate



77
78
79
80
# File 'lib/labclient/docs.rb', line 77

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

#result(value) ⇒ Object



71
72
73
74
# File 'lib/labclient/docs.rb', line 71

def result(value)
  # Ensure Markdown Ends with a new line
  @result[:result] = value.ends_with?("\n") ? value : "#{value}\n"
end

#subtitle(value) ⇒ Object



45
46
47
# File 'lib/labclient/docs.rb', line 45

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

#title(value) ⇒ Object


DSL Helpers



41
42
43
# File 'lib/labclient/docs.rb', line 41

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