Skip to content

YARD doc DSL handler #2

Description

@SleeplessByte

Description

YARD needs custom handlers to pickup our DSL and automagically document it.

Proposed Solution

Add handler so that the following may be generated:

# @!method to_constructable
#   Returns the construtable media type
#
#   @see https://www.rubydoc.info/gems/media_types/MediaTypes/Constructable ::MediaTypes::Constructable
#   @return [::MediaTypes::Constructable] a constructable
#
media_type 'x'
# @!method valid?(data, constructed_media_type, **opts)
#   Validates the +data+ against the validation for +constructed_media_type+.
#
#   @see https://www.rubydoc.info/gems/media_types/MediaTypes/Scheme#valid%3F-instance_method ::MediaTypes::Scheme#valid?
#   @see https://www.rubydoc.info/gems/media_types/MediaTypes/Constructable#valid%3F-instance_method ::MediaTypes::Constructable#valid?
#
#   @param [Object] data the data to validate
#   @param [Constructable, String] constructed_media_type something that resolved into a media type with validations
#   @param [Hash] opts passed on to {::MediaTypes::Scheme#valid?}
#
#   @return [TrueClass, FalseClass] true if valid, false otherwise
#
# @!method validate!(data, constructed_media_type, **opts)
#   Validates the +data+ against the validation for +constructed_media_type+. Raises if invalid
#
#   @see https://www.rubydoc.info/gems/media_types/MediaTypes/Scheme#validate-instance_method ::MediaTypes::Scheme#validate
#   @see https://www.rubydoc.info/gems/media_types/MediaTypes/Constructable#validate!-instance_method ::MediaTypes::Constructable#validate!
#   @see https://www.rubydoc.info/gems/media_types/MediaTypes/Scheme/ValidationError ::MediaTypes::Scheme::ValidationError
#
#   @param [Object] data the data to validate
#   @param [Constructable, String] constructed_media_type something that resolved into a media type with validations
#   @param [Hash] opts passed on to {::MediaTypes::Scheme#validate}
#
#   @raise ::MediaTypes::Scheme::ValidationError an error if the scheme is not valid
#   @return [TrueClass] true if valid
#
validations do
end
# @!method register
#   Registers all the known permutations of versions, views, suffixes and aliases for this media type via
#   {::MediaTypes.register}
#
#   @see https://www.rubydoc.info/gems/media_types/MediaTypes#register-class-method ::Mediatypes.register
#   @see https://www.rubydoc.info/gems/media_types/MediaTypes/Registerable ::Mediatypes::Registerable
#
#   @return [Array<::MediaTypes::Registerable>]
registrations :x do
end

Additional Context

https://yardoc.org/guides/extending-yard/writing-handlers.html

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions