1 # Custom tags for JSDuck 4.x
3 # - https://github.com/senchalabs/jsduck/wiki/Tags
4 # - https://github.com/senchalabs/jsduck/wiki/Custom-tags
5 # - https://github.com/senchalabs/jsduck/wiki/Custom-tags/7f5c32e568eab9edc8e3365e935bcb836cb11f1d
6 require 'jsduck/meta_tag'
8 class SourceTag < JsDuck::MetaTag
10 # This defines the name of the @tag
14 # Generate HTML output for this tag.
15 # One can make use of the #format method to easily support
16 # Markdown and {@link} tags inside the contents of the tag.
18 # @param tags All matches of this tag on one class.
20 '<h3 class="pa">Source</h3>' + tags.map {|tag| format(tag) }.join("\n")
24 class ContextTag < JsDuck::MetaTag
29 # @param tags All matches of this tag on one class.
31 return '<h3 class="pa">Context</h3>' + render_long_context(tags.last)
34 def render_long_context(tag)
35 if tag =~ /\A([^\s]+)/m
37 return format("`this` : {@link #{name}}")
42 class SeeTag < JsDuck::MetaTag
48 # @param tags All matches of this tag on one class.
51 doc << '<h3 class="pa">Related</h3>'
54 tags.map {|tag| render_long_see(tag) },
60 def render_long_see(tag)
61 if tag =~ /\A([^\s]+)( .*)?\Z/m
63 doc = $2 ? ': ' + $2 : ''
66 format("{@link #{name}} #{doc}"),
73 # As of JSDuck 5 this is in core
74 class FiresTag < JsDuck::MetaTag
80 # @param tags All matches of this tag on one class.
83 doc << '<h3 class="pa">Fires</h3>'
86 tags.map {|tag| render_long_event(tag) },
92 def render_long_event(tag)
93 if tag =~ /\A(\w+)( .*)?\Z/m
95 doc = $2 ? ': ' + $2 : ''
98 format("{@link #event-#{name}} #{doc}"),