NaturalDocs::Topics

Exporter
NaturalDocs::Topics

The topic constants and functions to convert them to and from strings used throughout the script.  All constants are exported by default.

Summary
NaturalDocs::TopicsThe topic constants and functions to convert them to and from strings used throughout the script.
@EXPORT
Types
TopicTypeA string representing a topic type as defined in Topics.txt.
Default TopicTypesExported constants of the default TopicTypes, so you don’t have to go through TypeFromName() every time.
Variables
FH_TOPICSThe file handle used when writing to Topics.txt.
typesA hashref that maps TopicTypes to NaturalDocs::Topics::Types.
namesA hashref that maps various forms of the all-lowercase type names to TopicTypes.
keywordsA hashref that maps all-lowercase keywords to their TopicTypes.
pluralKeywordsA hashref that maps all-lowercase plural keywords to their TopicTypes.
indexableAn existence hash of all the indexable TopicTypes.
requiredTypeNamesAn array of the TopicType names which are required to be defined in the main file.
legacyTypesAn array that converts the legacy topic types, which were numeric constants prior to 1.3, to the current TopicTypes.
mainTopicNamesAn array of the TopicType names that are defined in the main Topics.txt.
Files
Topics.txtThe configuration file that defines or overrides the topic definitions for Natural Docs.
File Functions
LoadLoads both the master and the project version of Topics.txt.
LoadFileLoads a particular version of Topics.txt.
SaveSaves the main and user versions of Topics.txt.
SaveFileSaves a particular version of Topics.txt.
Functions
KeywordInfoReturns information about a topic keyword.
NameInfoReturns information about a topic name.
TypeInfoReturns information about a TopicType.
NameOfTypeReturns the name of the passed TopicType, or undef if it doesn’t exist.
TypeFromNameReturns a TopicType for the passed topic name.
IsValidTypeReturns whether the passed TopicType is defined.
TypeFromLegacyReturns a TopicType for the passed legacy topic type integer.
AllIndexableTypesReturns an array of all possible indexable TopicTypes.
Support Functions
MakeTopicTypeReturns a TopicType for the passed topic name.

@EXPORT

our @EXPORT

Types

TopicType

A string representing a topic type as defined in Topics.txt.  It’s format should be treated as opaque; use MakeTopicType() to get them from topic names.  However, they can be compared for equality with string functions.

Default TopicTypes

Exported constants of the default TopicTypes, so you don’t have to go through TypeFromName() every time.

TOPIC_GENERALThe general TopicType, which has the special meaning of none in particular.
TOPIC_GENERICGeneric TopicType.
TOPIC_GROUPGroup TopicType.
TOPIC_CLASSClass TopicType.
TOPIC_INTERFACEInterface TopicType.
TOPIC_FILEFile TopicType.
TOPIC_SECTIONSection TopicType.
TOPIC_FUNCTIONFunction TopicType.
TOPIC_VARIABLEVariable TopicType.
TOPIC_PROPERTYProperty TopicType.
TOPIC_TYPEType TopicType.
TOPIC_CONSTANTConstant TopicType.
TOPIC_ENUMERATIONEnum TopicType.
TOPIC_DELEGATEDelegate TopicType.
TOPIC_EVENTEvent TopicType.

Variables

FH_TOPICS

The file handle used when writing to Topics.txt.

types

my %types

A hashref that maps TopicTypes to NaturalDocs::Topics::Types.

names

my %names

A hashref that maps various forms of the all-lowercase type names to TopicTypes.  All are in the same hash because two names that reduce to the same thing it would cause big problems, and we need to catch that.  Keys include

  • Topic names
  • Plural topic names
  • Alphanumeric-only topic names
  • Alphanumeric-only plural topic names

keywords

my %keywords

A hashref that maps all-lowercase keywords to their TopicTypes.  Must not have any of the same keys as pluralKeywords.

pluralKeywords

my %pluralKeywords

A hashref that maps all-lowercase plural keywords to their TopicTypes.  Must not have any of the same keys as keywords.

indexable

my %indexable

An existence hash of all the indexable TopicTypes.

requiredTypeNames

my @requiredTypeNames

An array of the TopicType names which are required to be defined in the main file.  Are in the order they should appear when reformatting.

legacyTypes

my @legacyTypes

An array that converts the legacy topic types, which were numeric constants prior to 1.3, to the current TopicTypes.  The legacy types are used as an index into the array.  Note that this does not support list type values.

mainTopicNames

my @mainTopicNames

An array of the TopicType names that are defined in the main Topics.txt.

Files

Topics.txt

The configuration file that defines or overrides the topic definitions for Natural Docs.  One version sits in Natural Docs’ configuration directory, and another can be in a project directory to add to or override them.

# [comments]

Everything after a # symbol is ignored.

Except when specifying topic names, everything below is case-insensitive.

Format: [version]

Specifies the file format version of the file.

Sections

Ignore[d] Keyword[s]: [keyword], [keyword] ...
   [keyword]
   [keyword], [keyword]
   ...

Ignores the keywords so that they’re not recognized as Natural Docs topics anymore.  Can be specified as a list on the same line and/or following like a normal Keywords section.

Topic Type: [name]
Alter Topic Type: [name]

Creates a new topic type or alters an existing one.  The name can only contain CFChars and isn’t case sensitive, although the original case is remembered for presentation.

The name General is reserved.  There are a number of default types that must be defined in the main file as well, but those are governed by NaturalDocs::Topics and are not included here.  The default types can have their keywords or behaviors changed, though, either by editing the default file or by overriding them in the user file.

Enumeration is a special type.  It is indexed with Types and its definition list members are listed with Constants according to the rules in Languages.txt.

Topic Type Sections

Plural: [name]

Specifies the plural name of the topic type.  Defaults to the singular name.  Has the same restrictions as the topic type name.

Index: [yes|no]

Whether the topic type gets an index.  Defaults to yes.

Scope: [normal|start|end|always global]

How the topic affects scope.  Defaults to normal.

normalThe topic stays within the current scope.
startThe topic starts a new scope for all the topics beneath it, like class topics.
endThe topic resets the scope back to global for all the topics beneath it, like section topics.
always globalThe topic is defined as a global symbol, but does not change the scope for any other topics.
Class Hierarchy: [yes|no]

Whether the topic is part of the class hierarchy.  Defaults to no.

Page Title if First: [yes|no]

Whether the title of this topic becomes the page title if it is the first topic in a file.  Defaults to no.

Break Lists: [yes|no]

Whether list topics should be broken into individual topics in the output.  Defaults to no.

Can Group With: [topic type], [topic type], ...

The list of TopicTypes the topic can possibly be grouped with.

[Add] Keyword[s]:
   [keyword]
   [keyword], [plural keyword]
   ...

A list of the topic type’s keywords.  Each line after the heading is the keyword and optionally its plural form.  This continues until the next line in “keyword: value” format.  “Add” isn’t required.

  • Keywords can only have letters and numbers.  No punctuation or spaces are allowed.
  • Keywords are not case sensitive.
  • Subsequent keyword sections add to the list.  They don’t replace it.
  • Keywords can be redefined by other keyword sections.

Revisions

1.3

The initial version of this file.

File Functions

Load

sub Load

Loads both the master and the project version of Topics.txt.

LoadFile

sub LoadFile #(isMain)

Loads a particular version of Topics.txt.

Parameters

isMainWhether the file is the main file or not.

Save

sub Save

Saves the main and user versions of Topics.txt.

SaveFile

sub SaveFile #(isMain)

Saves a particular version of Topics.txt.

Parameters

isMainWhether the file is the main file or not.

Functions

KeywordInfo

sub KeywordInfo #(keyword)

Returns information about a topic keyword.

Parameters

keywordThe keyword, which may be plural.

Returns

The array ( topicType, info, isPlural ), or an empty array if the keyword doesn’t exist.

topicTypeThe TopicType of the keyword.
infoThe NaturalDocs::Topics::Type of its type.
isPluralWhether the keyword was plural or not.

