# Class: YARD::Templates::TemplateOptions

Inherits:
  Options
  - Object
  - Options
  - YARD::Templates::TemplateOptions
  show all

Defined in:
  lib/yard/templates/template_options.rb

## Overview

An Options class containing default options for base template rendering. For options specific to generation of HTML output, see CLI::YardocOptions.

See Also:

- CLI::YardocOptions

## Direct Known Subclasses

CLI::GraphOptions, CLI::YardocOptions

## Instance Attribute Summary collapse

- #default_return ⇒ String

  The default return type for a method with no return tags.

- #embed_mixins ⇒ Array<String>

  An array of module name wildcards to embed into class documentation as if their methods were defined directly in the class.

- #format ⇒ Symbol

  The template output format.

- #globals ⇒ OpenStruct (also: #__globals)

  An open struct containing any global state across all generated objects in a template.

- #hide_void_return ⇒ Boolean

  Whether void methods should show “void” in their signature.

- #highlight ⇒ Boolean

  Whether code blocks should be syntax highlighted.

- #index ⇒ Boolean

  Whether the page is the “index”.

- #markup ⇒ Symbol

  The markup format to use when parsing docstrings.

- #markup_provider ⇒ Class

  The markup provider class for the markup format.

- #no_highlight ⇒ Boolean deprecated Deprecated.

  use #highlight instead.

- #object ⇒ CodeObjects::Base

  The main object being generated in the template.

- #owner ⇒ CodeObjects::Base

  The owner of the generated object.

- #page_title ⇒ String

  The title of a given page.

- #serialize ⇒ Boolean

  Whether serialization should be performed.

- #serializer ⇒ Serializers::Base

  The serializer used to generate links and serialize output.

- #template ⇒ Symbol

  The template name used to render output.

- #type ⇒ Symbol

  The template type used to generate output.

- #verifier ⇒ Verifier

  The verifier object.

## Instance Method Summary collapse

- #embed_mixins_match?(mixin) ⇒ Boolean?

## Dynamic Method Handling

This class handles dynamic methods through the `method_missing` method in the class YARD::Options

## Instance Attribute Details

### #default_return ⇒ `String`

Returns the default return type for a method with no return tags.

Returns:

- (`String`) —

  the default return type for a method with no return tags

    20

    # File 'lib/yard/templates/template_options.rb', line 20

    default_attr :default_return, "Object"

### #embed_mixins ⇒ `Array<String>`

Returns an array of module name wildcards to embed into class documentation as if their methods were defined directly in the class. Useful for modules like ClassMethods. If the name contains ‘::’, the module is matched against the full mixin path, otherwise only the module name is used.

#### Examples:

#####

A list of mixin path names (including wildcards)

    opts.embed_mixins #=> ['ClassMethods', '*Helper', 'YARD::*']

Returns:

- (`Array<String>`) —

  an array of module name wildcards to embed into class documentation as if their methods were defined directly in the class. Useful for modules like ClassMethods. If the name contains ‘::’, the module is matched against the full mixin path, otherwise only the module name is used.

    71

    # File 'lib/yard/templates/template_options.rb', line 71

    default_attr :embed_mixins, lambda { [] }

### #format ⇒ `Symbol`

Returns the template output format.

Returns:

- (`Symbol`) —

  the template output format

    11

    # File 'lib/yard/templates/template_options.rb', line 11

    default_attr :format, :text

### #globals ⇒ `OpenStruct` Also known as: __globals

Returns an open struct containing any global state across all generated objects in a template.

Returns:

- (`OpenStruct`) —

  an open struct containing any global state across all generated objects in a template.

    33

    # File 'lib/yard/templates/template_options.rb', line 33

    default_attr :globals, lambda { OpenStruct.new }

### #hide_void_return ⇒ `Boolean`

Returns whether void methods should show “void” in their signature.

Returns:

- (`Boolean`) —

  whether void methods should show “void” in their signature

    23

    # File 'lib/yard/templates/template_options.rb', line 23

    default_attr :hide_void_return, false

### #highlight ⇒ `Boolean`

Returns whether code blocks should be syntax highlighted.

Returns:

- (`Boolean`) —

  whether code blocks should be syntax highlighted

    26

    # File 'lib/yard/templates/template_options.rb', line 26

    default_attr :highlight, true

