1

I'm using YARD for my Ruby on Rails application documentation. I have simple model that looks like this:

# frozen_string_literal: true

# {Patient} is model responsible for storing patient personal informations.
#
# @!attribute id
#   @return [UUID] ID of the {Patient} in UUID format.
#
# @!attribute name
#   @return [String] Name of the {Patient}.
#
# @!attribute gender
#   @return [String] Gender of the {Patient}.
#
# @!attribute date_of_birth
#   @return [Date] Date of birth of the {Patient}.
#
# @!attribute created_at
#   @return [DateTime] Time when {Patient} was created.
#
# @!attribute updated_at
#   @return [DateTime] Time when {Patient} was updated.

class Patient < ApplicationRecord
  # == Relationships ========================================================
  belongs_to :organization

  # == Validations ==========================================================
  validates :name,          presence: true
  validates :date_of_birth, presence: true
  validates :gender,        inclusion: { in: Constants::GENDERS }
end

How can I document with YARD my Relationships and Validations? I saw that there is gem https://github.com/theodorton/yard-activerecord but it was not updated for 6 years.

Mateusz Urbański
  • 7,352
  • 15
  • 68
  • 133
  • 3
    I would take a look at this documentation and ask if it actually gives any sort of value at all. It doesn't take a rocket scientist do figure out what `paient.date_of_birth` means. Concentrate on documenting the aspects of the code that are actually unclear/suprising instead. Like for example that the id column is a uuid and the buisness logic enforced by your validations. – max Nov 04 '20 at 11:12
  • May I ask why you are doing this? – Eyeslandic Nov 04 '20 at 12:06

1 Answers1

0

ruby gem annotate is a way to auto-document your functions based on your database

Kemal Ahmed
  • 638
  • 6
  • 15