Class: JsDuck::MetaTag
- Inherits:
-
Object
- Object
- JsDuck::MetaTag
- Defined in:
- lib/jsduck/meta_tag.rb
Overview
Abstract base class for all meta tag implementations.
Child classes must define value for @name attribute. They can also provide @multiline, and override #to_html method.
Direct Known Subclasses
Tag::Abstract, Tag::Aside, Tag::Author, Tag::Chainable, Tag::Deprecated, Tag::Docauthor, Tag::Hide, Tag::Ignore, Tag::Markdown, Tag::New, Tag::Preventable, Tag::Private, Tag::Protected, Tag::Readonly, Tag::Removed, Tag::Required, Tag::Since, Tag::Static, Tag::Template
Instance Attribute Summary collapse
-
#assets ⇒ Object
Here the Assets object will be injected, so the Tag implementation can access guides, videos, etc when he needs to.
-
#boolean ⇒ Object
readonly
True to ignore any text after the @tag, just record the existance of the tag.
-
#context ⇒ Object
Here the appropriate class or member will be injected, so the to_value and to_html methods can for produce different output based on whether the tag is inside class, method, event, etc.
-
#formatter ⇒ Object
This is used to inject the formatter object for #markdown method.
-
#key ⇒ Object
The key under which to store this tag.
-
#multiline ⇒ Object
readonly
True to include all lines up to next @tag as part of this meta-tag.
-
#name ⇒ Object
readonly
Name of the tag (required).
-
#position ⇒ Object
Whether to render the tag before other content (:top) or after it (:bottom).
-
#signature ⇒ Object
readonly
The text to display in member signature.
Class Method Summary collapse
-
.descendants ⇒ Object
Returns all descendants of MetaTag class.
Instance Method Summary collapse
-
#format(text) ⇒ Object
Helper method to format the text in standard JsDuck way.
-
#to_html(contents) ⇒ Object
Override this to transform the content of meta-tag to HTML to be included into documentation.
-
#to_value(contents) ⇒ Object
It gets passed an array of contents gathered from all meta-tags of given type.
Instance Attribute Details
#assets ⇒ Object
Here the Assets object will be injected, so the Tag implementation can access guides, videos, etc when he needs to.
43 44 45 |
# File 'lib/jsduck/meta_tag.rb', line 43 def assets @assets end |
#boolean ⇒ Object (readonly)
True to ignore any text after the @tag, just record the existance of the tag.
29 30 31 |
# File 'lib/jsduck/meta_tag.rb', line 29 def boolean @boolean end |
#context ⇒ Object
Here the appropriate class or member will be injected, so the to_value and to_html methods can for produce different output based on whether the tag is inside class, method, event, etc.
39 40 41 |
# File 'lib/jsduck/meta_tag.rb', line 39 def context @context end |
#formatter ⇒ Object
This is used to inject the formatter object for #markdown method
68 69 70 |
# File 'lib/jsduck/meta_tag.rb', line 68 def formatter @formatter end |
#key ⇒ Object
The key under which to store this tag. Must be a symbol. When not provided then :name is converted to symbol and used as key.
13 14 15 |
# File 'lib/jsduck/meta_tag.rb', line 13 def key @key end |
#multiline ⇒ Object (readonly)
True to include all lines up to next @tag as part of this meta-tag
25 26 27 |
# File 'lib/jsduck/meta_tag.rb', line 25 def multiline @multiline end |
#name ⇒ Object (readonly)
Name of the tag (required)
9 10 11 |
# File 'lib/jsduck/meta_tag.rb', line 9 def name @name end |
#position ⇒ Object
Whether to render the tag before other content (:top) or after it (:bottom). Defaults to :bottom.
33 34 35 |
# File 'lib/jsduck/meta_tag.rb', line 33 def position @position end |
#signature ⇒ Object (readonly)
The text to display in member signature. Must be a hash defining the short and long versions of the signature text:
{:long => "something", :short => "SOM"}
Additionally the hash can contain a :tooltip which is the text to be shown when the signature bubble is hovered over in docs.
22 23 24 |
# File 'lib/jsduck/meta_tag.rb', line 22 def signature @signature end |
Class Method Details
.descendants ⇒ Object
Returns all descendants of MetaTag class.
78 79 80 81 82 83 84 |
# File 'lib/jsduck/meta_tag.rb', line 78 def self.descendants result = [] ObjectSpace.each_object(::Class) do |cls| result << cls if cls < self end result end |
Instance Method Details
#format(text) ⇒ Object
Helper method to format the text in standard JsDuck way. This means running it through Markdown engine and expanding @link and @img tags.
73 74 75 |
# File 'lib/jsduck/meta_tag.rb', line 73 def format(text) @formatter.format(text) end |
#to_html(contents) ⇒ Object
Override this to transform the content of meta-tag to HTML to be included into documentation.
It gets passed the value returned by #to_value method. It should return an HTML string to inject into document. For help in that it can use the #format method to easily support Markdown and @link/img tags inside the contents of meta-tag.
By default the method returns nil, which means the tag will not be rendered at all.
64 65 |
# File 'lib/jsduck/meta_tag.rb', line 64 def to_html(contents) end |
#to_value(contents) ⇒ Object
It gets passed an array of contents gathered from all meta-tags of given type. It should return the value to be stored for this meta-tag at :key. The returned value is also passed to #to_html method. Returning nil will cause the tag to be ignored. By default the contents are returned unchanged.
50 51 52 |
# File 'lib/jsduck/meta_tag.rb', line 50 def to_value(contents) contents end |