Giter Site home page Giter Site logo

yard-activerecord's Introduction

YARD ActiveRecord Plugin

Version Downloads Open Github issues

A YARD extension that handles and interprets methods used when developing applications with ActiveRecord. The extension handles attributes, associations, delegates and scopes. A must for any Rails app using YARD as documentation plugin.

Installation

Run the following command in order to load YARD plugins:

$ yard config load_plugins true

Attributes

In order for this plugin to document any database attributes you need to add schema.rb to your list of files. This is preferably done with in .yardopts within your app project folder:

# .yardopts
'app/**/*.rb'
'db/schema.rb'

It's important that the schema.rb-file is added at the end as it needs all classes loaded before it can add the attributes.

The plugin will then document all attributes in your documentation.

All attributes will be marked as writable. I will update the plugin to include handling of attr_accessible at a later point.

Please note that any reference-fields that ends with _id will not be handled as an attribute. Please see Associations.

There is an issue with namespaced classes. Currently this plugin will try and fetch a class with a namespace if it does not find one at the first try.

Example:

Table name        Class name
sales_people      SalesPeople # does not exist
sales_people      Sales::People # does exist

A problem then emerges if you have namespaces with two names.

Example:

Table name          Class name
sales_force_people  SalesForcePeople # does not exist
sales_force_people  Sales::ForcePeople # does not exist

The documentation will then be skipped for this table/class.

Associations

The plugin handles has_one, belongs_to, has_many and has_and_belongs_to_many associations. The annotation for each association includes a link to the referred model. For associations with a list of objects the documentation will simply be marked as Array<ModelName>.

Delegates

The plugin handles delegate-methods and marks these delegated instance methods simply as aliases for the associated object.

Scopes

The plugin will add class methods for any scopes you have defined in your models.

Validations

The plugin will add information about validations onto each field. It only handles the new style validations in the form of:

validates :foo, :presence=>true, :length=>{ is: 6 }

Validations in the older form of:

validates_presence_of :foo

are not supported.

Other useful plugins

Check out:

Contributing to yard-activerecord

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
  • Fork the project.
  • Start a feature/bugfix branch.
  • Commit and push until you are happy with your contribution.
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright

Copyright (c) 2014 Theodor Tonum. See LICENSE.txt for further details.

yard-activerecord's People

Contributors

theodorton avatar nathanstitt avatar pitr-ch avatar kellym avatar mjc-gh avatar rzane avatar caulfield avatar

Watchers

Russell Reas avatar James Cloos avatar Michael Cordell avatar Nick avatar Bijal Hopkins avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.