NameInfo

sub NameInfo #(name)

Returns information about a topic name.

Parameters

nameThe topic type name, which can be plural and/or alphanumeric only.

Returns

The array ( topicType, info ), or an empty array if the name doesn’t exist.  Note that unlike KeywordInfo(), this does not tell you whether the name is plural or not.

topicTypeThe TopicType of the name.
infoThe NaturalDocs::Topics::Type of the type.

TypeInfo

sub TypeInfo #(type)

Returns information about a TopicType.

Parameters

typeThe TopicType.

Returns

The NaturalDocs::Topics::Type of the type, or undef if it didn’t exist.

NameOfType

sub NameOfType #(topicType,
plural,
alphanumericOnly)

Returns the name of the passed TopicType, or undef if it doesn’t exist.

Parameters

topicTypeThe TopicType.
pluralWhether to return the plural instead of the singular.
alphanumericOnlyWhether to strips everything but alphanumeric characters out.  Case isn’t modified.

Returns

The topic type name, according to what was specified in the parameters, or undef if it doesn’t exist.

TypeFromName

sub TypeFromName #(topicName)

Returns a TopicType for the passed topic name.

Parameters

topicNameThe name of the topic, which can be plural and/or alphanumeric only.

Returns

The TopicType.  It does not specify whether the name was plural or not.

IsValidType

sub IsValidType #(type)

Returns whether the passed TopicType is defined.

TypeFromLegacy

sub TypeFromLegacy #(legacyInt)

Returns a TopicType for the passed legacy topic type integer.  TopicTypes were changed from integer constants to strings in 1.3.

AllIndexableTypes

sub AllIndexableTypes

Returns an array of all possible indexable TopicTypes.

Support Functions

MakeTopicType

sub MakeTopicType #(topicName)

Returns a TopicType for the passed topic name.  It does not check to see if it exists already.

Parameters

our @EXPORT
The configuration file that defines or overrides the topic definitions for Natural Docs.
A string representing a topic type as defined in Topics.txt.
sub TypeFromName #(topicName)
Returns a TopicType for the passed topic name.
my %types
A hashref that maps TopicTypes to NaturalDocs::Topics::Types.
A class storing information about a TopicType.
my %names
A hashref that maps various forms of the all-lowercase type names to TopicTypes.
my %keywords
A hashref that maps all-lowercase keywords to their TopicTypes.
my %pluralKeywords
A hashref that maps all-lowercase plural keywords to their TopicTypes.
my %indexable
An existence hash of all the indexable TopicTypes.
my @requiredTypeNames
An array of the TopicType names which are required to be defined in the main file.
my @legacyTypes
An array that converts the legacy topic types, which were numeric constants prior to 1.3, to the current TopicTypes.
my @mainTopicNames
An array of the TopicType names that are defined in the main Topics.txt.
sub Load
Loads both the master and the project version of Topics.txt.
sub LoadFile #(isMain)
Loads a particular version of Topics.txt.
sub Save
Saves the main and user versions of Topics.txt.
sub SaveFile #(isMain)
Saves a particular version of Topics.txt.
sub KeywordInfo #(keyword)
Returns information about a topic keyword.
sub NameInfo #(name)
Returns information about a topic name.
sub TypeInfo #(type)
Returns information about a TopicType.
sub NameOfType #(topicType,
plural,
alphanumericOnly)
Returns the name of the passed TopicType, or undef if it doesn’t exist.
sub IsValidType #(type)
Returns whether the passed TopicType is defined.
sub TypeFromLegacy #(legacyInt)
Returns a TopicType for the passed legacy topic type integer.
sub AllIndexableTypes
Returns an array of all possible indexable TopicTypes.
sub MakeTopicType #(topicName)
Returns a TopicType for the passed topic name.
The characters that can appear in configuration file keywords and user-defined element names: letters, numbers, spaces, dashes, slashes, apostrophes, and periods.
The topic constants and functions to convert them to and from strings used throughout the script.
The configuration file that defines or overrides the language definitions for Natural Docs.
Close