Class: YARD::Templates::TemplateOptions

Inherits:
Options
  • Object
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:

Direct Known Subclasses

CLI::GraphOptions, CLI::YardocOptions

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

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

Instance Attribute Details

#default_returnString

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



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

default_attr :default_return, "Object"

#embed_mixinsArray<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.



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

default_attr :embed_mixins, lambda { [] }

#formatSymbol

Returns the template output format.

Returns:

  • (Symbol)

    the template output format



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

default_attr :format, :text

#globalsOpenStruct 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.



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

default_attr :globals, lambda { OpenStruct.new }

#hide_void_returnBoolean

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

Returns:

  • (Boolean)

    whether void methods should show “void” in their signature



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

default_attr :hide_void_return, false

#highlightBoolean

Returns whether code blocks should be syntax highlighted.

Returns:

  • (Boolean)

    whether code blocks should be syntax highlighted



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

default_attr :highlight, true

#indexBoolean

Returns whether the page is the “index”.

Returns:

  • (Boolean)

    whether the page is the “index”



64
65
66
# File 'lib/yard/templates/template_options.rb', line 64

def index
  @index
end

#markupSymbol

Returns the markup format to use when parsing docstrings.

Returns:

  • (Symbol)

    the markup format to use when parsing docstrings



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

default_attr :markup, :rdoc

#markup_providerClass

Returns the markup provider class for the markup format.

Returns:

  • (Class)

    the markup provider class for the markup format



30
31
32
# File 'lib/yard/templates/template_options.rb', line 30

def markup_provider
  @markup_provider
end

#no_highlightBoolean

Deprecated.

use #highlight instead.

Returns whether highlighting should be ignored.

Returns:

  • (Boolean)

    whether highlighting should be ignored



55
56
57
# File 'lib/yard/templates/template_options.rb', line 55

def no_highlight
  @no_highlight
end

#objectCodeObjects::Base

Returns the main object being generated in the template.

Returns:



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

def object
  @object
end

#ownerCodeObjects::Base

Returns the owner of the generated object.

Returns:



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

def owner
  @owner
end

#page_titleString

Returns the title of a given page.

Returns:

  • (String)

    the title of a given page



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

def page_title
  @page_title
end

#serializeBoolean

Returns whether serialization should be performed.

Returns:

  • (Boolean)

    whether serialization should be performed



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

default_attr :serialize, true

#serializerSerializers::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.



51
52
53
# File 'lib/yard/templates/template_options.rb', line 51

def serializer
  @serializer
end

#templateSymbol

Returns the template name used to render output.

Returns:

  • (Symbol)

    the template name used to render output



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

default_attr :template, :default

#typeSymbol

Returns the template type used to generate output.

Returns:

  • (Symbol)

    the template type used to generate output



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

def type
  @type
end

#verifierVerifier

Returns the verifier object.

Returns:



89
90
91
# File 'lib/yard/templates/template_options.rb', line 89

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



78
79
80
81
82
83
84
85
86
# File 'lib/yard/templates/template_options.rb', line 78

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