- get docs generating for codecs

This commit is contained in:
Jordan Sissel 2013-08-27 01:14:48 +00:00
parent 5808351bea
commit 695a0a503a
4 changed files with 24 additions and 28 deletions

View file

@ -17,7 +17,7 @@ ELASTICSEARCH=vendor/jar/elasticsearch-$(ELASTICSEARCH_VERSION)
GEOIP=vendor/geoip/GeoLiteCity.dat
GEOIP_URL=http://logstash.objects.dreamhost.com/maxmind/GeoLiteCity-2013-01-18.dat.gz
KIBANA_URL=https://github.com/elasticsearch/kibana/archive/master.tar.gz
PLUGIN_FILES=$(shell git ls-files | egrep '^lib/logstash/(inputs|outputs|filters)/[^/]+$$' | egrep -v '/(base|threadable).rb$$|/inputs/ganglia/')
PLUGIN_FILES=$(shell git ls-files | egrep '^lib/logstash/(inputs|outputs|filters|codecs)/[^/]+$$' | egrep -v '/(base|threadable).rb$$|/inputs/ganglia/')
QUIET=@
WGET=$(shell which wget 2>/dev/null)
@ -276,7 +276,7 @@ docgen: $(addprefix build/docs/,$(subst lib/logstash/,,$(subst .rb,.html,$(PLUGI
build/docs: build
-$(QUIET)mkdir $@
build/docs/inputs build/docs/filters build/docs/outputs: | build/docs
build/docs/inputs build/docs/filters build/docs/outputs build/docs/codecs: | build/docs
-$(QUIET)mkdir $@
# bluecloth gem doesn't work on jruby. Use ruby.
@ -292,6 +292,9 @@ build/docs/outputs/%.html: lib/logstash/outputs/%.rb docs/docgen.rb docs/plugin-
$(QUIET)ruby docs/docgen.rb -o build/docs $<
$(QUIET)sed -i -re 's/%VERSION%/$(VERSION)/g' $@
$(QUIET)sed -i -re 's/%ELASTICSEARCH_VERSION%/$(ELASTICSEARCH_VERSION)/g' $@
build/docs/codecs/%.html: lib/logstash/codecs/%.rb docs/docgen.rb docs/plugin-doc.html.erb | build/docs/codecs
$(QUIET)ruby docs/docgen.rb -o build/docs $<
$(QUIET)sed -i -re 's/%VERSION%/$(VERSION)/g' $@
build/docs/%: docs/% lib/logstash/version.rb Makefile
@echo "Copying $< (to $@)"

View file

@ -8,6 +8,7 @@ $: << File.join(File.dirname(__FILE__), "..", "lib")
require "logstash/config/mixin"
require "logstash/inputs/base"
require "logstash/codecs/base"
require "logstash/filters/base"
require "logstash/outputs/base"
require "logstash/version"
@ -18,7 +19,7 @@ class LogStashConfigDocGenerator
def initialize
@rules = {
COMMENT_RE => lambda { |m| add_comment(m[1]) },
/^ *class.*< *LogStash::(Outputs|Filters|Inputs)::(Base|Threadable)/ => \
/^ *class.*< *LogStash::(Outputs|Filters|Inputs|Codecs)::(Base|Threadable)/ => \
lambda { |m| set_class_description },
/^ *config +[^=].*/ => lambda { |m| add_config(m[0]) },
/^ *milestone .*/ => lambda { |m| set_milestone(m[0]) },
@ -184,6 +185,8 @@ class LogStashConfigDocGenerator
section = "filter"
elsif klass.ancestors.include?(LogStash::Outputs::Base)
section = "output"
elsif klass.ancestors.include?(LogStash::Codecs::Base)
section = "codec"
end
template_file = File.join(File.dirname(__FILE__), "plugin-doc.html.erb")
@ -199,6 +202,9 @@ class LogStashConfigDocGenerator
klassname = LogStash::Config::Registry.registry[@name].to_s
name = @name
synopsis_file = File.join(File.dirname(__FILE__), "plugin-synopsis.html.erb")
synopsis = ERB.new(File.new(synopsis_file).read, nil, "-").result(binding)
if settings[:output]
dir = File.join(settings[:output], section + "s")
path = File.join(dir, "#{name}.html")

View file

@ -17,6 +17,7 @@ end # def plugins
basedir = ARGV[0]
docs = {
"inputs" => plugins(File.join(basedir, "inputs/*.html")),
"codecs" => plugins(File.join(basedir, "codecs/*.html")),
"filters" => plugins(File.join(basedir, "filters/*.html")),
"outputs" => plugins(File.join(basedir, "outputs/*.html")),
}

View file

@ -29,33 +29,19 @@ This plugin provides the following flags:
This is what it might look like in your config file:
<pre><code><%= section %> {
<%= name %> {
<% sorted_attributes.each do |name, config|
next if config[:deprecated]
if config[:validate].is_a?(Array)
annotation = "string, one of #{config[:validate].inspect}"
elsif config[:validate] == :path
annotation = "a valid filesystem path"
else
annotation = "#{config[:validate]}"
end
if name.is_a?(Regexp)
name = "/" + name.to_s.gsub(/^\(\?-mix:/, "").gsub(/\)$/, "") + "/"
end
if config[:required]
annotation += " (required)"
else
annotation += " (optional)"
end
annotation += ", default: #{config[:default].inspect}" if config.include?(:default)
-%>
<a href="#<%= name %>"><%= name %></a> => ... # <%= annotation %>
<% end -%>
<pre><code><% if section == "codec" -%>
# with an input plugin:
# you can also use this codec with an output.
input {
file {
codec =&gt; <%= synopsis.split("\n").map { |l| " #{l}" }.join("\n") %>
}
}
</code></pre>
<% else -%>
<%= section %> {
<%= synopsis %>
}
<% end -%></code></pre>
<h3> Details </h3>