Module: EasyApiDoc::ApplicationHelper

Defined in:
app/helpers/easy_api_doc/application_helper.rb

Instance Method Summary collapse

Instance Method Details



18
19
20
# File 'app/helpers/easy_api_doc/application_helper.rb', line 18

def action_link(action)
  api_action_path(:api => action.parents['apiversion'].name, :namespace => action.parents['namespace'].name, :resource => action.parents['resource'].name, :api_action => action.name)
end


6
7
8
# File 'app/helpers/easy_api_doc/application_helper.rb', line 6

def api_link(api)
  api_path(:id => api.name)
end


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/helpers/easy_api_doc/application_helper.rb', line 22

def breadcrumbs(stack)
  crumbs = []
  stack.each do |name, uri|
    if uri
      crumbs << link_to(name, uri)
    else
      crumbs << name
    end
  end

  (:ol, :class => "breadcrumb") do
    output = ""
    crumbs.each do |c|
      output += (:li, c, :class => crumbs.last ? 'active' : nil)
    end
    output.html_safe
  end
end

#contents_for_action(resource, action, attribute_name) ⇒ Object



51
52
53
54
55
56
57
58
59
# File 'app/helpers/easy_api_doc/application_helper.rb', line 51

def contents_for_action(resource, action, attribute_name)
  tree = ['doc', 'api', resource.parents['apiversion'].name, resource.parents['namespace'].name, resource.name, action.name]
  file = File.join(*tree, "#{attribute_name}.md")
  if File.exists?(file)
    GitHub::Markup.render(file, File.read(file)).html_safe
  else
    action.attributes[attribute_name]
  end
end

#contents_for_resource(resource, attribute_name) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'app/helpers/easy_api_doc/application_helper.rb', line 41

def contents_for_resource(resource, attribute_name)
  tree = ['doc', 'api', resource.parents['apiversion'].name, resource.parents['namespace'].name, resource.name]
  file = File.join(*tree, "#{attribute_name}.md")
  if File.exists?(file)
    GitHub::Markup.render(file, File.read(file)).html_safe
  else
    resource.attributes[attribute_name]
  end
end

#example_json(key_json_file) ⇒ Object



61
62
63
64
65
66
67
68
69
# File 'app/helpers/easy_api_doc/application_helper.rb', line 61

def example_json(key_json_file)
  tree = ['doc', 'api', 'examples', 'json']
  file = File.join(*tree, "#{key_json_file}")
  if File.exists?(file)
    File.read(file)
  else
    nil
  end
end


10
11
12
# File 'app/helpers/easy_api_doc/application_helper.rb', line 10

def namespace_link(namespace)
  namespace_path(:api => namespace.parents['apiversion'].name, :namespace => namespace.name)
end


14
15
16
# File 'app/helpers/easy_api_doc/application_helper.rb', line 14

def resource_link(resource)
  resource_path(:api => resource.parents['apiversion'].name, :namespace => resource.parents['namespace'].name, :resource => resource.name)
end