Skip to content

Instantly share code, notes, and snippets.

@amireh
Last active December 12, 2015 01:18
Show Gist options
  • Select an option

  • Save amireh/4690058 to your computer and use it in GitHub Desktop.

Select an option

Save amireh/4690058 to your computer and use it in GitHub Desktop.
The template overrides and the AppendixObject source.
<h3><%= object.title %></h3>
<%= yieldall :index => 0 %>
def init
sections :appendix_entry, [T('docstring')]
end
def appendix_entry
erb :entry
end
<div class="appendix">
<h2>Appendix</h2>
# perhaps i should select the :appendix children of object instead of using the Registry?
<% YARD::Registry.all(:appendix).select { |o| o.namespace == owner }.each do |o| %>
<div class="appendix_entry">
<%= o.format(:format => :html) %>
</div>
<% end %>
</div>
include T('default/module/html')
def init
super
sections.push(:appendix, [ T('docstring') ])
end
def appendix(*args)
erb(:appendix)
end
require 'yard/code_objects/base'
require 'yard/code_objects/class_object'
require 'yard/code_objects/method_object'
module YARD
module CodeObjects
class AppendixObject < Base
attr_reader :title, :body, :name
# def type; "appendix" end
def initialize(ns, docstring)
@name = "Appendix_#{index_in_namespace(ns)}"
super(ns, @name.to_sym)
@type = :appendix
# extract title from the first line
@title =
docstring.lines.any? &&
docstring.lines.first.gsub(/\s*@appendix/, '').strip
@body =
docstring.
split("\n")[1..-1].
# reject { |s| s.empty? }[1..-1].
# collect { |s| s.strip }.
join("\n")
@docstring = DocstringParser.new.parse(@body).to_docstring
end
def inspect
"#<yardoc #{type} #{path} #{title}>"
end
def to_s
@title
end
private
def sanitize_title
end
def index_in_namespace(ns)
@@indexes ||= {}
@@indexes[ns.to_s] ||= 0
@@indexes[ns.to_s] += 1
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment