Module: RocketDocs

Defined in:
lib/rocket_docs.rb,
lib/rocket_docs/engine.rb,
lib/rocket_docs/parser.rb,
lib/rocket_docs/router.rb,
lib/rocket_docs/version.rb,
lib/rocket_docs/documentation.rb,
lib/rocket_docs/documentation/action.rb,
lib/rocket_docs/documentation/controller.rb,
app/helpers/rocket_docs/application_helper.rb,
app/controllers/rocket_docs/application_controller.rb

Defined Under Namespace

Modules: ApplicationHelper, Parser, Router Classes: ApplicationController, Documentation, Engine

Constant Summary collapse

VERSION =
'0.0.8'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.descriptionObject

Returns the value of attribute description.



12
13
14
# File 'lib/rocket_docs.rb', line 12

def description
  @description
end

.titleObject

Returns the value of attribute title.



11
12
13
# File 'lib/rocket_docs.rb', line 11

def title
  @title
end

.urlObject

Returns the value of attribute url.



10
11
12
# File 'lib/rocket_docs.rb', line 10

def url
  @url
end

Class Method Details

.config(&block) ⇒ Object



14
15
16
# File 'lib/rocket_docs.rb', line 14

def config(&block)
  block.call(self)
end

.documentationObject



18
19
20
21
22
# File 'lib/rocket_docs.rb', line 18

def documentation
  Router.api_full.map do |version, controller|
    Documentation.new(version, controller)
  end
end

.documentation_for_files(files, version_name = 'Unknown') ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rocket_docs.rb', line 28

def documentation_for_files(files, version_name = 'Unknown')
  fake_controlers = files.map do |file|
    fake_controller = {
      path: file,
      actions: Hash[
        Parser.method_comments(file).keys.map { |m, _c| [m, []] }
      ]
    }
    [File.basename(file, '.rb'), fake_controller]
  end
  Documentation.new(version_name, Hash[fake_controlers])
end

.documentation_for_version(version) ⇒ Object



24
25
26
# File 'lib/rocket_docs.rb', line 24

def documentation_for_version(version)
  Documentation.new(version.to_i, Router.api_full[version.to_i])
end

.format_string(string) ⇒ Object



41
42
43
44
# File 'lib/rocket_docs.rb', line 41

def format_string(string)
  return unless string
  CGI.escapeHTML(string).gsub("\n", '<br>').html_safe
end