blob: 83cc0884ce3facefd324eba6a61ab871fe835d98 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# See also:
# - https://github.com/senchalabs/jsduck/wiki/Tags
# - https://github.com/senchalabs/jsduck/wiki/Custom-tags
require 'jsduck/meta_tag'
class SourceTag < JsDuck::MetaTag
def initialize
# This defines the name of the @tag
@name = 'source'
end
# Generate HTML output for this tag.
# One can make use of the #format method to easily support
# Markdown and {@link} tags inside the contents of the tag.
#
# @param tags All matches of this tag on one class.
def to_html(tags)
'<h3 class="pa">Source</h3>' + tags.map {|tag| format(tag) }.join("\n")
end
end
class ContextTag < JsDuck::MetaTag
def initialize
@name = 'context'
end
# @param tags All matches of this tag on one class.
def to_html(tags)
return '<h3 class="pa">Context</h3>' + render_long_context(tags.last)
end
def render_long_context(tag)
if tag =~ /\A([^\s]+)/m
name = $1
return format("`this` : {@link #{name}}")
end
end
end
class SeeTag < JsDuck::MetaTag
def initialize
@name = 'see'
@multiline = true
end
# @param tags All matches of this tag on one class.
def to_html(tags)
doc = []
doc << '<h3 class="pa">Related</h3>'
doc << [
'<ul>',
tags.map {|tag| render_long_see(tag) },
'</ul>',
]
doc
end
def render_long_see(tag)
if tag =~ /\A([^\s]+)( .*)?\Z/m
name = $1
doc = $2 ? ': ' + $2 : ''
return [
'<li>',
format("{@link #{name}} #{doc}"),
'</li>'
]
end
end
end
|