class MarkdownRubyDocumentation::Generate::Page
Attributes
erb_methods_class[R]
load_path[R]
output_object[R]
subject[R]
subject_location[R]
Public Class Methods
new(subject_class:, subject_location:, methods: [], load_path:, output_object:, erb_methods_class:)
click to toggle source
# File lib/markdown_ruby_documentation/generate.rb, line 68 def initialize(subject_class:, subject_location:, methods: [], load_path:, output_object:, erb_methods_class:) initialize_methods(methods, subject_class, subject_location) @erb_methods_class = erb_methods_class @subject = subject_class @subject_location = subject_location methods = methods @methods = methods @load_path = load_path @output_object = output_object end
Public Instance Methods
call()
click to toggle source
# File lib/markdown_ruby_documentation/generate.rb, line 84 def call methods_pipes = run_pipeline(methods_pipeline) text = run_pipeline(string_pipeline, methods_pipes) output_object.call(name: subject.name, text: text) self end
Private Instance Methods
all_instance_and_class_methods(methods, subject, subject_location)
click to toggle source
# File lib/markdown_ruby_documentation/generate.rb, line 101 def all_instance_and_class_methods(methods, subject, subject_location) native_instance_methods = (subject.instance_methods(false) - Object.instance_methods(false)).concat(subject.private_instance_methods(false) - Object.private_instance_methods(false)) super_instance_methods = (subject.instance_methods(true) - Object.instance_methods(true)).concat(subject.private_instance_methods(true) - Object.private_instance_methods(true)) - native_instance_methods native_klass_methods = (subject.methods(false) - Object.methods(false)).concat(subject.private_methods(false) - Object.private_methods(false)) super_klass_methods = (subject.methods(true) - Object.methods(true)).concat(subject.private_methods(true) - Object.private_methods(true)) - native_klass_methods methods.concat super_instance_methods.reverse.map { |method| InstanceMethod.new("#{subject.name}##{method}", context: subject, visibility: :super, file_path: subject_location) } methods.concat native_instance_methods.map { |method| InstanceMethod.new("#{subject.name}##{method}", context: subject, visibility: :native, file_path: subject_location) } methods.concat super_klass_methods.map { |method| ClassMethod.new("#{subject.name}.#{method}", context: subject, visibility: :super, file_path: subject_location) } methods.concat native_klass_methods.map { |method| ClassMethod.new("#{subject.name}.#{method}", context: subject, visibility: :native, file_path: subject_location) } end
initialize_methods(methods, subject, subject_location)
click to toggle source
# File lib/markdown_ruby_documentation/generate.rb, line 93 def initialize_methods(methods, subject, subject_location) if methods.empty? all_instance_and_class_methods(methods, subject, subject_location) else methods.map! { |method| method.is_a?(Symbol) ? InstanceMethod.new("#{subject.name}##{method}", context: subject, file_path: subject_location) : method } end end
methods_pipeline()
click to toggle source
# File lib/markdown_ruby_documentation/generate.rb, line 112 def methods_pipeline [ TemplateParser.new(subject, @methods), RejectBlankMethod, GitHubLink.new(subject: subject), ConstantsPresenter.new(subject), ClassLevelComment.new(subject), MarkdownPresenter.new(summary: summary, title_key: section_key), ] end
run_pipeline(pipeline, last_result=nil)
click to toggle source
# File lib/markdown_ruby_documentation/generate.rb, line 134 def run_pipeline(pipeline, last_result=nil) last_result ||= pipeline.shift.call pipeline.each do |pipe| last_result = pipe.call(last_result) end last_result end
section_key()
click to toggle source
# File lib/markdown_ruby_documentation/generate.rb, line 142 def section_key subject.name.underscore.gsub("/", "-") end
string_pipeline()
click to toggle source
# File lib/markdown_ruby_documentation/generate.rb, line 123 def string_pipeline [ MethodLinker.new(section_key: section_key, root_path: "./"), RelativeLinkConverter.new(subject: subject), ] end
summary()
click to toggle source
# File lib/markdown_ruby_documentation/generate.rb, line 130 def summary @summary ||= Summary.new(subject: subject, erb_methods_class: erb_methods_class) end