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
10
votes
1 answer

Yard doc and `define_method`

Is there a way to comment methods defined with define_method in YardDoc? I tried this: %w(one two three).each do |type| # The #{type} way # @return [String] the #{type} way define_method("#{type}_way") do ... end end But, unfortunately, not…
JoJoS
  • 1,971
  • 2
  • 13
  • 15
10
votes
2 answers

YARD: how to create a link to a class method?

How do you create a link to a ruby class method with YARD? Here is the yard documentation regarding links. Linking to an instance method within the same namespace: {#my_instance_method} Which works fine. However, following that same approach with a…
anxiety
  • 1,689
  • 16
  • 25
10
votes
0 answers

Examples on translating raw data generated by YARD

On the YARD readme, there is mention of raw data generated by YARD: YARD also outputs documented objects as raw data (the dumped Namespace) which can be reloaded to do generation at a later date, or even auditing on code. This means that any…
austen
  • 3,314
  • 3
  • 25
  • 26
9
votes
1 answer

Document duck types with multiple methods in YARD

YARD allows me to specify types for method parameters and return values. As I really like to duck type it is nice to see that YARD also supports defining types by specifying methods they must support. As you can see here, expressions like…
aef
  • 4,498
  • 7
  • 26
  • 44
9
votes
2 answers

How to use Yard to document rails enum type

I have an ActiveRecord class similar to this: class User < ActiveRecord::Base # How do I document this? enum status [:registering, :active, :suspended, :deleted] end status attribute is used to build a state machine. How do I document that…
Favourite Onwuemene
  • 4,247
  • 8
  • 28
  • 46
9
votes
2 answers

How can one document a function with a variable number of arguments in YARD?

I have a function that take a variable number of arguments, like this: def myfun(*args) # ... end All args are of the same type (Symbol), so right now I document the function like if there were only one argument, saying it can take more than one,…
bfontaine
  • 18,169
  • 13
  • 73
  • 107
9
votes
3 answers

Documenting def_delegators with Yardoc

I have a class that uses the def_delegators method from the Forwardable module. I haven't found a way to get Yardoc to output documentation for it. I've tried using a macro but it won't output anything for these particular methods (everything else…
ian
  • 12,003
  • 9
  • 51
  • 107
9
votes
2 answers

Yard: Specify a different path for the compiled doc (instead of doc/)?

Is there any way to tell Yard not to clutter up my Rails project's doc/ folder? I'd like it to save its files in doc/yard/ or something like that. Sadly I didn't find any option for that. Thank you for help.
Joshua Muheim
  • 12,617
  • 9
  • 76
  • 152
8
votes
3 answers

Internal comments using YARD for Ruby documentation?

I'm in the process of switching over a rubygem I maintain from RDoc to YARD documentation. However, there are some critical comments in the code that need to remain only in the code and should not show up in the documentation. For instance: ## #…
Daisy Sophia Hollman
  • 6,046
  • 6
  • 24
  • 35
8
votes
1 answer

All Ruby documentation offline with yard

If I want see documentation on my gems I can do: yard server --gems How can I see the documentation of Ruby's standard library?
Rusty Robot
  • 1,305
  • 1
  • 12
  • 18
8
votes
1 answer

Hiding a method from YARD (the right way)

I am using YARD to document one of my Ruby projects. I have certain methods that I do not want to be included in the documentation, things like #inspect and #to_s that you expect to exist and return a reasonable result. It is possible to hide these…
Phrogz
  • 296,393
  • 112
  • 651
  • 745
8
votes
1 answer

How do I document generated classes in Yard?

I have a class that I create from a factory function like this: Cake = MyProject.Struct(:type, :price) In Yard, it's simply displayed along with my constants: Cake = Struct(:type, :price) I want it to show up in the "Classes: " list. After…
Hubro
  • 56,214
  • 69
  • 228
  • 381
8
votes
1 answer

How do I document methods where providing a block is optional?

I have a function documented like this: ## # Searches for street names in the local address database. Returns a list # of strings, or invokes the block for each result. # # @param [String, Hash] query # # Can be: # # - A search string with…
Hubro
  • 56,214
  • 69
  • 228
  • 381
8
votes
2 answers

Ruby YARD: documenting abstract methods implementations

I have a typical OO pattern: one base abstract class (that defines abstract methods) and several classes that implement these abstract methods in class-specific way. I'm used to write documentation only once in abstract methods and then it…
GreyCat
  • 16,622
  • 18
  • 74
  • 112
7
votes
0 answers

Yard doc and dynamic assignment of constants, instance, and class methods

I have a module I include to help define certain methods, constants and class methods. It is creating them all dynamically. I need help understanding how I can use Yard Doc's @macro feature to align the documentation and set the instance, class,…
thornomad
  • 6,707
  • 10
  • 53
  • 78
1
2
3
12 13