### #index ⇒ `Boolean`

Returns whether the page is the “index”.

Returns:

- (`Boolean`) —

  whether the page is the “index”

    63
    64
    65

    # File 'lib/yard/templates/template_options.rb', line 63

    def index
      @index
    end

### #markup ⇒ `Symbol`

Returns the markup format to use when parsing docstrings.

Returns:

- (`Symbol`) —

  the markup format to use when parsing docstrings

    17

    # File 'lib/yard/templates/template_options.rb', line 17

    default_attr :markup, :rdoc

### #markup_provider ⇒ `Class`

Returns the markup provider class for the markup format.

Returns:

- (`Class`) —

  the markup provider class for the markup format

    29
    30
    31

    # File 'lib/yard/templates/template_options.rb', line 29

    def markup_provider
      @markup_provider
    end

### #no_highlight ⇒ `Boolean`

Deprecated.

use #highlight instead.

Returns whether highlighting should be ignored.

Returns:

- (`Boolean`) —

  whether highlighting should be ignored

    54
    55
    56

    # File 'lib/yard/templates/template_options.rb', line 54

    def no_highlight
      @no_highlight
    end

### #object ⇒ `CodeObjects::Base`

Returns the main object being generated in the template.

Returns:

- (`CodeObjects::Base`) —

  the main object being generated in the template

    37
    38
    39

    # File 'lib/yard/templates/template_options.rb', line 37

    def object
      @object
    end

### #owner ⇒ `CodeObjects::Base`

Returns the owner of the generated object.

Returns:

- (`CodeObjects::Base`) —

  the owner of the generated object

    40
    41
    42

    # File 'lib/yard/templates/template_options.rb', line 40

    def owner
      @owner
    end

### #page_title ⇒ `String`

Returns the title of a given page.

Returns:

- (`String`) —

  the title of a given page

    60
    61
    62

    # File 'lib/yard/templates/template_options.rb', line 60

    def page_title
      @page_title
    end

### #serialize ⇒ `Boolean`

Returns whether serialization should be performed.

Returns:

- (`Boolean`) —

  whether serialization should be performed

    46

    # File 'lib/yard/templates/template_options.rb', line 46

    default_attr :serialize, true

### #serializer ⇒ `Serializers::Base`

Returns the serializer used to generate links and serialize output. Serialization output only occurs if #serialize is `true`.

Returns:

- (`Serializers::Base`) —

  the serializer used to generate links and serialize output. Serialization output only occurs if #serialize is `true`.

    50
    51
    52

    # File 'lib/yard/templates/template_options.rb', line 50

    def serializer
      @serializer
    end

### #template ⇒ `Symbol`

Returns the template name used to render output.

Returns:

- (`Symbol`) —

  the template name used to render output

    14

    # File 'lib/yard/templates/template_options.rb', line 14

    default_attr :template, :default

### #type ⇒ `Symbol`

Returns the template type used to generate output.

Returns:

- (`Symbol`) —

  the template type used to generate output

    43
    44
    45

    # File 'lib/yard/templates/template_options.rb', line 43

    def type
      @type
    end

### #verifier ⇒ `Verifier`

Returns the verifier object.

Returns:

- (`Verifier`) —

  the verifier object

    88
    89
    90

    # File 'lib/yard/templates/template_options.rb', line 88

    def verifier
      @verifier
    end

## Instance Method Details

### #embed_mixins_match?(mixin) ⇒ `Boolean`?

Parameters:

- mixin (`CodeObjects::Base`) —

  accepts any code object, but returns nil unless the object is a module.

Returns:

- (`Boolean`) —

  whether a mixin matches the embed_mixins list

- (`nil`) —

  if the mixin is not a module object

    77
    78
    79
    80
    81
    82
    83
    84
    85

    # File 'lib/yard/templates/template_options.rb', line 77

    def embed_mixins_match?(mixin)
      return true if mixin == object # the method is not inherited
      return nil unless mixin.is_a?(CodeObjects::ModuleObject)
      embed_mixins.any? do |embed_mixin|
        re = /\A#{Regexp.quote(embed_mixin).gsub('\*', '.*')}\Z/
        matchstr = embed_mixin.include?("::") ? mixin.path : mixin.name
        re.match(matchstr.to_s)
      end
    end