class YARD::Tags::Library

Keeps track of all the registered meta-data tags and directives. Also allows for defining of custom tags and customizing the tag parsing syntax.

Defining Custom Meta-Data Tags

To define a custom tag, use {define_tag}. You should pass the tag name and the factory method to use when creating the tag. If you do not provide a factory method to use, it will default to {DefaultFactory#parse_tag}

You can also define tag objects manually by simply implementing a “tagname_tag” method that returns a {Tag} object, but they will not take advantage of tag factory parsing:

def mytag_tag(text)
  Tag.new(:mytag, text)
end

Defining Custom Directives

Directives can be defined by calling the {define_directive} method, taking the directive name, an optional tag factory parser method (to parse the data in the directive into a temporary {Tag} object) and a {Directive} subclass that performs the directive processing. For more information on creating a Directive subclass, see the {Directive} class documentation.

Similar to tags, Directives can also be defined manually, in this case using the method name “mydirective_directive” and returning a new {Directive} object:

def mydirective_directive(tag, parser)
  MyDirective.new(tag, parser)
end

Namespaced Tags

In YARD 0.8.0+, tags can be namespaced using the ‘.’ character. It is recommended to namespace project specific tags, like +@yard.tag_name+, so that tags do not collide with other plugins or new built-in tags.

Adding/Changing the Tag Syntax

If you have specialized tag parsing needs you can substitute the {#factory} object with your own by setting {Library.default_factory= Library.default_factory} to a new class with its own parsing methods before running YARD. This is useful if you want to change the syntax of existing tags (@see, @since, etc.)

@example Defining a custom tag

define_tag "Parameter", :param, :with_types_and_name
define_tag "Author", :author

@example Defining a custom directive

define_directive :method, :with_title_and_text, MethodDirective

@see DefaultFactory @see define_tag @see define_directive @see Directive