Sha256: e2f271214daaf0ef6fb48b57fe6dcd0365d996cacbc3c4398ce9481e485bdcb5
Contents?: true
Size: 1.91 KB
Versions: 4
Compression:
Stored size: 1.91 KB
Contents
require 'mount_doc' require 'slim' require 'github/markup' module MountDoc class MountDocController < ApplicationController include MountDocHelper layout 'mount_doc' def index @page_title = 'Index' readme_file = Dir[File.join(::Rails.root, '/README.*')].first render text: GitHub::Markup.render(readme_file), layout: true end 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 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 def model_doc end 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 private def not_found render :not_found, status: 404 end end end
Version data entries
4 entries across 4 versions & 1 rubygems