Class: Synthra::CLI::Commands::Docs
- Inherits:
-
Object
- Object
- Synthra::CLI::Commands::Docs
- Defined in:
- lib/synthra/cli/commands/docs.rb
Overview
CLI command for generating schema documentation
Constant Summary collapse
- EXIT_SUCCESS =
0- EXIT_ERROR =
1
Instance Method Summary collapse
- #call(schema_dir, options) ⇒ Object
- #generate_documentation(schema_dir, output_dir, title) ⇒ Object private
-
#initialize ⇒ Docs
constructor
A new instance of Docs.
Constructor Details
#initialize ⇒ Docs
Returns a new instance of Docs.
15 16 17 |
# File 'lib/synthra/cli/commands/docs.rb', line 15 def initialize # No args needed for this command end |
Instance Method Details
#call(schema_dir, options) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/synthra/cli/commands/docs.rb', line 19 def call(schema_dir, ) unless File.directory?(schema_dir) $stderr.puts "✗ Schema directory not found: #{schema_dir}" return EXIT_ERROR end output_dir = [:output] || "docs" title = [:title] || "Synthra Schema Documentation" generate_documentation(schema_dir, output_dir, title) end |
#generate_documentation(schema_dir, output_dir, title) ⇒ Object (private)
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/synthra/cli/commands/docs.rb', line 33 def generate_documentation(schema_dir, output_dir, title) require_relative "../../documentation_generator" puts "📚 Generating documentation..." puts " Source: #{schema_dir}" puts " Output: #{output_dir}" puts "" # Load schemas registry = Registry.new registry.load_dir(schema_dir) if registry.names.empty? $stderr.puts "✗ No schemas found in #{schema_dir}" return EXIT_ERROR end # Generate docs generator = DocumentationGenerator.new(registry, title: title) files = generator.generate_html(output_dir) puts "✅ Generated #{files.count} documentation files:" files.each { |path| puts " #{path}" } puts "" puts " Open #{output_dir}/index.html in your browser" EXIT_SUCCESS rescue StandardError => e $stderr.puts "✗ Documentation generation failed: #{e.}" EXIT_ERROR end |