Merge "cleanup action=tokens"
[lhc/web/wiklou.git] / maintenance / jsduck / MetaTags.rb
1 # See also:
2 # - https://github.com/senchalabs/jsduck/wiki/Tags
3 # - https://github.com/senchalabs/jsduck/wiki/Custom-tags
4 require 'jsduck/meta_tag'
5
6 class ContextTag < JsDuck::MetaTag
7 def initialize
8 @name = 'context'
9 end
10
11 # @param tags All matches of this tag on one class.
12 def to_html(tags)
13 return '<h3 class="pa">Context</h3>' + render_long_context(tags.last)
14 end
15
16 def render_long_context(tag)
17 if tag =~ /\A([^\s]+)/m
18 name = $1
19 return format("`this` : {@link #{name}}")
20 end
21 end
22 end
23
24 class SeeTag < JsDuck::MetaTag
25 def initialize
26 @name = 'see'
27 @multiline = true
28 end
29
30 # @param tags All matches of this tag on one class.
31 def to_html(tags)
32 doc = []
33 doc << '<h3 class="pa">Related</h3>'
34 doc << [
35 '<ul>',
36 tags.map {|tag| render_long_see(tag) },
37 '</ul>',
38 ]
39 doc
40 end
41
42 def render_long_see(tag)
43 if tag =~ /\A([^\s]+)( .*)?\Z/m
44 name = $1
45 doc = $2 ? ': ' + $2 : ''
46 return [
47 '<li>',
48 format("{@link #{name}} #{doc}"),
49 '</li>'
50 ]
51 end
52 end
53 end