Class: Ukiryu::Definition::DocumentationGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/ukiryu/definition/documentation_generator.rb

Overview

Generate documentation from tool definitions

This class generates human-readable documentation from tool definitions in various formats (Markdown, AsciiDoc).

Constant Summary collapse

FORMATS =

Supported formats

%i[markdown asciidoc md].freeze

Class Method Summary collapse

Class Method Details

.generate(definition, format: :markdown) ⇒ String

Generate documentation for a definition

Parameters:

  • definition (Hash)

    the definition

  • format (Symbol) (defaults to: :markdown)

    output format (:markdown, :asciidoc)

Returns:

  • (String)

    generated documentation



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ukiryu/definition/documentation_generator.rb', line 19

def generate(definition, format: :markdown)
  format = normalize_format(format)

  case format
  when :markdown
    generate_markdown(definition)
  when :asciidoc
    generate_asciidoc(definition)
  else
    raise ArgumentError, "Unsupported format: #{format}"
  end
end

.generate_command_docs(command_name, command_def, format: :markdown) ⇒ String

Generate documentation for a specific command

Parameters:

  • command_name (String)

    the command name

  • command_def (Hash)

    the command definition

  • format (Symbol) (defaults to: :markdown)

    output format

Returns:

  • (String)

    generated command documentation



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/ukiryu/definition/documentation_generator.rb', line 48

def generate_command_docs(command_name, command_def, format: :markdown)
  format = normalize_format(format)

  case format
  when :markdown
    generate_command_markdown(command_name, command_def)
  when :asciidoc
    generate_command_asciidoc(command_name, command_def)
  else
    raise ArgumentError, "Unsupported format: #{format}"
  end
end

.generate_to_file(definition, file_path, format: :markdown) ⇒ Object

Generate documentation to a file

Parameters:

  • definition (Hash)

    the definition

  • file_path (String)

    output file path

  • format (Symbol) (defaults to: :markdown)

    output format



37
38
39
40
# File 'lib/ukiryu/definition/documentation_generator.rb', line 37

def generate_to_file(definition, file_path, format: :markdown)
  content = generate(definition, format: format)
  File.write(file_path, content)
end