A class for parsed topics of source files. Also encompasses some of the TopicType-specific behavior.
NaturalDocs:: | A class for parsed topics of source files. |
Implementation | |
Members | The object is a blessed arrayref with the following indexes. |
Title, Package, and Symbol Behavior | Title, package, and symbol behavior is a little awkward so it deserves some explanation. |
Functions | |
New | Creates a new object. |
Type | Returns the TopicType. |
SetType | Replaces the TopicType. |
IsList | Returns whether the topic is a list. |
SetIsList | Sets whether the topic is a list. |
Title | Returns the title of the topic. |
SetTitle | Replaces the topic title. |
Symbol | Returns the SymbolString defined by the topic. |
Package | Returns the package SymbolString that the topic appears in. |
SetPackage | Replaces the package the topic appears in. |
Using | Returns an arrayref of additional scope SymbolStrings available to the topic via “using” statements, or undef if none. |
SetUsing | Replaces the using arrayref of sope SymbolStrings. |
Prototype | Returns the prototype if one is defined. |
SetPrototype | Replaces the function or variable prototype. |
Summary | Returns the topic summary, if it exists, formatted in NDMarkup. |
Body | Returns the topic’s body, formatted in NDMarkup. |
SetBody | Replaces the topic’s body, formatted in NDMarkup. |
LineNumber | Returns the line the topic appears at in the file. |
The object is a blessed arrayref with the following indexes.
TYPE | The TopicType. |
TITLE | The title of the topic. |
PACKAGE | The package SymbolString the topic appears in, or undef if none. |
USING | An arrayref of additional package SymbolStrings available to the topic via “using” statements, or undef if none. |
PROTOTYPE | The prototype, if it exists and is applicable. |
SUMMARY | The summary, if it exists. |
BODY | The body of the topic, formatted in NDMarkup. Some topics may not have bodies, and if not, this will be undef. |
LINE_NUMBER | The line number the topic appears at in the file. |
IS_LIST | Whether the topic is a list. |
Title, package, and symbol behavior is a little awkward so it deserves some explanation. Basically you set them according to certain rules, but you get computed values that try to hide all the different scoping situations.
Set them to the title and package as they appear. “Function” and “PkgA.PkgB” will return “Function” for the title, “PkgA.PkgB” for the package, and “PkgA.PkgB.Function” for the symbol.
In the rare case that a title has a separator symbol it’s treated as inadvertant, so “A vs. B” in “PkgA.PkgB” still returns just “PkgA.PkgB” for the package even though if you got it from the symbol it can be seen as “PkgA.PkgB.A vs”.
Set the title normally and leave the package undef. So “PkgA.PkgB” and undef will return “PkgA.PkgB” for the title as well as for the package and symbol.
The only time you should set the package is when you have full language support and they only documented the class with a partial title. So if you documented “PkgA.PkgB” with just “PkgB”, you want to set the package to “PkgA”. This will return “PkgB” as the title for presentation and will return “PkgA.PkgB” for the package and symbol, which is correct.
Set the title and package normally, do not set the package to undef. So “Global” and “PkgA.PkgB” will return “Global” as the title, “PkgA.PkgB” as the package, and “Global” as the symbol.
So does this suck? Yes, yes it does. But the suckiness is centralized here instead of having to be handled everywhere these issues come into play. Just realize there are a certain set of rules to follow when you set these variables, and the results you see when you get them are computed rather than literal.
sub New #( type, title, package, using, prototype, summary, body, lineNumber, isList )
Creates a new object.
type | The TopicType. |
title | The title of the topic. |
package | The package SymbolString the topic appears in, or undef if none. |
using | An arrayref of additional package SymbolStrings available to the topic via “using” statements, or undef if none. |
prototype | The prototype, if it exists and is applicable. Otherwise set to undef. |
summary | The summary of the topic, if any. |
body | The body of the topic, formatted in NDMarkup. May be undef, as some topics may not have bodies. |
lineNumber | The line number the topic appears at in the file. |
isList | Whether the topic is a list topic or not. |
The new object.
sub Type
Returns the TopicType.
sub SetType #( type )
Replaces the TopicType.
sub Symbol
Returns the SymbolString defined by the topic. It is fully resolved and does not need to be joined with Package().
sub Package
Returns the package SymbolString that the topic appears in.
sub Using
Returns an arrayref of additional scope SymbolStrings available to the topic via “using” statements, or undef if none.
sub SetUsing #( using )
Replaces the using arrayref of sope SymbolStrings.
sub Summary
Returns the topic summary, if it exists, formatted in NDMarkup.
sub Body
Returns the topic’s body, formatted in NDMarkup. May be undef.
sub SetBody #( body )
Replaces the topic’s body, formatted in NDMarkup. May be undef.
Creates a new object.
sub New #( type, title, package, using, prototype, summary, body, lineNumber, isList )
Returns the TopicType.
sub Type
Replaces the TopicType.
sub SetType #( type )
Returns whether the topic is a list.
sub IsList
Sets whether the topic is a list.
sub SetIsList
Returns the title of the topic.
sub Title
Replaces the topic title.
sub SetTitle #( title )
Returns the SymbolString defined by the topic.
sub Symbol
Returns the package SymbolString that the topic appears in.
sub Package
Replaces the package the topic appears in.
sub SetPackage #( package )
Returns an arrayref of additional scope SymbolStrings available to the topic via “using” statements, or undef if none.
sub Using
Replaces the using arrayref of sope SymbolStrings.
sub SetUsing #( using )
Returns the prototype if one is defined.
sub Prototype
Replaces the function or variable prototype.
sub SetPrototype #( prototype )
Returns the topic summary, if it exists, formatted in NDMarkup.
sub Summary
Returns the topic’s body, formatted in NDMarkup.
sub Body
Replaces the topic’s body, formatted in NDMarkup.
sub SetBody #( body )
Returns the line the topic appears at in the file.
sub LineNumber