Document model attributes with YARD

前端 未结 2 538
别那么骄傲
别那么骄傲 2021-02-04 06:38

I\'m using YARD to generate docs for my rails app with makrdown as the script parser. Most of the documentation features just work great right out of the box. However, I\'d also

2条回答
  •  鱼传尺愫
    2021-02-04 07:08

    After quite a while searching around, I punted and manually added the documentation for the attributes to the model files. This is certainly not ideal, but hopefully the model structure won't change a whole lot.

    I created a .yardopts file for the project and used the yard command-line options to create two new tags for marking these up:

    --type-name-tag 'attribute:Attributes' --type-name-tag 'association:Associations'
    

    These provide me with specific tags for marking up the attributes and associations; they will show up grouped under the "Attributes" and "Associations" headings in the documentation. I can add this:

    # @attribute name [String] The name of the object
    # @association relatedObjs [Array] Objects needed to perform a certain function
    

    Maybe someone will write a plugin for YARD that will parse out the annotate-models output.

提交回复
热议问题