0.0
No commit activity in last 3 years
No release in over 3 years
yard-struct allows users to document their classes created through Struct.new using a simple, familiar syntax and @member tag.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.2.9

Runtime

>= 0.4.0
 Project Readme

yard-struct

Plugin for YARD which generates documentation for Struct members.

Why?

Without yard-struct, there's a big difference between these as YARD can see them:

class A < Struct.new(:foo, :bar)
  def to_s
    foo + bar
  end
end

class B
  attr_accessor :foo, :bar
  def to_s
    foo + bar
  end
end

yard-struct makes it so that when YARD examines the first, it creates attributes for the auto-generated accessors :foo and :bar.

There's more

This plugin also adds a new tag, @member. This lets you document the Struct members with types. Use it as such:

##
# Whizbang class does lots of stuff.
#
# @member [IO, #read] input the input file to whizbang
# @member [Proc, #call] frob the proc to frobinate the input
class Whizbang < Struct.new(:input, :frob)
end

The generated types will be shown prominently in the generated documentation.

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

Copyright

Copyright (c) 2010 Michael Edgar. See LICENSE for details.