class RTFDoc::Resource
Constants
- DEFAULT
Attributes
name[R]
sections[R]
Public Class Methods
build(name, paths, endpoints: nil)
click to toggle source
# File lib/rtfdoc.rb, line 323 def self.build(name, paths, endpoints: nil) endpoints ||= DEFAULT desc = nil sections = endpoints.each_with_object([]) do |endpoint, res| if endpoint.is_a?(Hash) n, values = endpoint.each_pair.first next unless n.start_with?('scope|') dir_name = n.slice(6..-1) scope_name = values['title'] || dir_name scoped_endpoints = values['endpoints'] subsections = scoped_endpoints.each_with_object([]) do |e, r| filename = paths.dig(dir_name, e) next unless filename content = File.read(filename) r << Section.new(e, content, resource: name) end res << Scope.new(scope_name, subsections) next res end filename = paths[endpoint] next unless filename content = File.read(filename) if endpoint == 'desc' desc = ResourceDesc.new(name, content) res << desc else res << Section.new(endpoint, content, resource: name) end end desc&.generate_example(sections) Resource.new(name, sections) end
new(name, sections)
click to toggle source
# File lib/rtfdoc.rb, line 366 def initialize(name, sections) @name, @sections = name, sections end
Public Instance Methods
output()
click to toggle source
# File lib/rtfdoc.rb, line 370 def output head, *tail = sections head.include_show_button = true inner = sections.flat_map(&:output).join("\n") %(<section class="head-section">#{inner}</section>) end
Private Instance Methods
human_name()
click to toggle source
# File lib/rtfdoc.rb, line 390 def human_name name.tr('_', ' ').split.map!(&:capitalize).join(' ') end