mirror of
https://github.com/elastic/logstash.git
synced 2025-04-25 07:07:54 -04:00
Some documentation generation fixes
- Add docgen command to use internal libraries - Fix loading of base files due to plugin path changes - Fix loading of jar dependency files - Remove kramdown gem and actions - Cleanup the generated synopsis a bit Fixes #2009
This commit is contained in:
parent
03b7f57c01
commit
ecc2628cb1
4 changed files with 30 additions and 9 deletions
|
@ -1,7 +1,6 @@
|
||||||
require "rubygems"
|
require "rubygems"
|
||||||
require "erb"
|
require "erb"
|
||||||
require "optparse"
|
require "optparse"
|
||||||
require "kramdown" # markdown parser
|
|
||||||
|
|
||||||
$: << Dir.pwd
|
$: << Dir.pwd
|
||||||
$: << File.join(File.dirname(__FILE__), "..", "lib")
|
$: << File.join(File.dirname(__FILE__), "..", "lib")
|
||||||
|
@ -84,7 +83,7 @@ class LogStashConfigAsciiDocGenerator
|
||||||
# are gone from logstash.
|
# are gone from logstash.
|
||||||
name = name.to_s unless name.is_a?(Regexp)
|
name = name.to_s unless name.is_a?(Regexp)
|
||||||
|
|
||||||
description = Kramdown::Document.new(@comments.join("\n")).to_kramdown
|
description = @comments.join("\n")
|
||||||
@attributes[name][:description] = description
|
@attributes[name][:description] = description
|
||||||
clear_comments
|
clear_comments
|
||||||
end # def add_config
|
end # def add_config
|
||||||
|
@ -156,24 +155,32 @@ class LogStashConfigAsciiDocGenerator
|
||||||
|
|
||||||
# Loading the file will trigger the config dsl which should
|
# Loading the file will trigger the config dsl which should
|
||||||
# collect all the config settings.
|
# collect all the config settings.
|
||||||
|
|
||||||
|
# include the plugin lib dir for loading specific files
|
||||||
|
|
||||||
|
$: << File.join(File.dirname(file), "..", "..")
|
||||||
|
# include the lib dir of the plugin it self for any local dependencies
|
||||||
load file
|
load file
|
||||||
|
|
||||||
|
# Get the correct base path
|
||||||
|
base = File.join(LogStash::Environment::LOGSTASH_HOME,'lib/logstash', file.split("/")[-2])
|
||||||
|
|
||||||
# parse base first
|
# parse base first
|
||||||
parse(File.new(File.join(File.dirname(file), "base.rb"), "r").read)
|
parse(File.new(File.join(base, "base.rb"), "r").read)
|
||||||
|
|
||||||
# Now parse the real library
|
# Now parse the real library
|
||||||
code = File.new(file).read
|
code = File.new(file).read
|
||||||
|
|
||||||
# inputs either inherit from Base or Threadable.
|
# inputs either inherit from Base or Threadable.
|
||||||
if code =~ /\< LogStash::Inputs::Threadable/
|
if code =~ /\< LogStash::Inputs::Threadable/
|
||||||
parse(File.new(File.join(File.dirname(file), "threadable.rb"), "r").read)
|
parse(File.new(File.join(base, "threadable.rb"), "r").read)
|
||||||
end
|
end
|
||||||
|
|
||||||
if code =~ /include LogStash::PluginMixins/
|
if code =~ /include LogStash::PluginMixins/
|
||||||
mixin = code.gsub(/.*include LogStash::PluginMixins::(\w+)\s.*/m, '\1')
|
mixin = code.gsub(/.*include LogStash::PluginMixins::(\w+)\s.*/m, '\1')
|
||||||
mixin.gsub!(/(.)([A-Z])/, '\1_\2')
|
mixin.gsub!(/(.)([A-Z])/, '\1_\2')
|
||||||
mixin.downcase!
|
mixin.downcase!
|
||||||
parse(File.new(File.join(File.dirname(file), "..", "plugin_mixins", "#{mixin}.rb")).read)
|
parse(File.new(File.join(base, "..", "plugin_mixins", "#{mixin}.rb")).read)
|
||||||
end
|
end
|
||||||
|
|
||||||
parse(code)
|
parse(code)
|
||||||
|
@ -202,7 +209,7 @@ class LogStashConfigAsciiDocGenerator
|
||||||
is_contrib_plugin = @contrib_list.include?(file)
|
is_contrib_plugin = @contrib_list.include?(file)
|
||||||
|
|
||||||
# descriptions are assumed to be markdown
|
# descriptions are assumed to be markdown
|
||||||
description = Kramdown::Document.new(@class_description).to_kramdown
|
description = @class_description
|
||||||
|
|
||||||
klass.get_config.each do |name, settings|
|
klass.get_config.each do |name, settings|
|
||||||
@attributes[name].merge!(settings)
|
@attributes[name].merge!(settings)
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
<%= " " if section == "codec" %> <%= name %> => ...
|
<%= " " if section == "codec" %> <%= name %> => ...
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<%= " " if section == "codec" %>}
|
<%= " " if section == "codec" %>}
|
||||||
|
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
[cols="<,<,<,<m",options="header",]
|
[cols="<,<,<,<m",options="header",]
|
||||||
|
|
|
@ -120,6 +120,22 @@ class LogStash::Runner
|
||||||
require "pry"
|
require "pry"
|
||||||
return binding.pry
|
return binding.pry
|
||||||
end,
|
end,
|
||||||
|
"docgen" => lambda do
|
||||||
|
require 'docs/asciidocgen'
|
||||||
|
opts = OptionParser.new
|
||||||
|
settings = {}
|
||||||
|
opts.on("-o DIR", "--output DIR",
|
||||||
|
"Directory to output to; optional. If not specified,"\
|
||||||
|
"we write to stdout.") do |val|
|
||||||
|
settings[:output] = val
|
||||||
|
end
|
||||||
|
args = opts.parse(ARGV)
|
||||||
|
docs = LogStashConfigAsciiDocGenerator.new
|
||||||
|
args.each do |arg|
|
||||||
|
docs.generate(arg, settings)
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end,
|
||||||
"plugin" => lambda do
|
"plugin" => lambda do
|
||||||
require 'logstash/pluginmanager'
|
require 'logstash/pluginmanager'
|
||||||
plugin_manager = LogStash::PluginManager::Main.new($0)
|
plugin_manager = LogStash::PluginManager::Main.new($0)
|
||||||
|
|
|
@ -120,7 +120,6 @@ Gem::Specification.new do |gem|
|
||||||
|
|
||||||
# Development Deps
|
# Development Deps
|
||||||
gem.add_development_dependency "coveralls"
|
gem.add_development_dependency "coveralls"
|
||||||
gem.add_development_dependency "kramdown" #(MIT license) pure-ruby markdown parser
|
|
||||||
|
|
||||||
# Jenkins Deps
|
# Jenkins Deps
|
||||||
gem.add_runtime_dependency "ci_reporter", "1.9.3"
|
gem.add_runtime_dependency "ci_reporter", "1.9.3"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue