From 56eb71ca1fc3119a8f4db7cc6ed1efa6e67fb718 Mon Sep 17 00:00:00 2001 From: Richard Pijnenburg Date: Mon, 3 Nov 2014 14:10:53 +0000 Subject: [PATCH] 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 --- docs/asciidocgen.rb | 19 +++++++++++++------ docs/plugin-synopsis.asciidoc.erb | 3 +-- lib/logstash/runner.rb | 16 ++++++++++++++++ logstash.gemspec | 1 - 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/docs/asciidocgen.rb b/docs/asciidocgen.rb index ec7cbba5d..27745ff93 100644 --- a/docs/asciidocgen.rb +++ b/docs/asciidocgen.rb @@ -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) diff --git a/docs/plugin-synopsis.asciidoc.erb b/docs/plugin-synopsis.asciidoc.erb index 7e1efd892..726ea3210 100644 --- a/docs/plugin-synopsis.asciidoc.erb +++ b/docs/plugin-synopsis.asciidoc.erb @@ -8,8 +8,7 @@ -%> <%= " " if section == "codec" %> <%= name %> => ... <% end -%> -<%= " " if section == "codec" %> } - +<%= " " if section == "codec" %>} -------------------------- [cols="<,<,<, 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) diff --git a/logstash.gemspec b/logstash.gemspec index 50ae8ce78..761be9f59 100644 --- a/logstash.gemspec +++ b/logstash.gemspec @@ -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"