templates/default/fulldoc/markdown/setup.rb in yard-markdown-0.2.2 vs templates/default/fulldoc/markdown/setup.rb in yard-markdown-0.3.0
- old
+ new
@@ -106,52 +106,58 @@
<% end %>
<% unless object.root? %>
| **Defined in:** | <%= object.file ? object.file : "(unknown)" %> |
<% end %>
-<%= object.docstring %>
+<%= rdoc_to_md object.docstring %>
-<% if constant_listing.size > 0 %>
-<% groups(constant_listing, "Constants") do |list, name| %>
- # <%= name %>
- <% list.each do |cnst| %>
- ## <%= cnst.name %> [](#<%=aref(cnst)%>)
- <%= cnst.docstring %>
- <% end %>
-<% end %>
-<% end %>
-
<% if (insmeths = public_instance_methods(object)).size > 0 %>
# Public Instance Methods
<% insmeths.each do |item| %>
## <%= item.name(false) %>(<%= item.parameters.map {|p| p.join("") }.join(", ")%>) [](#<%=aref(item)%>)
- <%= item.docstring %>
+ <%= rdoc_to_md item.docstring %>
<% end %>
<% end %>
<% if (pubmeths = public_class_methods(object)).size > 0 %>
# Public Class Methods
<% pubmeths.each do |item| %>
## <%= item.name(false) %>(<%= item.parameters.map {|p| p.join(" ") }.join(", ") %>) [](#<%=aref(item)%>)
- <%= item.docstring %>
+ <%= rdoc_to_md item.docstring %>
<% end %>
<% end %>
<% if (attrs = attr_listing(object)).size > 0 %>
# Attributes
<% attrs.each do |item|%>
## <%= item.name %><%= item.reader? ? "[RW]" : "[R]" %> [](#<%=aref(item)%>)
- <%= item.docstring %>
+ <%= rdoc_to_md item.docstring %>
<% end %>
<% end %>
- '.gsub(/^ /, ""),
- trim_mode: "%<>",
- )
+
+<% if constant_listing.size > 0 %>
+<% groups(constant_listing, "Constants") do |list, name| %>
+ # <%= name %>
+ <% list.each do |cnst| %>
+ ## <%= cnst.name %> [](#<%=aref(cnst)%>)
+ <%= rdoc_to_md cnst.docstring %>
+
+ <% end %>
+<% end %>
+<% end %>
+ ', trim_mode: "%<>")
+
template.result(binding)
+end
+
+require 'rdoc'
+
+def rdoc_to_md(docstring)
+ RDoc::Markup::ToMarkdown.new.convert(docstring)
end
def aref(object)
if object.type == :constant
"constant-#{object.name(false)}"