You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current best practice for writing YARD documentation for value classes created with this gem can be best summed up as "make them look like Structs for YARD":
Use the inheritance syntax (eg class A < Value.new(...)) rather than assigning to a constant
Document each field using YARD tag @attr_reader (docs)
Example
# What is a person?## @attr_reader [String] name Full name# @attr_reader [Fixnum] age Age in years# @attr_reader [Array<Person>] friends List of friendsclassPerson < Value.new(:name,:age,:friends);end
Still TODO
tell YARD about generated constructor
tell YARD about generated class methods: .with
tell YARD about the generated instance methods: #==, #eql?, #values, #inspect, #with, #to_h, #to_a
The text was updated successfully, but these errors were encountered:
I suggest that there should be a documented best practice for documenting value classes with yard.
Requirements:
I've put a gist together showing how it currently works. As you can see,
Example3
works about 75%, which I think is the best we can do at the moment.So that leads me to a documentation proposal. What do you think of this:
How to Document a Value class using YARD
Current best practice for writing YARD documentation for value classes created with this gem can be best summed up as "make them look like Structs for YARD":
class A < Value.new(...)
) rather than assigning to a constant@attr_reader
(docs)Example
Still TODO
.with
#==
,#eql?
,#values
,#inspect
,#with
,#to_h
,#to_a
The text was updated successfully, but these errors were encountered: