Skip to content

durableprogramming/metimur

Repository files navigation

Metimur

A powerful Ruby source code analysis and documentation management tool.

Metimur Logo

What is Metimur?

Metimur is a Ruby library and command-line tool that helps developers analyze, document, and maintain Ruby source code. It provides capabilities to:

  • Parse Ruby source files and extract structural information
  • Add or update documentation comments for classes, modules, and methods
  • Manage file header and footer comments
  • Generate code structure reports
  • Read and update YARD-style documentation programatically

Table of Contents

Installation

Add this line to your application's Gemfile:

gem 'metimur'

Then execute:

$ bundle install

Or install it directly:

$ gem install metimur

Quick Start

1. Analyze a Ruby File

# Parse a single Ruby file
metimur parse-file lib/my_class.rb

# Parse with JSON output
metimur parse-file lib/my_class.rb --format=json

# Show detailed information
metimur parse-file lib/my_class.rb --details

2. Add Documentation

# Add a YARD comment to a class
metimur set-class-comment lib/my_class.rb MyClass "@author John Doe\n@since 1.0.0"

# Add a method comment
metimur set-method-comment lib/my_class.rb my_method "@param name [String] The user's name\n@return [Boolean] Success status"

Usage Examples

Command Line Interface

  1. Parse a Ruby File
$ metimur parse-file lib/user.rb
File: lib/user.rb
Total lines: 50

Classes (1):
  User (1..45)
    - initialize (5..8)
    - full_name (10..12)
    - save (14..20)
  1. Add Class Documentation
$ metimur set-class-comment lib/user.rb User "User model representing system users
@author John Doe
@since 1.0.0"

Ruby API

  1. Parse a Source File
require 'metimur'

# Parse a single file
source_file = Metimur.parse_file('lib/user.rb')

# Access file information
puts "Classes found: #{source_file.classes.count}"
source_file.classes.each do |klass|
  puts "Class: #{klass.name}"
  puts "Methods: #{klass.methods.map(&:name).join(', ')}"
end
  1. Manage Documentation
require 'metimur'

# Add a YARD comment to a method
Metimur.set_yard_comment(
  'lib/user.rb',
  15, # line number
  "@param name [String] The user's name\n@return [User] The created user"
)

# Add a file header
Metimur.set_file_header_comment(
  'lib/user.rb',
  "Copyright (c) 2023 Your Company\nLicensed under MIT"
)

Behind the scenes

Metimur is built with a modular architecture that separates concerns into distinct components:

graph TD
    A[CLI Layer] --> B[Core API]
    B --> C[Parser]
    B --> D[Models]
    B --> E[Actions]
    C --> F[Source File Analysis]
    D --> G[Code Structure Models]
    E --> H[Documentation Management]
Loading

Contributing

We welcome contributions! Here's how you can help:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run the tests (bundle exec rspec)
  5. Commit your changes (git commit -am 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Create a Pull Request

Development Setup

# Clone the repository
git clone https://github.com/durableprogramming/metimur.git

# Install dependencies
cd metimur
bundle install

# Run tests
bundle exec rspec

# Run the local version
bundle exec exe/metimur

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Support

Need help? Have questions?


Made with ❤️ by the Metimur team

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published