Module: Yard::Yaml::Plugin

Defined in:
lib/yard/yaml/plugin.rb

Overview

Plugin activation for yard-yaml (Phase 3: config + discovery; still no YARD registrations).

Constant Summary collapse

STATE =
{activated: false}
STATE_MUTEX =
Mutex.new

Class Method Summary collapse

Class Method Details

.__reset_state__Object

Test-helper: reset internal activation flag. Not part of public API; used from test teardown to avoid state leakage.



54
55
56
57
# File 'lib/yard/yaml/plugin.rb', line 54

def __reset_state__
  STATE_MUTEX.synchronize { STATE[:activated] = false }
  nil
end

.activate(argv = nil) ⇒ void

This method returns an undefined value.

Activate the plugin.

Phase 3 behavior:

  • Parse argv for ‘–yard_yaml-*` flags and apply to configuration.

  • Run discovery to collect YAML pages and mirror to registry store.

  • Do NOT register tags, templates, or handlers yet.

Parameters:

  • argv (Array<String>, nil) (defaults to: nil)

    optional argument vector to parse



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/plugin.rb', line 28

def activate(argv = nil)
  # Parse and apply CLI overrides if provided
  begin
    overrides = Cli.parse(argv || [])
    Yard::Yaml.configure(overrides) unless overrides.empty?
  rescue StandardError
    # Parsing failures should not prevent activation in Phase 3
  end

  # Collect pages via discovery using current config
  begin
    pages = Discovery.collect(Yard::Yaml.config)
    Yard::Yaml.__set_pages__(pages)
  rescue Yard::Yaml::Error
    # strict mode surfaced an error; re-raise to fail activation/build
    raise
  rescue StandardError
    # Non-strict errors are already warned by converter/discovery
  end

  STATE_MUTEX.synchronize { STATE[:activated] = true }
  nil
end

.activated?Boolean

Whether the plugin has been activated for the current process. Activation is explicit; requiring this file does not activate anything.

Returns:

  • (Boolean)


15
16
17
# File 'lib/yard/yaml/plugin.rb', line 15

def activated?
  STATE[:activated]
end