Module: Docks::Tags

Defined in:
lib/docks/tags.rb,
lib/docks/tags/for_tag.rb,
lib/docks/tags/base_tag.rb,
lib/docks/tags/beta_tag.rb,
lib/docks/tags/link_tag.rb,
lib/docks/tags/name_tag.rb,
lib/docks/tags/type_tag.rb,
lib/docks/tags/alias_tag.rb,
lib/docks/tags/class_tag.rb,
lib/docks/tags/group_tag.rb,
lib/docks/tags/param_tag.rb,
lib/docks/tags/since_tag.rb,
lib/docks/tags/state_tag.rb,
lib/docks/tags/title_tag.rb,
lib/docks/tags/value_tag.rb,
lib/docks/tags/access_tag.rb,
lib/docks/tags/active_tag.rb,
lib/docks/tags/author_tag.rb,
lib/docks/tags/helper_tag.rb,
lib/docks/tags/markup_tag.rb,
lib/docks/tags/member_tag.rb,
lib/docks/tags/method_tag.rb,
lib/docks/tags/object_tag.rb,
lib/docks/tags/public_tag.rb,
lib/docks/tags/set_by_tag.rb,
lib/docks/tags/source_tag.rb,
lib/docks/tags/static_tag.rb,
lib/docks/tags/throws_tag.rb,
lib/docks/tags/example_tag.rb,
lib/docks/tags/factory_tag.rb,
lib/docks/tags/pattern_tag.rb,
lib/docks/tags/private_tag.rb,
lib/docks/tags/require_tag.rb,
lib/docks/tags/returns_tag.rb,
lib/docks/tags/variant_tag.rb,
lib/docks/tags/preclude_tag.rb,
lib/docks/tags/property_tag.rb,
lib/docks/tags/subtitle_tag.rb,
lib/docks/tags/demo_type_tag.rb,
lib/docks/tags/signature_tag.rb,
lib/docks/tags/variation_tag.rb,
lib/docks/tags/deprecated_tag.rb,
lib/docks/tags/description_tag.rb,
lib/docks/tags/symbol_type_tag.rb,
lib/docks/tags/include_with_tag.rb,
lib/docks/tags/subcomponent_tag.rb,
lib/docks/tags/activate_with_tag.rb,
lib/docks/tags/compatibility_tag.rb,
lib/docks/tags/javascript_action_tag.rb

Defined Under Namespace

Classes: Access, ActivateWith, Active, Alias, Author, Base, Beta, Compatibility, DemoType, Deprecated, Description, Example, Factory, For, Group, Helper, IncludeWith, IncludedSymbol, JavascriptAction, Klass, Link, Markup, Member, Method, Name, Object, Param, Pattern, Preclude, Private, Property, Public, Require, Returns, SetBy, Signature, Since, Source, State, Static, Subcomponent, Subtitle, SymbolType, Throws, Title, Type, UsedBy, Value, Variant, Variation

Class Method Summary collapse

Class Method Details

.<<(tag) ⇒ Object



36
37
38
# File 'lib/docks/tags.rb', line 36

def self.<<(tag)
  register(tag)
end

.base_tag_name(tag) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/docks/tags.rb', line 7

def self.base_tag_name(tag)
  tag = tag.instance.name if tag.instance_of?(Class)
  tag = tag.name if tag.kind_of?(Base)
  tag = tag.to_sym

  found = @synonyms[tag]
  return found if found
end

.has_tag?(tag) ⇒ Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/docks/tags.rb', line 67

def self.has_tag?(tag)
  !tag_for(tag).nil?
end

.join_synonymous_tags(hash) ⇒ Object



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
# File 'lib/docks/tags.rb', line 40

def self.join_synonymous_tags(hash)
  final_hash = {}
  hash.each do |tag, value|
    tag = tag.to_s.singularize.to_sym
    base_tag = @synonyms[tag]

    next if base_tag.nil?

    if final_hash[base_tag].nil?
      # No previous result for this tag or its synonyms. This effectively
      # includes all non-multiple-allowed tags.
      begin
        final_hash[base_tag] = value.clone
      rescue TypeError
        final_hash[base_tag] = value
      end
    else
      # All tags that could have previously-included synonym tags must be
      # multiple-allowed tags. All multiple-allowed tags have new arrays
      # for each declared tag.
      final_hash[base_tag].concat(value)
    end
  end

  final_hash
end

.register(tag) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/docks/tags.rb', line 20

def self.register(tag)
  tag = tag.instance
  tag.setup_post_processors

  return false if tag.name.nil?
  tag_name = tag.name.to_sym
  @tags[tag_name] = tag

  [tag_name, tag.synonyms].flatten.each do |synonym|
    @synonyms[synonym.to_sym] = tag_name
    @synonyms[synonym.to_s.pluralize.to_sym] = tag_name if tag.multiple_allowed?
  end

  true
end

.register_bundled_tagsObject



16
17
18
# File 'lib/docks/tags.rb', line 16

def self.register_bundled_tags
  bundled_tags.each { |tag| register(tag) }
end

.supported_parseable_tagsObject



75
76
77
# File 'lib/docks/tags.rb', line 75

def self.supported_parseable_tags
  supported_tags.select { |tag| tag_for(tag).parseable? }
end

.supported_tagsObject



71
72
73
# File 'lib/docks/tags.rb', line 71

def self.supported_tags
  @synonyms.keys
end

.tag_for(tag) ⇒ Object



3
4
5
# File 'lib/docks/tags.rb', line 3

def self.tag_for(tag)
  @tags[base_tag_name(tag)]
end