A package to handle the command line and various other program settings.
NaturalDocs:: | A package to handle the command line and various other program settings. |
Information | |
Usage and Dependencies | |
Internal Overview | |
Named Directories | Ever since Natural Docs introduced multiple input directories in 1.16, they’ve had to be named. |
Removed Directories | Directories that were part of the previous run but aren’t anymore are still stored in the package. |
Variables | |
PREVIOUS_SETTINGS_FILEHANDLE | The file handle used with PreviousSettings.nd. |
inputDirectories | An array of input directories. |
inputDirectoryNames | An array of the input directory names. |
imageDirectories | An array of image directories. |
imageDirectoryNames | An array of the image directory names. |
relativeImageDirectories | An array of the relative paths for images. |
excludedInputDirectories | An array of input directories to exclude. |
removedInputDirectories | An array of input directories that were once in the command line but are no longer. |
removedInputDirectoryNames | An array of the removed input directories’ names. |
removedImageDirectories | An array of image directories that were once in the command line but are no longer. |
removedImageDirectoryNames | An array of the removed image directories’ names. |
projectDirectory | The project directory. |
buildTargets | An array of NaturalDocs::Settings::BuildTargets. |
documentedOnly | Whether undocumented code aspects should be included in the output. |
tabLength | The number of spaces in tabs. |
noAutoGroup | Whether auto-grouping is turned off. |
onlyFileTitles | Whether source files should always use the file name as the title. |
isQuiet | Whether the script should be run in quiet mode or not. |
rebuildData | WHether most data files should be ignored and rebuilt. |
styles | An array of style names to use, most important first. |
charset | The character encoding of the source files, and thus the output. |
Files | |
PreviousSettings.nd | Stores the previous command line settings. |
Action Functions | |
Load | Loads and parses all settings from the command line and configuration files. |
Save | Saves all settings in configuration files to disk. |
GenerateDirectoryNames | Generates names for each of the input and image directories, which can later be retrieved with InputDirectoryNameOf() and ImageDirectoryNameOf(). |
Information Functions | |
InputDirectories | Returns an arrayref of input directories. |
InputDirectoryNameOf | Returns the generated name of the passed input directory. |
SplitFromInputDirectory | Takes an input file name and returns the array ( inputDirectory, relativePath ). |
ImageDirectories | Returns an arrayref of image directories. |
ImageDirectoryNameOf | Returns the generated name of the passed image or input directory. |
SplitFromImageDirectory | Takes an input image file name and returns the array ( imageDirectory, relativePath ). |
RelativeImageDirectories | Returns an arrayref of relative image directories. |
ExcludedInputDirectories | Returns an arrayref of input directories to exclude. |
BuildTargets | Returns an arrayref of NaturalDocs::Settings::BuildTargets. |
OutputDirectoryOf | Returns the output directory of a builder object. |
Styles | Returns an arrayref of the styles associated with the output. |
ProjectDirectory | Returns the project directory. |
ProjectDataDirectory | Returns the project data directory. |
StyleDirectory | Returns the main style directory. |
JavaScriptDirectory | Returns the main JavaScript directory. |
ConfigDirectory | Returns the main configuration directory. |
DocumentedOnly | Returns whether undocumented code aspects should be included in the output. |
TabLength | Returns the number of spaces tabs should be expanded to. |
NoAutoGroup | Returns whether auto-grouping is turned off. |
OnlyFileTitles | Returns whether source files should always use the file name as the title. |
IsQuiet | Returns whether the script should be run in quiet mode or not. |
RebuildData | Returns whether all data files should be ignored and rebuilt. |
CharSet | Returns the character set, or undef if none. |
Constant Functions | |
AppVersion | Returns Natural Docs’ version number as an integer. |
TextAppVersion | Returns Natural Docs’ version number as plain text. |
AppURL | Returns a string of the project’s current web address. |
Support Functions | |
ParseCommandLine | Parses and validates the command line. |
PrintSyntax | Prints the syntax reference. |
PrintOutputFormats | Prints all the possible output formats that can be specified with -o. |
LoadAndComparePreviousSettings | Loads PreviousSettings.nd and compares the values there with those in the command line. |
SavePreviousSettings | Saves the settings into PreviousSettings.nd. |
Ever since Natural Docs introduced multiple input directories in 1.16, they’ve had to be named. Since they don’t necessarily extend from the same root anymore, they can’t share an output directory without the risk of file name conflicts. There was an early attempt at giving them actual names, but now they’re just numbered from 1.
Directory names aren’t generated right away. It waits for Menu.txt to load because that holds the obfuscated names from the last run. NaturalDocs::Menu then calls GenerateDirectoryNames() and passes those along as hints. GenerateDirectoryNames() then applies them to any matches and generates new ones for any remaining. This is done so that output page locations can remain consistent when built on multiple computers, so long as the menu file is shared. I tend to think the menu file is the most likely configuration file to be shared.
Directories that were part of the previous run but aren’t anymore are still stored in the package. The primary reason, though there may be others, is file purging. If an input directory is removed, all the output files that were generated from anything in it need to be removed. To find out what the output file name was for a removed source file, it needs to be able to split it from it’s original input directory and know what that directory was named. If this didn’t happen those output files would be orphaned, as was the case prior to 1.32.
The file handle used with PreviousSettings.nd.
my @inputDirectoryNames
An array of the input directory names. Each name corresponds to the directory of the same index in inputDirectories.
my @imageDirectoryNames
An array of the image directory names. Each name corresponds to the directory of the same index in imageDirectories.
my @removedInputDirectoryNames
An array of the removed input directories’ names. Each name corresponds to the directory of the same index in removedInputDirectories.
my @removedImageDirectoryNames
An array of the removed image directories’ names. Each name corresponds to the directory of the same index in removedImageDirectories.
my @buildTargets
An array of NaturalDocs::Settings::BuildTargets.
Stores the previous command line settings.
[BINARY_FORMAT] [VersionInt: app version]
The file starts with the standard BINARY_FORMAT VersionInt header.
[UInt8: tab length] [UInt8: documented only (0 or 1)] [UInt8: no auto-group (0 or 1)] [UInt8: only file titles (0 or 1)] [AString16: charset] [UInt8: number of input directories] [AString16: input directory] [AString16: input directory name] ...
A count of input directories, then that number of directory/name pairs.
[UInt8: number of output targets] [AString16: output directory] [AString16: output format command line option] ...
A count of output targets, then that number of directory/format pairs.
sub GenerateDirectoryNames #( hashref inputHints, hashref imageHints )
Generates names for each of the input and image directories, which can later be retrieved with InputDirectoryNameOf() and ImageDirectoryNameOf().
inputHints | A hashref of suggested input directory names, where the keys are the directories and the values are the names. These take precedence over anything generated. You should include names for directories that are no longer in the command line. This parameter may be undef. |
imageHints | Same as inputHints, only for the image directories. |
sub InputDirectoryNameOf #( directory )
Returns the generated name of the passed input directory. GenerateDirectoryNames() must be called once before this function is available.
If a name for a removed input directory is available, it will be returned as well.
sub ImageDirectoryNameOf #( directory )
Returns the generated name of the passed image or input directory. GenerateDirectoryNames() must be called once before this function is available.
If a name for a removed input or image directory is available, it will be returned as well.
sub BuildTargets
Returns an arrayref of NaturalDocs::Settings::BuildTargets. Do not change.
sub OutputDirectoryOf #( object )
Returns the output directory of a builder object.
object | The builder object, whose class is derived from NaturalDocs::Builder::Base. |
The builder directory, or undef if the object wasn’t found..
sub AppVersion
Returns Natural Docs’ version number as an integer. Use TextAppVersion() to get a printable version.
sub LoadAndComparePreviousSettings
Loads PreviousSettings.nd and compares the values there with those in the command line. If differences require it, sets rebuildData and/or <rebuildOutput>.
sub SavePreviousSettings
Saves the settings into PreviousSettings.nd.
An array of input directories.
my @inputDirectories
An array of the input directory names.
my @inputDirectoryNames
An array of image directories.
my @imageDirectories
An array of the image directory names.
my @imageDirectoryNames
An array of the relative paths for images.
my @relativeImageDirectories
An array of input directories to exclude.
my @excludedInputDirectories
An array of input directories that were once in the command line but are no longer.
my @removedInputDirectories
An array of the removed input directories’ names.
my @removedInputDirectoryNames
An array of image directories that were once in the command line but are no longer.
my @removedImageDirectories
An array of the removed image directories’ names.
my @removedImageDirectoryNames
The project directory.
my $projectDirectory
An array of NaturalDocs::Settings::BuildTargets.
my @buildTargets
Whether undocumented code aspects should be included in the output.
my $documentedOnly
The number of spaces in tabs.
my $tabLength
Whether auto-grouping is turned off.
my $noAutoGroup
Whether source files should always use the file name as the title.
my $onlyFileTitles
Whether the script should be run in quiet mode or not.
my $isQuiet
WHether most data files should be ignored and rebuilt.
my $rebuildData
An array of style names to use, most important first.
my @styles
The character encoding of the source files, and thus the output.
my $charset
Loads and parses all settings from the command line and configuration files.
sub Load
Saves all settings in configuration files to disk.
sub Save
Generates names for each of the input and image directories, which can later be retrieved with InputDirectoryNameOf() and ImageDirectoryNameOf().
sub GenerateDirectoryNames #( hashref inputHints, hashref imageHints )
Returns the generated name of the passed input directory.
sub InputDirectoryNameOf #( directory )
Returns the generated name of the passed image or input directory.
sub ImageDirectoryNameOf #( directory )
Returns an arrayref of input directories.
sub InputDirectories
Takes an input file name and returns the array ( inputDirectory, relativePath ).
sub SplitFromInputDirectory #( file )
Returns an arrayref of image directories.
sub ImageDirectories
Takes an input image file name and returns the array ( imageDirectory, relativePath ).
sub SplitFromImageDirectory #( file )
Returns an arrayref of relative image directories.
sub RelativeImageDirectories
Returns an arrayref of input directories to exclude.
sub ExcludedInputDirectories
Returns an arrayref of NaturalDocs::Settings::BuildTargets.
sub BuildTargets
Returns the output directory of a builder object.
sub OutputDirectoryOf #( object )
Returns an arrayref of the styles associated with the output.
sub Styles
Returns the project directory.
sub ProjectDirectory
Returns the project data directory.
sub ProjectDataDirectory
Returns the main style directory.
sub StyleDirectory
Returns the main JavaScript directory.
sub JavaScriptDirectory
Returns the main configuration directory.
sub ConfigDirectory
Returns whether undocumented code aspects should be included in the output.
sub DocumentedOnly
Returns the number of spaces tabs should be expanded to.
sub TabLength
Returns whether auto-grouping is turned off.
sub NoAutoGroup
Returns whether source files should always use the file name as the title.
sub OnlyFileTitles
Returns whether the script should be run in quiet mode or not.
sub IsQuiet
Returns whether all data files should be ignored and rebuilt.
sub RebuildData
Returns the character set, or undef if none.
sub CharSet
Returns Natural Docs’ version number as an integer.
sub AppVersion
Returns Natural Docs’ version number as plain text.
sub TextAppVersion
Returns a string of the project’s current web address.
sub AppURL
Parses and validates the command line.
sub ParseCommandLine
Prints the syntax reference.
sub PrintSyntax
Prints all the possible output formats that can be specified with -o.
sub PrintOutputFormats #( prefix )
Loads PreviousSettings.nd and compares the values there with those in the command line.
sub LoadAndComparePreviousSettings
Saves the settings into PreviousSettings.nd.
sub SavePreviousSettings
Loads the menu file from disk and updates it.
sub LoadAndUpdate
Adds all supported files to the list of files to parse.
sub ReparseEverything
Adds all supported files to the list of files to build.
sub RebuildEverything