Module: Yard::Yaml::Tags

Defined in:
lib/yard/yaml/tags.rb,
sig/yard/yaml.rbs

Class Method Summary collapse

Class Method Details

.register!void

This method returns an undefined value.



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
# File 'lib/yard/yaml/tags.rb', line 13

def register!
  return unless defined?(::YARD) && ::YARD.const_defined?(:Tags)

  # Ensure a minimal Library exists under ::YARD::Tags if missing
  unless ::YARD::Tags.const_defined?(:Library, false)
    # If the test provided a top-level ::Library constant, attach it.
    if defined?(::Library) && ::Library.is_a?(Module)
      begin
        ::YARD::Tags.const_set(:Library, ::Library)
      rescue
        return
      end
    else
      # Create a minimal shim that records define_tag calls
      calls = []
      lib = Module.new
      lib.define_singleton_method(:calls) { calls }
      lib.define_singleton_method(:define_tag) { |*args| calls << args }
      begin
        ::YARD::Tags.const_set(:Library, lib)
      rescue
        # if we failed to set, just return silently
        return
      end
    end
  end

  begin
    ::YARD::Tags::Library.define_tag("YAML", :yaml, :with_title_and_text)
  rescue
    # ignore if already defined or unavailable
  end
  begin
    ::YARD::Tags::Library.define_tag("YAML File", :yaml_file, :with_text)
  rescue
    # ignore if already defined or unavailable
  end
end