Add API example generator via tent-apidoc
This commit is contained in:
parent
89e20162ed
commit
9b4d94cd2f
4 changed files with 138 additions and 8 deletions
16
lib/api_example.rb
Normal file
16
lib/api_example.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
require 'tent-apidoc'
|
||||
|
||||
class ApiExampleFilter < Nanoc::Filter
|
||||
identifier :api_example
|
||||
type :text
|
||||
|
||||
def run(content, params={})
|
||||
content.gsub(/\{(\w+) example\}/) { api_example($1) }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def api_example(id)
|
||||
TentApiDoc.examples[id.to_sym]
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue