Class: MountDoc::MountDocController

Inherits:
ApplicationController show all
Includes:
MountDocHelper
Defined in:
app/controllers/mount_doc/mount_doc_controller.rb

Constant Summary

Constants included from MountDocHelper

MountDoc::MountDocHelper::HTTP_Methods

Instance Method Summary collapse

Methods included from MountDocHelper

#actions, #controllers, #doc_dir, #files, #markdown, #markup, #models, #mount_doc_config, #rdoc, #routes, #routes_for, #syntaxhighlight

Instance Method Details

#action_docObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/mount_doc/mount_doc_controller.rb', line 32

def action_doc
  @controller_name = params[:ctrl_id]
  @action_name = params[:id]

  file_name = File.join(::Rails.root, 'app/controllers', "#{@controller_name.gsub('::', '/')}_controller.rb")
  unless File.exists?(file_name)
    not_found
    return
  end

  @controller_document = MountDoc::Document.new(:controller, @controller_name).doc_object
  @document = @controller_document.meths.select{|meth| meth.name.to_s == @action_name.to_s }.first

  unless @document
    not_found
    return
  end

  @page_title = @controller_name.gsub('::', '/').camelize + '#' + @action_name
end

#controller_docObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/mount_doc/mount_doc_controller.rb', line 19

def controller_doc
  @controller_name = params[:id]

  file_name = File.join(::Rails.root, 'app/controllers', "#{@controller_name.gsub('::', '/')}_controller.rb")
  unless File.exists?(file_name)
    not_found
    return
  end

  @document = MountDoc::Document.new(:controller, @controller_name).doc_object
  @page_title = @controller_name.gsub('::', '/').camelize
end

#file_docObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'app/controllers/mount_doc/mount_doc_controller.rb', line 57

def file_doc
  file_name = params[:id]
  file_name += '.' + params[:format] if params.has_key?(:format)
  file_name = File.join(::Rails.root, MountDoc::Config.doc_file_path, file_name)

  if File.exists?(file_name)
    @page_title = File.basename(file_name)
    render text: GitHub::Markup.render(file_name), layout: true
  else
    not_found
    return
  end

end

#indexObject



11
12
13
14
15
16
17
# File 'app/controllers/mount_doc/mount_doc_controller.rb', line 11

def index
  @page_title = 'Index'

  readme_file = Dir[File.join(::Rails.root, '/README.*')].first

  render text: GitHub::Markup.render(readme_file), layout: true
end

#model_docObject



53
54
55
# File 'app/controllers/mount_doc/mount_doc_controller.rb', line 53

def model_doc

end