mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -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
a6c7a69b5e
commit
56eb71ca1f
4 changed files with 30 additions and 9 deletions
|
@ -1,7 +1,6 @@
|
|||
require "rubygems"
|
||||
require "erb"
|
||||
require "optparse"
|
||||
require "kramdown" # markdown parser
|
||||
|
||||
$: << Dir.pwd
|
||||
$: << File.join(File.dirname(__FILE__), "..", "lib")
|
||||
|
@ -84,7 +83,7 @@ class LogStashConfigAsciiDocGenerator
|
|||
# are gone from logstash.
|
||||
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
|
||||
clear_comments
|
||||
end # def add_config
|
||||
|
@ -156,24 +155,32 @@ class LogStashConfigAsciiDocGenerator
|
|||
|
||||
# Loading the file will trigger the config dsl which should
|
||||
# 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
|
||||
|
||||
# Get the correct base path
|
||||
base = File.join(LogStash::Environment::LOGSTASH_HOME,'lib/logstash', file.split("/")[-2])
|
||||
|
||||
# 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
|
||||
code = File.new(file).read
|
||||
|
||||
# inputs either inherit from Base or 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
|
||||
|
||||
if code =~ /include LogStash::PluginMixins/
|
||||
mixin = code.gsub(/.*include LogStash::PluginMixins::(\w+)\s.*/m, '\1')
|
||||
mixin.gsub!(/(.)([A-Z])/, '\1_\2')
|
||||
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
|
||||
|
||||
parse(code)
|
||||
|
@ -202,7 +209,7 @@ class LogStashConfigAsciiDocGenerator
|
|||
is_contrib_plugin = @contrib_list.include?(file)
|
||||
|
||||
# descriptions are assumed to be markdown
|
||||
description = Kramdown::Document.new(@class_description).to_kramdown
|
||||
description = @class_description
|
||||
|
||||
klass.get_config.each do |name, settings|
|
||||
@attributes[name].merge!(settings)
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
-%>
|
||||
<%= " " if section == "codec" %> <%= name %> => ...
|
||||
<% end -%>
|
||||
<%= " " if section == "codec" %> }
|
||||
|
||||
<%= " " if section == "codec" %>}
|
||||
--------------------------
|
||||
|
||||
[cols="<,<,<,<m",options="header",]
|
||||
|
|
|
@ -120,6 +120,22 @@ class LogStash::Runner
|
|||
require "pry"
|
||||
return binding.pry
|
||||
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
|
||||
require 'logstash/pluginmanager'
|
||||
plugin_manager = LogStash::PluginManager::Main.new($0)
|
||||
|
|
|
@ -120,7 +120,6 @@ Gem::Specification.new do |gem|
|
|||
|
||||
# Development Deps
|
||||
gem.add_development_dependency "coveralls"
|
||||
gem.add_development_dependency "kramdown" #(MIT license) pure-ruby markdown parser
|
||||
|
||||
# Jenkins Deps
|
||||
gem.add_runtime_dependency "ci_reporter", "1.9.3"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue