The ScopeData module

Handling RakuDoc v2 block scope concept.

=begin rakudoc :type<fundamental>

AUTHOR

Richard Hainsworth aka finanalyst

VERSION

v0.2.1

Purpose

RakuDoc v2 introduces the concept of a block scope. The choice of terminology is to avoid some of the complexities of Raku's 'lexical scope'.

Basically a block scope is started by a =begin BLOCKNAME and ended by a =end BLOCKNAME.

Within a block scope, several directives may affect other RakuDoc features within the same block, such as =config and =alias.

Once the block has ended, the effect of such directives end.

The ScopedData class was written to track and handle this sort of behaviour.

Typically only one ScopedData object is instantiated.

The following pieces of information are tracked:

  • starter - the block that starts a scope

  • titles - the title of the block starting the scope

  • config - the accumulated config data

    • config data is a hash for each block

    • the value for each block is the metadata option available for such a block

  • alias - alias defined for the scope

  • items-numeration - the current numeration for items

  • defns-numeration - the current numeration for defns

Method diagnostic()

Provides information about all block scopes. A ScopeData object has an attribute debug. If set to True then diagnostic is called by start-scope and end-scope.

Method < start-scope( :$starter!, :$title, :$verbatim ) >

Starts a new scope. When a scope is started, all the previous information is copied.

This information can be changed within the scope.

If verbatim is set, then all strings will be rendered without removing spaces or new lines.

Method end-scope

Changes to items tracked by the object are forgotten.

< multi method config(%h)>

Add key/value pair to the existing scope's config

< multi method config( --> Hash )>

Get the current scope's config

< multi method aliases(%h)>

Add key/value pair to the existing scope's aliases

< multi method aliases( --> Hash )>

Get the current scope's aliases

< method last-starter >

Return the last starter block

< multi method last-title() >

Return the most recent title

< multi method last-title( $s )>

Change the title for the current block

< multi method verbatim()>

Change the state of the verbatim flag to True

< multi method verbatim( :called-by($)! )>

Which block set the verbatim flag

< multi method item-inc( $level --> Str )>

Increment the item numeration at the required level, returns the result. See Numeration module for more detail

< multi method item-reset()>

Reset the item numeration altogether

< multi method defn-inc( --> Str )>

Increment the defn numeration, only one level

< multi method defn-reset()>

Reset the defn numeration

=place semantic:AUTHOR :caption<Credits>

=place semantic:VERSION :!toc

=end rakudoc

Rakuast::RakuDoc::Render v1.0.14

Renders RakuDoc v2 to text, HTML, HTML-Extra, Markdown

Authors

  • Richard Hainsworth

License

Artistic-2.0

Dependencies

Test::Deeply::RelaxedPrettyDumpTest::OutputLibCurlURIDigest::SHA1::NativeText::MiscUtilsMethod::ProtectedTest::RunRakuAST::Deparse::HighlightRainbow:ver<0.3.0+>File::Directory::TreeJSON::FastYAMLishXML

Test Dependencies

Provides

  • RakuDoc::Citations
  • RakuDoc::MarkupMeta
  • RakuDoc::Numeration
  • RakuDoc::Plugin::HTML::Bulma
  • RakuDoc::Plugin::HTML::FontAwesome
  • RakuDoc::Plugin::HTML::Graphviz
  • RakuDoc::Plugin::HTML::Hilite
  • RakuDoc::Plugin::HTML::Latex
  • RakuDoc::Plugin::HTML::LeafletMaps
  • RakuDoc::Plugin::HTML::ListFiles
  • RakuDoc::Plugin::HTML::SCSS
  • RakuDoc::Plugin::Markdown::Graphviz
  • RakuDoc::Processed
  • RakuDoc::PromiseStrings
  • RakuDoc::Render
  • RakuDoc::ScopedData
  • RakuDoc::Templates
  • RakuDoc::To::Generic
  • RakuDoc::To::HTML
  • RakuDoc::To::HTML-Extra
  • RakuDoc::To::Markdown
  • RenderDocs

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.