class Documentable::Registry

Container of all our knowledge.

class Documentable::Registry {}

An instance of this object is used to deal with a collection of Documentable objects. It gives you an API to access all the processed documentation. We can say this class is our source of information.

Methods

method documentables

Defined as

method documentables(--> Array[Documentable::Primary])

Returns an Array containing all Documentable::Primary objects created.

method definitions

Defined as

method definitions(--> Array[Documentable::Secondary])

Returns an Array containing all Documentable::Secondary objects created.

method references

Defined as

method references(--> Array[Documentable::Index])

Returns an Array containing all Documentable::References objects created.

method docs

Defined as

method docs(--> Array[Documentable])

Returns an Array containing all Documentable objects created. Equivalent to join documentables, definitions and references.

method composed

Defined as

method composed(--> Bool)

Returns a Bool indicating is the registry is composed.

method tg

Defined as

method tg(--> TypeGraph)

Returns the instance of TypeGraph used to complete the type files.

method routines-by-type

Defined as

method  routines-by-type(--> Hash)

Returns a Hash with the following structure:

So, if you have a class Any, with two methods, method1 and method2 then:

my $registry = (suppose it's correctly initialized);
 
# This will return two Documentable::Secondary objects containing the 
# definition of method1 and method2. 
say $registry.routines-by-type<Any>;
 

method pod-cache

Defined as

method pod-cache(--> Pod::From::Cache)

Returns the the cache object used.

method topdir

Defined as

method topdir(--> Str)

Returns a Str indicating the directory used as $topdir.

submethod BUILD

Defined as

submethod BUILD(Str :$topdir = "doc":@dirs = [], Bool :$verbose = True)

Creates a new instance of the class.

Example:

use Documentable::Registry;
 
my $registry = Documentable::Registry.new(
    topdir    => "doc",                # doc containing the pod collection 
    dirs      => ["Type""Language"], # dirs to process 
    verbose   => True,
);
 
# to complete the processing and initialize some attributes 
$registry.compose;
 

method add-new

Defined as

method add-new(--> Documentable::Primary)

Adds a new Documentable::Primary object to the registry and returns it.

Warning: if the registry is composed, you cannot add new objects to it.

method load

Defined as

method load(Str :$path --> Positional[Pod::Block::Named])

Loads a new pod6 file from the cache.

method process-pod-dir

Defined as

method process-pod-dir(Str :$dir --> Array[Documentable::Primary])

Returns an Array containing all Documentable::Primary objects created after processing the contents of $topdir/$dir.

method compose

Defined as

method compose(--> Bool)

method lookup

Defined as

method lookup(Str $whatStr $by --> Hash)

This method will classify all Documentable objects in the Documentable::Registry using the attribute $by and will return all of those whose attribute $by is set to $what. These queries are cached the first time they are made, so next calls to this method will be faster.

Example:

my $registry = (... initialize ...)
 
# query all Documentable objects with $.kind 
# set to Kind::Type 
$registry.lookup(Kind::Type.Str:by<kind>)
 

method docs-for

Defined as

method docs-for(Str $name)

Returns all Documentable objects with $.name set to $name.

Equivalent to .lookup($name, :by<name>).

Type Graph

Type relations for Documentable::Registry
perl6-type-graph Documentable::Registry Documentable::Registry Any Any Documentable::Registry->Any

Expand above chart