Class | YARD::CLI::Yardoc
In: | lib/yard/cli/yardoc.rb
Parent: | Command

Yardoc is the default YARD CLI command (+yard doc+ and historic `yardoc` executable) used to generate and output (mainly) HTML documentation given a set of source files.

## Usage

Main usage for this command is:

      $ yardoc [options] [source_files [- extra_files]]

See +yardoc —help+ for details on valid options.

## Options File (+.yardopts+)

If a +.yardopts+ file is found in the source directory being processed, YARD will use the contents of the file as arguments to the command, treating newlines as spaces. You can use shell-style quotations to group space delimited arguments, just like on the command line.

A valid +.yardopts+ file might look like:

      --no-private
      --title "My Title"
      --exclude foo --exclude bar
      lib/**/*.erb
      lib/**/*.rb -
      HACKING.rdoc LEGAL COPYRIGHT

Note that Yardoc also supports the legacy RDoc style +.document+ file, though this file can only specify source globs to parse, not options.

## Queries (+—query+)

Yardoc supports queries to select specific code objects for which to generate documentation. For example, you might want to generate documentation only for your public API. If you‘ve documented your public methods with +@api public+, you can use the following query to select all of these objects:

      --query '@api.text == "public"'

Note that the syntax for queries is mostly Ruby with a few syntactic simplifications for meta-data tags. See the {Verifier} class for an overview of this syntax.

## Adding Custom Ad-Hoc Meta-data Tags (+—tag+)

YARD allows specification of {file:docs/Tags.md meta-data tags} programmatically via the {YARD::Tags::Library} class, but often this is not practical for users writing documentation. To make adding custom tags easier, Yardoc has a few command-line switches for creating basic tags and displaying them in generated HTML output.

To specify a custom tag to be displayed in output, use any of the following:

- +—tag+ TAG:TITLE
- +—name-tag+ TAG:TITLE
- +—type-tag+ TAG:TITLE
- +—type-name-tag+ TAG:TITLE
- +—title-tag+ TAG:TITLE

"TAG:TITLE" is of the form: name:"Display Title", for example:

      --tag overload:"Overloaded Method"

See +yardoc —help+ for a description of the various options.

Tags added in this way are automatically displayed in output. To add a meta-data tag that does not show up in output, use +—hide-tag TAG+. Note that you can also use this option on existing tags to hide builtin tags, for instance.

## Processed Data Storage (+.yardoc+ directory)

When Yardoc parses a source directory, it creates a +.yardoc+ directory (by default, override with +-b+) at the root of the project. This directory contains marshal dumps for all raw object data in the source, so that you can access it later for various commands (`stats`, `graph`, etc.). This directory is also used as a cache for any future calls to `yardoc` so as to process only the files which have changed since the last call.

When Yardoc uses the cache in subsequent calls to `yardoc`, methods or classes that have been deleted from source since the last parsing will not be erased from the cache (YARD never deletes objects). In such a case, you should wipe the cache and do a clean parsing of the source tree. You can do this by deleting the +.yardoc+ directory manually, or running Yardoc without +—use-cache+ (+-c+).

@since 0.2.1 @see Verifier

### Methods

all_objects description new parse_arguments run yardopts

### Constants

DEFAULT_YARDOPTS_FILE | = | ".yardopts" |  | The configuration filename to load extra options from

### Attributes

assets | [RW] | @return [Array<String>] a list of assets to copy after generation @since 0.6.0
excluded | [RW] | @return [Array<String>] list of excluded paths (regexp matches) @since 0.5.3
files | [RW] | @return [Array<String>] list of Ruby source files to process
generate | [RW] | @return [Boolean] whether to generate output
has_markup | [RW] | @return [Boolean] whether markup option was specified @since 0.7.0
hidden_tags | [RW] | @return [Array<Symbol>] a list of tags to hide from templates @since 0.6.0
list | [RW] | @return [Boolean] whether to print a list of objects @since 0.5.5
options | [R] | @return [Hash] the hash of options passed to the template. @see Templates::Engine#render
options_file | [RW] | The options file name (defaults to {DEFAULT_YARDOPTS_FILE}) @return [String] the filename to load extra options from
save_yardoc | [RW] | @return [Boolean] whether objects should be serialized to .yardoc db
statistics | [RW] | @return [Boolean] whether to print statistics after parsing @since 0.6.0

use_cache

[RW]

@return [Boolean] whether to use the existing yardoc db if the

      .yardoc already exists. Also makes use of file checksums to
      parse only changed files.

use_document_file | [RW] | @return [Boolean] whether to parse options from .document
use_yardopts_file | [RW] | @return [Boolean] whether to parse options from .yardopts
visibilities | [RW] | Keep track of which visibilities are to be shown @return [Array<Symbol>] a list of visibilities @since 0.5.6

### Public Class methods

new()

Creates a new instance of the commandline utility

### Public Instance methods

all_objects()

The list of all objects to process. Override this method to change which objects YARD should generate documentation for.

@deprecated To hide methods use the +@private+ tag instead. @return [Array<CodeObjects::Base>] a list of code objects to process

description()
parse_arguments(*args)

Parses commandline arguments @param [Array<String>] args the list of arguments @return [Boolean] whether or not arguments are valid @since 0.5.6

run(*args)

Runs the commandline utility, parsing arguments and generating output if set.

@param [Array<String>] args the list of arguments. If the list only

      contains a single nil value, skip calling of {#parse_arguments}

@return [void]

yardopts()

Parses the .yardopts file for default yard options @return [Array<String>] an array of options parsed from .yardopts

[Validate]