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
1
vote
2 answers

Is there a Ruby documentation tool that allows inclusion of diagrams and images?

I am a big fan of doxygen which I have used for years with various languages. In particular, I appreciate its wiki-like ability to include images and run the Graphviz dot generator to have arbitrary inline diagrams from inline DOT code or external…
Andy Dent
  • 17,578
  • 6
  • 88
  • 115
1
vote
1 answer

Dynamic documentation, using the return of method in the description of another YARD?

I am documenting a project and essientially I have something similar to the following: def foo return bar(__method__) end def bar (method) return method.to_s + 'somestring' end I am setting up a multitude of methods similar to how I have…
rudolph9
  • 8,021
  • 9
  • 50
  • 80
0
votes
1 answer

YARD and RDoc compatibility

If I document my code with YARD, and use e.g. the @overload tag, and someone else installs my gem and it generates the documentation with RDoc, won't the result be messy? Is there a good way to deal with this?
mydoghasworms
  • 18,233
  • 11
  • 61
  • 95
0
votes
1 answer

YARD: How to generate vendor plugin documentation?

I am using Ruby on Rails 3.1.0 and the YARD 0.7.4 gem for documentation purposes. I implemented a working plugin (in the ROOT_APP/vendor/plugins/ directory) and I would like to document that plugin. Note: When I run the yard doc…
user12882
  • 4,702
  • 9
  • 39
  • 54
0
votes
1 answer

How can I generate documentation related to my plugin?

I am using Rails 3.1.0 and I have implemented a working plugin. As well as it should be done, its related files are located in the ROOT_APP/vendor/plugins/my_plugin directory. Now, I am using the YARD 0.7.4 gem and I would like to document that…
Backo
  • 18,291
  • 27
  • 103
  • 170
0
votes
1 answer

Change yardoc serialized_path

Right now Yardoc will generate docs like: doc/ModuleName.html, doc/ModuleName/ClassName.html and doc/ModuleName/ClassName/method_name.html I was wondering how I can adjust serialized_path (without monkey patching everything) to do something like:…
Jordon Bedwell
  • 3,189
  • 3
  • 23
  • 32
0
votes
0 answers

Can I get all @examples from my YARD docs?

I would like to extract all the @example code in my YARD documentation. Then I can test them to alert me if they need to be updated. For example... # @example # obj = Some::Object.new # obj.method(1,2,3) def method(a, b, c) ... end I would…
Schwern
  • 153,029
  • 25
  • 195
  • 336
0
votes
2 answers

How can I document a subclass method with YARD?

How can I document a method that a subclass overrides without being redundant? For example... class Parent # Is this the parent? # @return [Boolean] def parent? true end end class Child < Parent def parent? false end end YARD…
Schwern
  • 153,029
  • 25
  • 195
  • 336
0
votes
1 answer

Can YARD be used to declare @return type as type of one of the arguments?

What I want to do is basically: # @param [class] cls # @return [instanceof(cls)] def get(cls) # Imagine this is method and object has property @instances = {} if !@instances.keys.include?(cls) @instances[cls] = cls.new() end …
idchlife
  • 554
  • 1
  • 6
  • 16
0
votes
0 answers

Ruby yard documenting DSL method definition AND its uses>

Ruby with Yard 0.9.8. I'm defining custom attribute accessors in a ClassMethods module that will be extended into classed and other modules. What I want to do is document what the DSL accessor methods do and attach that to their definitions, but…
RoUS
  • 1,888
  • 2
  • 14
  • 29
0
votes
1 answer

YARD How to document block argument type?

Is there a way to avoid creating temporary variables just to document block's argument YARD type? The snippet below works but these temporary variables doesn't look good. foos.each_with_object(Set.new) do |foo, obj| # @type [Set] set = obj #…
BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91
0
votes
1 answer

YARD convention for "any" object as a parameter

How to document a YARD parameter that could be of any type possible? Is there a convention for it? This is similar to Any type in TypeScript # @param [?] var1 def create_foo(var1) # var1 could be anything end
BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91
0
votes
1 answer

How to use Yard to document enumerable type and the types that they contain?

Using the ruby Yard doc tool I can write # @param bar [String] def foo(bar) end however if the parameter is an enumerable # @param bar [Enumerable[String]] def foo(bar) end Is the above the correct way or not?
bradgonesurfing
  • 30,949
  • 17
  • 114
  • 217
0
votes
1 answer

Sorbet `srb init` fails with Kernel#exit due to conflict with yard gem

We're starting to use Sorbet at work and srb init throws an error requiring yard. Files still generated and seemed to work fine until srb tc started to produce errors like the following: sorbet/rbi/todo.rbi:38: PG::Error was previously defined as a…
melcher
  • 1,543
  • 9
  • 15
0
votes
0 answers

How should a Command Pattern inspired class be documented in YARD

While building a Project in Ruby I am required to document every important piece of code with RDoc, using YARD, the bulk of the work is done via Command Patterns Classes (from GOF). The main structure of a Command Pattern is similar to this…
Lomefin
  • 1,173
  • 12
  • 43