Last active
December 12, 2015 01:18
-
-
Save amireh/4690058 to your computer and use it in GitHub Desktop.
The template overrides and the AppendixObject source.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <h3><%= object.title %></h3> | |
| <%= yieldall :index => 0 %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def init | |
| sections :appendix_entry, [T('docstring')] | |
| end | |
| def appendix_entry | |
| erb :entry | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| include T('default/module/html') | |
| def init | |
| super | |
| sections.push(:appendix, [ T('docstring') ]) | |
| end | |
| def appendix(*args) | |
| erb(:appendix) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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