yard_helper.rb in shep-0.2.0.pre.alpha0 vs yard_helper.rb in shep-0.2.1.pre.alpha0
- old
+ new
@@ -4,27 +4,33 @@
class EntityFieldDeclHandler < YARD::Handlers::Ruby::Base #AttributeHandler
handles method_call(:fields)
namespace_only
process do
+ sanitized = {
+ '<' => '<',
+ '>' => '>',
+ }
+
mastotype = namespace.name.to_s.gsub(/_/, '::')
new_docstr = "Ruby object representing a Mastodon `#{mastotype}` object:\n\n"
nnt = Object.const_get(namespace.path).send(:names_and_types)
nnt.each do |name, type|
# We generate the argument list in Markdown because I am
# completely done fighting with YARD to get it to recognize my
# 'attr' tags.
- new_docstr += " * #{name} (#{type.to_yard_s})\n"
+ typename = type.to_yard_s
+ .gsub(/[<>]/) {|match| sanitized[match]} # Excape angle brackets
+ .gsub(/(Entity::\w+)/, '{\1}') # So YARD can generate refs
+
+ new_docstr += " * #{name} (#{typename})\n"
end
-
+
new_docstr += "\n"
new_docstr += "See `Shep::Entity` for an overview.\n\n"
new_docstr += namespace.docstring.to_raw.strip
namespace.docstring.replace(new_docstr)
end
end
-
-
-