Class: Lutaml::Xsd::Spa::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/xsd/spa/generator.rb

Overview

Main SPA documentation generator

Generates interactive HTML Single Page Application documentation from XSD schemas using Vue.js frontend.

Examples:

Generate single-file SPA

generator = Generator.new(
  package,
  'output/docs.html',
  mode: 'inlined'
)
generator.generate

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(package, output_path, options = {}) ⇒ Generator

Initialize SPA generator

Parameters:

  • package (SchemaRepositoryPackage)

    Schema repository package

  • output_path (String)

    Output file path

  • options (Hash) (defaults to: {})

    Generation options

Options Hash (options):

  • :mode (String)

    Output mode (‘inlined’ or ‘cdn’)

  • :verbose (Boolean)

    Enable verbose output



33
34
35
36
37
38
39
# File 'lib/lutaml/xsd/spa/generator.rb', line 33

def initialize(package, output_path, options = {})
  @package = package
  @output_path = output_path
  @options = options
  @config_loader = ConfigurationLoader.new
  @serializer = SchemaSerializer.new(package)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



24
25
26
# File 'lib/lutaml/xsd/spa/generator.rb', line 24

def options
  @options
end

#output_pathObject (readonly)

Returns the value of attribute output_path.



24
25
26
# File 'lib/lutaml/xsd/spa/generator.rb', line 24

def output_path
  @output_path
end

#packageObject (readonly)

Returns the value of attribute package.



24
25
26
# File 'lib/lutaml/xsd/spa/generator.rb', line 24

def package
  @package
end

Instance Method Details

#generateArray<String>

Generate SPA documentation

Returns:

  • (Array<String>)

    List of generated file paths



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/lutaml/xsd/spa/generator.rb', line 44

def generate
  log "Starting SPA generation..."

  # Create output strategy
  strategy = create_strategy
  mode = options[:mode] || "inlined"
  strategy_name = "#{mode.split('_').map(&:capitalize).join(' ')} Strategy"
  log "✓ Using #{strategy_name}"

  # Serialize schema data
  serialized_data = @serializer.serialize
  log "✓ Serialized #{serialized_data[:schemas]&.size || 0} schema(s)"

  # Generate output using strategy
  output_files = strategy.generate(serialized_data, nil)
  log "✓ Generated #{output_files&.size || 0} file(s)"

  output_files
end