Class: Glib::DocGenerator
- Inherits:
-
Object
- Object
- Glib::DocGenerator
- Defined in:
- lib/glib/doc_generator.rb
Instance Method Summary collapse
-
#generate_for_file(file_path, output_path) ⇒ Object
Generate YAML documentation for a single Ruby file.
-
#initialize ⇒ DocGenerator
constructor
A new instance of DocGenerator.
Constructor Details
#initialize ⇒ DocGenerator
Returns a new instance of DocGenerator.
8 9 10 |
# File 'lib/glib/doc_generator.rb', line 8 def initialize @parser = Parser::CurrentRuby end |
Instance Method Details
#generate_for_file(file_path, output_path) ⇒ Object
Generate YAML documentation for a single Ruby file
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/glib/doc_generator.rb', line 13 def generate_for_file(file_path, output_path) unless File.exist?(file_path) puts "Warning: File not found: #{file_path}" return end source = File.read(file_path) ast = @parser.parse(source) components = extract_components(ast, source) # Generate YAML yaml_data = { 'meta' => { 'source_file' => file_path, 'generated_at' => Time.now.iso8601, 'generator_version' => '1.0.0' }, 'components' => components } # Ensure output directory exists FileUtils.mkdir_p(File.dirname(output_path)) # Write YAML file File.write(output_path, yaml_data.to_yaml) end |