Skip to content

Commit

Permalink
- generate in format markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
jordansissel committed Apr 7, 2011
1 parent 06a353f commit 6a28e92
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions doc/docgen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,39 @@ def generate(file)
string = File.new(file).read
parse(string)
require file
puts LogStash::Config::Registry.registry[@name]
@settings.each do |name, description|
p name => description
klass = LogStash::Config::Registry.registry[@name]
if klass.ancestors.include?(LogStash::Inputs::Base)
section = "inputs"
elsif klass.ancestors.include?(LogStash::Filters::Base)
section = "filters"
elsif klass.ancestors.include?(LogStash::Outputs::Base)
section = "outputs"
end

# TODO(sissel): probably should use ERB for this.
puts "# " + LogStash::Config::Registry.registry[@name].to_s
puts
puts "Usage example:"
puts
puts [
"#{section} {",
" #{@name} {",
" # ... settings ...",
" }",
"}",
].map { |l| " #{l}" }.join("\n")

# TODO(sissel): include description of this plugin, maybe use
# rdoc to pull this?
@settings.each do |name, config|
puts "## #{name}"
puts
puts config[:description]
puts
puts " * Value expected is: #{config[:validate] or "string"}"
puts " * This is a required setting" if config[:required]
puts " * Default value is: #{config[:default]}" if config.include?(:default)
puts
end
end
end
Expand Down

0 comments on commit 6a28e92

Please sign in to comment.