lib/rdoc/generator/markdown.rb in rdoc-markdown-0.2.1 vs lib/rdoc/generator/markdown.rb in rdoc-markdown-0.3
- old
+ new
@@ -3,13 +3,12 @@
gem "rdoc"
require "pathname"
require "erb"
require "reverse_markdown"
-require 'extralite'
-require 'active_support/core_ext/string/inflections'
-require 'unindent'
+require "extralite"
+require "unindent"
class RDoc::Generator::Markdown
RDoc::RDoc.add_generator self
##
@@ -93,11 +92,11 @@
##
# This class emits a search index for generated documentation as sqlite database
#
- def emit_sqlite(name="index.db")
+ def emit_sqlite(name = "index.db")
db = Extralite::Database.new("#{output_dir}/#{name}")
db.execute <<-SQL
create table contentIndex (
id INTEGER PRIMARY KEY,
@@ -128,11 +127,11 @@
klass.constants.sort_by { |x| x.name }.each do |const|
result << {
name: "#{klass.full_name}.#{const.name}",
type: "Constant",
- path: "#{turn_to_path(klass.full_name)}##{ActiveSupport::Inflector.parameterize const.name}"
+ path: "#{turn_to_path(klass.full_name)}##{const.name}"
}
end
klass.attributes.sort_by { |x| x.name }.each do |attr|
result << {
@@ -148,23 +147,10 @@
end
end
def emit_classfiles
@classes.each do |klass|
- klass_methods = []
- instance_methods = []
-
- klass.method_list.each do |method|
- next if method.visibility.to_s.eql?("private")
-
- if method.type == "class"
- klass_methods << method
- else
- instance_methods << method
- end
- end
-
template = ERB.new File.read(File.join(TEMPLATE_DIR, "classfile.md.erb"))
out_file = Pathname.new("#{output_dir}/#{turn_to_path klass.full_name}")
out_file.dirname.mkpath
@@ -183,29 +169,25 @@
##
# Converts HTML string into a Markdown string with some cleaning and improvements.
def markdownify(input)
- md= ReverseMarkdown.convert input, github_flavored: true
+ md = ReverseMarkdown.convert input
# unintent multiline strings
md.unindent!
# Replace .html to .md extension in all markdown links
md = md.gsub(/\[(.+)\]\((.+).html(.*)\)/) do |_|
match = Regexp.last_match
"[#{match[1]}](#{match[2]}.md#{match[3]})"
end
-
- # clean up things, to make it look neat.
-
- md.gsub("[↑](#top)", "").lstrip
end
# Aliasing a shorter method name for use in templates
- alias_method :h, :markdownify
+ alias_method :h, :markdownify
##
# Prepares for document generation, by creating required folders and initializing variables.
# Could be called multiple times.
@@ -216,17 +198,7 @@
@output_dir.mkpath
return unless @store
@classes = @store.all_classes_and_modules.sort
- end
-
- ##
- # Return a list of the documented modules sorted by salience first, then
- # by name.
-
- def get_sorted_module_list classes
- classes.select do |klass|
- klass.display?
- end.sort
end
end