NaturalDocs:: Extensions

A package to manage all the extensions to Natural Docs.

Summary
A package to manage all the extensions to Natural Docs.
An array of all the extension packages.
A hash of all the errors from each package’s Requires() requirements.
Adds external packages similar to if you used the line ‘require [package]’.
Adds an extension package to Natural Docs.
Returns a hashref of the command line options by extension package.
Sends the command line options to their extensions.
These functions call the equivalent functions of each extension.
Called after a file has been parsed, but before it is scanned for symbols or turned into output.

Variables

extensions

my @extensions

An array of all the extension packages.

requireErrors

my %requireErrors

A hash of all the errors from each package’s Requires() requirements.  The keys are the package names, and the values are the error message.  If there were no errors for a package, it will not have an entry here.

Functions

Requires

sub Requires #(extension,
requirement,
requirement,
requirement ...)

Adds external packages similar to if you used the line ‘require [package]’.  This is similar to ‘use [package]’ except that nothing is exported, meaning you always have to use ‘package::function()’ instead of just ‘function()’.  We don’t want an extension to potentially cause a naming conflict with Natural Docs’ functions, either now or in a future version.

All extension packages must call this function from BEGIN if they need to use external packages other than what is included in all Perl distributions by default.  You can find a list of them at http://www.perldoc.com/perl5.005_03/lib.html.

Using this function instead of a direct ‘use [package]’ lets Natural Docs degrade gracefully if those packages aren’t there.  If you just used ‘use [package]’ instead, Natural Docs would always quit with an error if that package wasn’t there, whether the user was trying to use your extension or not.  Using this function instead only gives that error message if the packages aren’t installed and the user tried to use your extension anyway.

Parameters

extensionThe extension package.
requirementThe required external package.  Specify as many times as you like.

Example

NaturalDocs::Extensions->Requires(__PACKAGE__, 'String::CRC32', 'Crypt::Blowfish');

Add

sub Add #(package)

Adds an extension package to Natural Docs.  All extension packages must call this function from INIT to be recognized.

Parameters

packageThe package name.

CommandLineOptions

sub CommandLineOptions

Returns a hashref of the command line options by extension package.  The keys are the package names, and the values are hashrefs where the keys are the all-lowercase short options (‘-i’) and the values are the all-lowercase long options (‘--input’).  If there are no command line options for a particular extension, it will not be included in the hashref.  If there are no command line options for any extensions, it will return undef.

ParseCommandLineOptions

sub ParseCommandLineOptions #(options)

Sends the command line options to their extensions.

Parameters

optionsA hashref of the command line options and their values.  The keys are the all-lowercase short options (‘-i’) and the values are their parameters, or undef if none.

Returns

An arrayref of error messages, or undef if none.

Hook Targets

These functions call the equivalent functions of each extension.

AfterFileParsed

sub AfterFileParsed #(file,
parsedFile)

Called after a file has been parsed, but before it is scanned for symbols or turned into output.  Only call this function if the file has Natural Docs content.

Parameters

fileThe source file.
parsedFileThe arrayref of NaturalDocs::Parser::ParsedTopic objects.
my @extensions
An array of all the extension packages.
my %requireErrors
A hash of all the errors from each package’s Requires() requirements.
sub Requires #(extension,
requirement,
requirement,
requirement ...)
Adds external packages similar to if you used the line ‘require [package]’.
sub Add #(package)
Adds an extension package to Natural Docs.
sub CommandLineOptions
Returns a hashref of the command line options by extension package.
sub ParseCommandLineOptions #(options)
Sends the command line options to their extensions.
sub AfterFileParsed #(file,
parsedFile)
Called after a file has been parsed, but before it is scanned for symbols or turned into output.
A class for parsed topics of source files.