Natural DocsVersion 1.2 Copyright © 2003-2004 Greg Valure http://www.naturaldocs.org Summary | | | Licensed under the GNU General Public License | | | | Adding additional languages is very easy, so don’t worry if yours isn’t here. | | | | | | | | | | | | | | | | | | | | Read the CSS Guide to understand the styles Natural Docs uses and how they fit together. | | | | | | General functions that are used throughout the program, and that don’t really fit anywhere else. | | Compares two strings so that the result is good for proper sorting. | | Compares two arrayrefs and shortens the first array to only contain shared entries. | | Does the equivalent of “use [module]” for every .pm file in a directory and all its subdirectories. | | A cross-platform chomp function. | | | | | | |
LicenseLicensed under the GNU General Public License This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, visit http://www.gnu.org/licenses/gpl.txt or write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. SyntaxNaturalDocs -i [input (source) directory]
(-i [input (source) directory] ...)
-o [output format] [output directory]
(-o [output format] [output directory] ...)
-p [project directory]
[options]Directory names with spaces are fine. They don’t need quotes on Windows. ExamplesNaturalDocs -i C:\My Project\Source
-o HTML C:\My Project\Docs
-p C:\My Project\Natural DocsNaturalDocs -i /src/project
-o HTML /doc/project
-p /etc/naturaldocs/project
-s Small -t 2 -qOptions| -i [dir] | The input (source) directory. Required. Can be specified multiple times. Also --input, --source. | | -o [fmt] [dir] | The output format and directory. Required. See Supported Output Formats for a list of options. This can be specified multiple times, but only once per directory. Also --output. | | -p [dir] | The project directory. Required. There should be a unique project directory for each input directory. Also --project. | | -s [style] | Sets the CSS style for HTML output. If set to “Custom”, it will not sync the project’s CSS file with one from Natural Docs’ style directory. If not specified, the style is “Default”. See HTML Styles for options. Also --style. | | -do | Prevents undocumented code aspects from being included in the output. Also --documentedonly. | | -t [len] | Sets the number of spaces tabs should be expanded to. This only needs to be set if you use tabs in example code and text diagrams. The default is 4. Also --tablength. | | -r | Rebuilds all output and data files from scratch. Does not affect the menu file. Also --rebuild. | | -ro | Rebuilds all output files from scratch. Use this whenever you add or change output formats. Also --rebuildoutput. | | -q | Suppresses all non-error output. Also --quiet. | | -ho | For C and C++, only check the headers and not the source files. Also --headersonly. | | -h | Prints the syntax reference. Also -?, --help. |
Supported LanguagesAdding additional languages is very easy, so don’t worry if yours isn’t here. See How to Add Languages. - C++
- C#
- Java
- JavaScript (.js files only)
- Perl (.pl and .pm files, plus .cgi and extensionless files if “perl” is in the #! line)
- Python (.py files, plus .cgi and extensionless files if “python” is in the #! line)
- PHP (support isn’t flawless because escapement isn’t handled yet)
- PL/SQL
- Visual Basic
- Pascal (which includes Delphi)
- Assembly
- Tcl
- Ada
- Ruby
- Text files (.txt files only)
Supported Output Formats| HTML | Creates HTML output. A directory tree will be created to mirror the source tree, and each source file will have a corresponding HTML file of the same name, only with .html appended. The files are self-contained and don’t rely on frames. index.html forwards to the first file on the menu. | | FramedHTML | Creates framed HTML output. A directory tree will be created to mirror the source tree, and each source file will have a corresponding HTML file of the same name, only with .html appended. The menu has its own file, so changes to it will be done much quicker. |
Natural Docs is designed to be extended with more output formats, but it requires familiarity with Perl. See How to Add Output Formats for details. HTML Styles| Default | The standard Natural Docs appearence. You’re looking at it right now. | | Small | For people who prefer 8pt Verdana, aka people with good eyes. You get more on the screen at once, but some people hate it when web pages use tiny fonts. | | Roman | For people who prefer Roman fonts, aka people who use OS X, XP with ClearType, or some other decent anti-aliasing system. Most people don’t and thus prefer Verdana. It makes the fancy quotes (66 and 99, as opposed to II) look especially nice, though. | | Custom | Tells Natural Docs that the output directory is using its own custom CSS file. Natural Docs will not sync the CSS file at all with this option set. |
You can also use any CSS file present in Natural Docs’ styles directory. Just use its name without the .css extension. For example, if your style is Blue.css, use “Blue”. You can check for additional styles at http://www.naturaldocs.org. If you would like to build your own, see How to Add HTML Styles. HTML Compatibility| Mozilla (Gecko) | Works on 1.0+. Tested on Mozilla 1.0.2 and 1.4. 1.0.2 has minor formatting issues with prototypes in tooltips, but nothing that hurts usability. | | Internet Explorer | Works on 4+. Tested on 4.0, 5.0 and 6.0. I don’t have a partition for 5.5 so I’m assuming it works. 4.0 can’t collapse the menu and makes the tooltips the full page width, although it positions them correctly. 5.0 occasionally slightly misplaces the tooltips, but it’s still usable and is usually fine. | | Opera | Works on 5+. Tested on 5.12, 6.05, and 7.02. Only 7.02 can collapse the menu. 5.12 can’t size or position the tooltips very well, but they’re usable most of the time. | | Konqueror (KHTML) | Works on 3+. Tested on Konqueror 3.1.1. Has some minor margin issues, but it’s definitely their renderer that’s the problem. Shows tooltips immediately because it has problems doing it on a timer. | | Netscape 4.x | Nope. Crashes 4.08 and mangled on 4.8. Why did they ever drop this for Gecko? I’ve stopped supporting NS4 in my projects and have found that my quality of life has improved considerably. |
Note that a browser not being able to collapse the menu isn’t a compatibility concern. The menu defaults to completely open if the browser can’t handle collapsing it, so it’s always usable. It’s just better on browsers that support it. Also note that if a browser doesn’t support frames, the user will automatically be forwarded to the menu file when using framed HTML output so it will still be usable. How to Add Output Formats- Create a new NaturalDocs::Builder sub-package derived from NaturalDocs::Builder::Base.
- See NaturalDocs::Builder::Base’s documentation for a list of the interface functions that should be implemented and examples of how to do so.
- By placing the file in the Modules/NaturalDocs/Builder directory, it will automatically be included by Natural Docs. You do not have to add a ‘use’ statement anywhere in the code, which makes it easy to keep custom output formats whenever you upgrade Natural Docs.
How to Add Topics- If you’d like to add a synonym for an existing topic type, edit NaturalDocs::Topics::constants. Note that it must be in all lowercase.
- If you’d like to add a new topic type, read through NaturalDocs::Topics’ source. It should be obvious what needs to be edited, just don’t skip anything. You can stop when you reach the functions.
How to Add Extensions- Create a new NaturalDocs::Extensions sub-package derived from NaturalDocs::Extensions::Base.
- See NaturalDocs::Extensions::Base’s documentation for a list of interface functions can be implemented.
- By placing the file in the Modules/NaturalDocs/Extensions directory, it will automatically be included by Natural Docs. You do not have to add a ‘use’ statement anywhere in the code, which makes it easy to keep custom extensions whenever you upgrade Natural Docs.
How to Add HTML StylesRead the CSS Guide to understand the styles Natural Docs uses and how they fit together. After you’ve created your own CSS file, drop it in the Natural Docs styles directory. Then you can reference it via -s in the command line. Its name is the CSS file name without the extension. So if your file is Red.css, you use it by specifying “-s Red” in your projects. If you ever change the CSS file in the Natural Docs styles directory, each project that uses it will get an updated copy automatically the next time Natural Docs is run on it. Also make sure that whenever you upgrade Natural Docs, you check the Revisions section of the CSS Guide to see if there have been any changes to the generated HTML. It may require you to update your CSS file. Code Conventions- All NaturalDocs:: packages have their functions called in Package->Function() notation. You call NaturalDocs::Project->FilesToBuild(), not NaturalDocs::Project::FilesToBuild(). Note that this was not the case until version 1.14, so any custom modifications done before then probably need to be updated.
- If you’re wondering about some of the line lengths or the strange indentation, it’s because I work on Natural Docs using 8pt Verdana.
Support FunctionsGeneral functions that are used throughout the program, and that don’t really fit anywhere else. StringCompareCompares two strings so that the result is good for proper sorting. A proper sort orders the characters as follows: - End of string.
- Whitespace. Line break-tab-space.
- Symbols, which is anything not included in the other entries.
- Numbers, 0-9.
- Letters, case insensitive except to break ties.
If you use cmp instead of this function, the result would go by ASCII/Unicode values which would place certain symbols between letters and numbers instead of having them all grouped together. Also, you would have to choose between case sensitivity or complete case insensitivity, in which ties are broken arbitrarily. ReturnsLike cmp, it returns zero if A and B are equal, a positive value if A is greater than B, and a negative value if A is less than B. ShortenToMatchStrings| sub ShortenToMatchStrings # | ( | sharedArrayRef, | | | compareArrayRef | ) | |
|
Compares two arrayrefs and shortens the first array to only contain shared entries. Assumes all entries are strings. Parameters| sharedArrayRef | The arrayref that will be shortened to only contain common elements. | | compareArrayRef | The arrayref to match. |
UseDirectory| sub UseDirectory # | ( | directory, | | | directory, | | | directory ... | ) | |
|
Does the equivalent of “use [module]” for every .pm file in a directory and all its subdirectories. You must call this function from within a BEGIN block if you want the INIT functions of the modules to be executed. Parameters| directory | A single subdirectory. Specify this as many times as necessary to make the path from the Natural Docs directory. |
ExampleBEGIN {
IncludeDirectory('Modules', 'NaturalDocs', 'Extensions');
};This code will include every .pm file in [Natural Docs’ directory]/Modules/NaturalDocs/Extensions and all its subdirectories. XChompA cross-platform chomp function. Regular chomp fails when parsing Windows-format line breaks on a Unix platform. It leaves the /r on, which screws everything up. This does not. Parameters| lineRef | A reference to the line to chomp. |
|