Skip to content

Yard doc style annotations do not update after migrations #780

@tmr08c

Description

@tmr08c

After generating annotations using the Yard doc format, running migrations does not update the annotations.

Commands

bundle exec annotate --models -f yard

Generates:

# == Schema Information
#
# Table name: users
#
# @!attribute id
#   @return []
# @!attribute name
#   @return [String]
# @!attribute created_at
#   @return [Time]
# @!attribute updated_at
#   @return [Time]
#
class User < ApplicationRecord
end

Generate a new migration and migrate:

> rails g migration add_email_to_users email:string
> rails db:migrate
== 20200322114415 AddEmailToUsers: migrating ==================================
-- add_column(:users, :email, :string)
   -> 0.0019s
== 20200322114415 AddEmailToUsers: migrated (0.0020s) =========================

Manually run annotations, but annotations are not updated:

› bundle exec annotate --models -f yard        
Model files unchanged.

Version

  • annotate version: 3.1.1
  • rails version: 6.0.2.2
  • ruby version: 2.6.5

Notes

I believe the source of the problem is the regular expression used to extract columns from the annotation blob:

column_pattern = /^#[\t ]+[\w\*`]+[\t ]+.+$/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions