Project

annotato

0.0
The project is in a healthy, maintained state
Annotato automatically adds or updates comments at the end of your Rails models to show schema details like columns, indexes, and PostgreSQL triggers.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

>= 6.0
 Project Readme

Annotato

Automatically adds schema comments (columns, indexes, triggers, enums) to Rails models.

CI Gem Version


Features

  • Annotates Rails models with:

    • Columns and types
    • Default values and constraints
    • Enums with values
    • Indexes (only if present)
    • Triggers (only if present)
  • Skips unchanged annotations

  • Smart formatting with aligned columns

Example:

# == Annotato Schema Info
# Table: users
#
# Columns:
#  id         :bigint           not null, primary key
#  email      :string           not null, unique
#  role       :string           default("user"), not null
#
# Enums:
#  role: { user, admin }

class User < ApplicationRecord
end

Installation

Add this line to your Gemfile:

gem "annotato"

Then run:

bundle install

Usage

Annotate All Models

To annotate all models, run:

bundle exec rake annotato:models

Annotate Specific Models

You can now pass one or multiple model names to the task.

# Annotate only the User model
rake annotato:models[User]

# Annotate multiple models (User and Admin::Account)
rake annotato:models["User,Admin::Account"]

Rake Task

rake annotato:models[MODEL]
  • Automatically loads all models via Rails.application.eager_load!
  • Modifies model files in place
  • Replace existing Annotato and legacy annotate blocks
  • Pass MODEL argument (single or comma-separated) to target specific models

Development

To run tests:

bundle exec rspec

To check code coverage:

COVERAGE=true bundle exec rspec

Contributing

Feel free to open issues or pull requests.


License

MIT