Class: SelfDocAPI
Constant Summary
Debci::HTMLHelpers::ICONS
Class Method Summary
collapse
Methods inherited from Debci::App
#get_page_params, get_page_range, #get_page_range, #pagination_params, #refresh!
#expand_pin_packages, #expand_url, #file_link, #history_url, #icon, #package_url, #title_test_trigger_pin
Class Method Details
.doc(d = nil) ⇒ Object
22
23
24
25
|
# File 'lib/debci/api.rb', line 22
def doc(d=nil)
@last_doc = format_doc(d)
@doc ||= []
end
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/debci/api.rb', line 38
def format_doc(text)
return nil unless text
lines = text.lines
if lines.first && lines.first.strip == ""
lines.first.shift
end
lines.first =~ /^\s+/; prefix = ::Regexp.last_match(0)
if prefix
lines.map! do |line|
line.sub(/^#{prefix}/, '')
end
end
formatter = RDoc::Markup::ToHtml.new(RDoc::Options.new, nil)
RDoc::Markdown.parse(lines.join).accept(formatter)
end
|
.get(path, *args) ⇒ Object
54
55
56
57
|
# File 'lib/debci/api.rb', line 54
def get(path, *args)
register_doc('GET', path)
super(path, *args)
end
|
.post(path, *args) ⇒ Object
58
59
60
61
|
# File 'lib/debci/api.rb', line 58
def post(path, *args)
register_doc('POST', path)
super(path, *args)
end
|
.register_doc(method, path) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/debci/api.rb', line 26
def register_doc(method, path)
@last_doc ||= nil
return unless @last_doc
entry = {
method: method,
path: path,
text: @last_doc,
anchor: [method, path].join('_'),
}
@last_doc = nil
doc.push(entry)
end
|