role Metamodel::Documenting { }

Warning: this role is part of the Rakudo implementation, and is not a part of the language specification.

Type declarations may include declarator blocks (#| and #=), which allow you to set the type's documentation. This can then be accessed through the WHY method on objects of that type:

#|[Documented is an example class for Metamodel::Documenting's documentation.] 
class Documented { }
#=[Take a look at my WHY!] 
 
say Documented.WHY;
# OUTPUT: 
# Documented is an example class for Metamodel::Documenting's documentation. 
# Take a look at my WHY! 

Metamodel::Documenting is what implements this behavior for types. This example can be rewritten to use its methods explicitly like so:

BEGIN {
    our Mu constant Documented = Metamodel::ClassHOW.new_type: :name<Documented>;
    Documented.HOW.compose: Documented;
    Documented.HOW.set_why: do {
        my Pod::Block::Declarator:D $pod .= new;
        $pod._add_leading:  "Documented is an example class for Metamodel::Documenting's documentation.";
        $pod._add_trailing: "Take a look at my WHY!";
        $pod
    };
}
 
say Documented.HOW.WHY;
# OUTPUT: 
# Documented is an example class for Metamodel::Documenting's documentation. 
# Take a look at my WHY! 

It typically isn't necessary to handle documentation for types directly through their HOW like this, as Metamodel::Documenting's methods are exposed through Mu via its WHY and set_why methods, which are usable on types in most cases.

Methods §

method set_why §

method set_why($why)

Sets the documentation for a type to $why.

method WHY §

method WHY()

Returns the documentation for a type.

Type Graph §

Type relations for Metamodel::Documenting
perl6-type-graph Metamodel::Documenting Metamodel::Documenting Mu Mu Any Any Any->Mu Metamodel::Naming Metamodel::Naming Metamodel::SubsetHOW Metamodel::SubsetHOW Metamodel::SubsetHOW->Metamodel::Documenting Metamodel::SubsetHOW->Any Metamodel::SubsetHOW->Metamodel::Naming Metamodel::Versioning Metamodel::Versioning Metamodel::Stashing Metamodel::Stashing Metamodel::TypePretense Metamodel::TypePretense Metamodel::MethodDelegation Metamodel::MethodDelegation Metamodel::ModuleHOW Metamodel::ModuleHOW Metamodel::ModuleHOW->Metamodel::Documenting Metamodel::ModuleHOW->Any Metamodel::ModuleHOW->Metamodel::Naming Metamodel::ModuleHOW->Metamodel::Versioning Metamodel::ModuleHOW->Metamodel::Stashing Metamodel::ModuleHOW->Metamodel::TypePretense Metamodel::ModuleHOW->Metamodel::MethodDelegation Metamodel::DefiniteHOW Metamodel::DefiniteHOW Metamodel::DefiniteHOW->Metamodel::Documenting Metamodel::DefiniteHOW->Any Metamodel::AttributeContainer Metamodel::AttributeContainer Metamodel::Finalization Metamodel::Finalization Metamodel::MethodContainer Metamodel::MethodContainer Metamodel::PrivateMethodContainer Metamodel::PrivateMethodContainer Metamodel::MultiMethodContainer Metamodel::MultiMethodContainer Metamodel::RoleContainer Metamodel::RoleContainer Metamodel::MultipleInheritance Metamodel::MultipleInheritance Metamodel::DefaultParent Metamodel::DefaultParent Metamodel::C3MRO Metamodel::C3MRO Metamodel::MROBasedMethodDispatch Metamodel::MROBasedMethodDispatch Metamodel::MROBasedTypeChecking Metamodel::MROBasedTypeChecking Metamodel::Trusting Metamodel::Trusting Metamodel::BUILDPLAN Metamodel::BUILDPLAN Metamodel::Mixins Metamodel::Mixins Metamodel::BoolificationProtocol Metamodel::BoolificationProtocol Metamodel::ClassHOW Metamodel::ClassHOW Metamodel::ClassHOW->Metamodel::Documenting Metamodel::ClassHOW->Any Metamodel::ClassHOW->Metamodel::Naming Metamodel::ClassHOW->Metamodel::Versioning Metamodel::ClassHOW->Metamodel::Stashing Metamodel::ClassHOW->Metamodel::AttributeContainer Metamodel::ClassHOW->Metamodel::Finalization Metamodel::ClassHOW->Metamodel::MethodContainer Metamodel::ClassHOW->Metamodel::PrivateMethodContainer Metamodel::ClassHOW->Metamodel::MultiMethodContainer Metamodel::ClassHOW->Metamodel::RoleContainer Metamodel::ClassHOW->Metamodel::MultipleInheritance Metamodel::ClassHOW->Metamodel::DefaultParent Metamodel::ClassHOW->Metamodel::C3MRO Metamodel::ClassHOW->Metamodel::MROBasedMethodDispatch Metamodel::ClassHOW->Metamodel::MROBasedTypeChecking Metamodel::ClassHOW->Metamodel::Trusting Metamodel::ClassHOW->Metamodel::BUILDPLAN Metamodel::ClassHOW->Metamodel::Mixins Metamodel::ClassHOW->Metamodel::BoolificationProtocol Metamodel::NativeHOW Metamodel::NativeHOW Metamodel::NativeHOW->Metamodel::Documenting Metamodel::NativeHOW->Any Metamodel::NativeHOW->Metamodel::Naming Metamodel::NativeHOW->Metamodel::Versioning Metamodel::NativeHOW->Metamodel::Stashing Metamodel::NativeHOW->Metamodel::MultipleInheritance Metamodel::NativeHOW->Metamodel::C3MRO Metamodel::NativeHOW->Metamodel::MROBasedMethodDispatch Metamodel::NativeHOW->Metamodel::MROBasedTypeChecking Metamodel::PackageHOW Metamodel::PackageHOW Metamodel::PackageHOW->Metamodel::Documenting Metamodel::PackageHOW->Any Metamodel::PackageHOW->Metamodel::Naming Metamodel::PackageHOW->Metamodel::Stashing Metamodel::PackageHOW->Metamodel::TypePretense Metamodel::PackageHOW->Metamodel::MethodDelegation Metamodel::RolePunning Metamodel::RolePunning Metamodel::ParametricRoleHOW Metamodel::ParametricRoleHOW Metamodel::ParametricRoleHOW->Metamodel::Documenting Metamodel::ParametricRoleHOW->Any Metamodel::ParametricRoleHOW->Metamodel::Naming Metamodel::ParametricRoleHOW->Metamodel::Versioning Metamodel::ParametricRoleHOW->Metamodel::Stashing Metamodel::ParametricRoleHOW->Metamodel::TypePretense Metamodel::ParametricRoleHOW->Metamodel::AttributeContainer Metamodel::ParametricRoleHOW->Metamodel::MethodContainer Metamodel::ParametricRoleHOW->Metamodel::PrivateMethodContainer Metamodel::ParametricRoleHOW->Metamodel::MultiMethodContainer Metamodel::ParametricRoleHOW->Metamodel::RoleContainer Metamodel::ParametricRoleHOW->Metamodel::MultipleInheritance Metamodel::ParametricRoleHOW->Metamodel::RolePunning

Expand above chart

Generated from