Natural Docs Version 0.9 |
NaturalDocs:: MenuA package handling the menu’s contents and state. Usage and Dependencies
Summary
menuSynonyms
A hash of the text synonyms for the menu tokens. The keys are the lowercase synonyms, and the values are one of the Menu Item Types. indexSynonyms
A hash of the text synonyms for the index modifiers. The keys are the all lowercase synonyms, and the values are the associated Topic Types. indexNames
A hash of text equivalents of the possible index types. The keys are the Topic Types, and the values are the strings. menu
The parsed menu file. Is stored as a MENU_GROUP NaturalDocs::Menu::Entry object, with the top-level entries being stored as the group’s content. This is done because it makes LoadAndUpdate() simpler to implement. However, it is exposed externally via Content() as an arrayref. This structure will not contain objects for MENU_TITLE, MENU_SUBTITLE, or MENU_FOOTER entries. Those will be stored in the title, subTitle, and footer variables instead. defaultTitlesChanged
A hash of default titles that have changed, since OnDefaultTitleChange() will be called before LoadAndUpdate(). Collects them to be applied later. indexes
An existence hash of all the defined index types appearing in the menu. Keys are the Topic Types or * for the general index. previousIndexes
An existence hash of all the indexes that appeared in the menu last time. Keys are the Topic Types or * for the general index. NaturalDocs_Menu. txtThe file used to generate the menu. FormatThe file is plain text. Blank lines can appear anywhere and are ignored. Tags and their content must be completely contained on one line with the exception of Group’s braces. # [comment] The file supports single-line comments via #. They can appear alone on a line or after content. Title: [title] SubTitle: [subtitle] Footer: [footer] The menu title, subtitle, and footer are specified as above. Each can only be specified once, with subsequent ones being ignored. Subtitle is ignored if Title is not present. File: [file title] ([file name]) File: [file title] (auto-title, [file name]) Files are specified as above. If “auto-title,” precedes the file name in the parenthesis, the file title is ignored and the default is used instead. If not specified, the file title overrides the default title. Group: [name] Group: [name] { ... } Groups are specified as above. If no braces are specified, the group’s content is everything that follows until the end of the file, the next group (braced or unbraced), or the closing brace of a parent group. Group braces are the only things in this file that can span multiple lines. There is no limitations on where the braces can appear. The opening brace can appear after the group tag, on its own line, or preceding another tag on a line. Similarly, the closing brace can appear after another tag or on its own line. Being bitchy here would just get in the way of quick and dirty editing; the package will clean it up automatically when it writes it back to disk. Text: [text] Arbitrary text is specified as above. As with other tags, everything must be contained on the same line. Link: [URL] Link: [title] ([URL]) External links can be specified as above. If the titled form is not used, the URL is used as the title. Index: [name] [modifier] Index: [name] Indexes are specified with the types above. Valid modifiers are defined in indexSynonyms and include Function and Class. If no modifier is specified, the line specifies a general index. NaturalDocs. mThe file used to store the previous state of the menu so as to detect changes. Is named NaturalDocs.m instead of something like NaturalDocs.menu to avoid confusion with NaturalDocs_Menu.txt. This one is not user-editable so we don’t want people opening it by accident. [file version] The first line is the file version number from NaturalDocs::Settings::FileVersion(). [index type] tab [index type] tab ... The next line is a tab-separated list of all the index types present in the menu. They are the values of the Topic Types or
That’s all for now. In the future this will store the entire previous state so auto-locking can be applied. The file version will have to be incremented though. LoadAndUpdate
Loads the menu file from NaturalDocs_Menu.txt and updates it. If a file is deleted or no longer has Natural Docs content, it is removed from the menu. If files are added or get Natural Docs content, they are added to the end. If there are groups defined, the new ones will be added in group Other. Content
Returns the parsed menu as an arrayref of NaturalDocs::Menu::Entry objects. Do not change the arrayref. The arrayref will not contain MENU_TITLE and MENU_SUBTITLE entries. Use the Title() and SubTitle() functions instead. Indexes
Returns an existence hashref of all the indexes appearing in the menu. The keys are the Topic Types or * for the general index. Do not change the arrayref. PreviousIndexes
Returns an existence hashref of all the indexes that previously appeared in the menu. The keys are the Topic Types or * for the general index. Do not change the arrayref. Event HandlersThese functions are called by NaturalDocs::Project only. You don’t need to worry about calling them. For example, when changing the default menu title of a file, you only need to call NaturalDocs::Project::SetDefaultMenuTitle(). That function will handle calling OnDefaultTitleChange(). OnFileChange
Called by NaturalDocs::Project if it detects that the menu file has changed. OnDefaultTitleChange
Called by NaturalDocs::Project if the default menu title of a source file has changed. Parameters
ParseMenuFile
Loads and parses the menu file. ReturnsThe array ( hasGroups, errors, filesInMenu, trashAlert ).
Yeah, this method isn’t the best, but the alternatives would be to make them package variables (they aren’t needed outside of LoadAndUpdate()) or to make LoadAndUpdate() a huge beast function (which it was before this was split off.) AddMissingFiles
Adds all files with Natural Docs content to the menu that are not already on it. Parameters
HandleErrors
Handles errors appearing in the menu file. Parameters
WriteEntries
A recursive function to write the contents of an arrayref of NaturalDocs::Menu::Entry objects to disk. Parameters
|