Class: SpecForge::Documentation::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/spec_forge/documentation/generator.rb

Overview

Base class for all documentation generators

Provides the common interface and shared functionality for generators that transform SpecForge documents into various output formats. Subclasses implement format-specific generation logic.

Examples:

Creating a custom generator

class MyGenerator < Generator
  def generate
    # Transform input document to custom format
  end
end

Direct Known Subclasses

OpenAPI::V30

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input = {}) ⇒ Base

Initializes a new generators

Parameters:

  • input (Hash, Document) (defaults to: {})

    The document to generate



72
73
74
# File 'lib/spec_forge/documentation/generator.rb', line 72

def initialize(input = {})
  @input = input
end

Instance Attribute Details

#inputDocument (readonly)

The input document containing structured API data

Contains all the endpoint information extracted from tests, organized and ready for transformation into the target format.

Returns:

  • (Document)

    The document to be processed by the generator



63
64
65
# File 'lib/spec_forge/documentation/generator.rb', line 63

def input
  @input
end

Class Method Details

.generate(use_cache: false) ⇒ Object

Generates documentation from test data with optional caching

Parameters:

  • use_cache (Boolean) (defaults to: false)

    Whether to use cached test data if available

Returns:

  • (Object)

    The generated documentation in the target format

Raises:

  • (RuntimeError)

    Must be implemented by subclasses



38
39
40
# File 'lib/spec_forge/documentation/generator.rb', line 38

def self.generate(use_cache: false)
  raise "not implemented"
end

.to_sem_versionSemVersion

Converts the generator's version to a semantic version object

Returns:

  • (SemVersion)

    The semantic version



25
26
27
# File 'lib/spec_forge/documentation/generator.rb', line 25

def self.to_sem_version
  SemVersion.new(const_get("CURRENT_VERSION"))
end

.validate!(input) ⇒ void

This method returns an undefined value.

Validates the generated output according to format specifications

Parameters:

  • input (Object)

    The generated documentation to validate

Raises:

  • (RuntimeError)

    Must be implemented by subclasses



51
52
53
# File 'lib/spec_forge/documentation/generator.rb', line 51

def self.validate!(input)
  raise "not implemented"
end

Instance Method Details

#generateObject

Generates the document into a specific format

Returns:

  • (Object)

    The generated document

Raises:

  • (RuntimeError)

    Must be implemented by subclasses



83
84
85
# File 'lib/spec_forge/documentation/generator.rb', line 83

def generate
  raise "not implemented"
end