Questions tagged [yard]

YARD stands for "Yay! A Ruby Documentation tool". It is considered an alternative to the rdoc tool with more features.

YARD stands for "Yay! A Ruby Documentation tool". It is considered an alternative to the rdoc tool with more features. The YARD website says:

YARD is a documentation generation tool for the Ruby programming language. It enables the user to generate consistent, usable documentation that can be exported to a number of formats very easily, and also supports extending for custom Ruby constructs such as custom class level definitions.

YARD's notable features include:

  • Preview as you document
  • Easily customize templates
  • Support your own DSL
  • Extend, extend, extend!

And of course YARD comes with much more functionality, including the ability to serve documentation for gems, the ability to group methods into logical sections, and much more.

195 questions
7
votes
3 answers

yard, How to include image to documentation?

I want to include image in yard-genereted documentation, but can't find anywhere how to do this... Does anyone know how to do this?
Adrian Serafin
  • 7,665
  • 5
  • 46
  • 67
7
votes
1 answer

In Ruby YARD docs, what it mean to wrap a word +example+ with + (plus sign)?

In the official YARD docs, there is the following example: # @overload set(key, value) # Sets a value on key # @param key [Symbol] describe key param # @param value [Object] describe value param # @overload set(value) # Sets a value on the…
Bill Mei
  • 717
  • 1
  • 10
  • 22
7
votes
0 answers

Using yard to work with markdown files

I've written some using documentation for a ruby gem. I'm using yard to generate the ruby gem reference documentation from the ruby source, and I want yard to work with this other markdown documentation. I've written the documentation within the…
SheffieldKevin
  • 271
  • 1
  • 13
7
votes
1 answer

Documenting a function that renders a JSON with Yard?

If I have a function that returns this: render :json => @orders.as_json(include: [{:user => {only: :id}}], :only => [:id, :status_id]) I am documenting it like this: # @return [JSON] includes the id, the order status id and the id of the…
Hommer Smith
  • 26,772
  • 56
  • 167
  • 296
7
votes
6 answers

How to customize diff git to ignore yard date generation

I'm using yard to generate the documenation of my project. Even thought the documentation can generated and so don't really need to be versionned, we decided to do so, because it makes it easier to see the impact of code (comment) change in the…
mb14
  • 22,276
  • 7
  • 60
  • 102
6
votes
2 answers

YARD: document custom getter/setter pair like attr_accessor

I'm using YARD to document my project. YARD document attributes created with attr_accessor :some_attribute in a separate section "Instance Attribute Summary". Now I have another attribute, but with custom setter and getter def some_other_attribute …
Marian Theisen
  • 6,100
  • 29
  • 39
6
votes
0 answers

How to YARD-document return type of method with yield?

I would like to better document the return type of this naïve memoization method using YARD: # Ensures that given block is only executed exactly once and on subsequent # calls returns result from first execution. Useful for memoizing methods. # #…
Nicolas
  • 472
  • 6
  • 14
6
votes
2 answers

How can I reference the current class as a return type in YARD?

Consider a code like this: module Foo # returns a copy of self # @return [ ___ ] def returns_new_self self.class.new end end class Bar include Foo end class Zap include Foo end With this, Bar.new.returns_new_self will return…
Todoroki
  • 515
  • 4
  • 12
6
votes
1 answer

Documenting methods created with meta-programming using YARD

I'm currently working on a gem and writing documentation for it. I currently have a class that has several method defined using defined_method as follows: class Client ['one', 'two'].each do |method_name| # Sets the value # @param argument…
Aliou
  • 1,065
  • 11
  • 17
6
votes
1 answer

How to generate documentation with Yard for Rails views?

I have just started using Yard to generate my docs and whilst it works great for my models and controllers, I can't seem to get it to generate anything for the views I've tried a variety of different ways to get it to work. Currently I've set up a…
Addsy
  • 3,944
  • 2
  • 32
  • 35
6
votes
0 answers

Create a completely new template for YARD?

I need to change the structure of the HTML documentation generated by Yard; there isn't much in common with the default HTML template. As I understand it, the solution to this is to create a new YARD template, but I'm having trouble creating one.…
Tom Opgenorth
  • 1,511
  • 1
  • 12
  • 19
6
votes
1 answer

Ignore commented out code when using YARD

I have some Ruby code that looks like this: # some_string = "{really?}" where the curly braces need to be part of the string. This line is commented out code that I'd like to remain there. I'm additionally using YARD to document code, so when I run…
Gordon Seidoh Worley
  • 7,839
  • 6
  • 45
  • 82
6
votes
1 answer

Document block taking no parameters

I'm writing my first gem which I'm documenting with YARD. I've made one of my classes have a constructor which expects a block which takes no arguments1. YARD provides the @yield [params] description tag to describe a block argument in terms of the…
Chowlett
  • 45,935
  • 20
  • 116
  • 150
6
votes
1 answer

Using a rakefile to generate docs from source

I downloaded the ruby Twitter gem source code and am trying to generate the documentation using yard, which I installed via gem install yard. In the rakefile, I found the following, which I assume is used to generate the docs for the Twitter…
BrainLikeADullPencil
  • 11,313
  • 24
  • 78
  • 134
6
votes
3 answers

DRYing yard parameters

I've got what i assumed was a fairly basic yard macro usage where i have a Hash structure with a number of options that is shared between multiple functions. I was hoping to use a macro simply to prevent me having to replicate this structure all…
jamielennox
  • 368
  • 1
  • 2
  • 9
1 2
3
12 13