Organizing the Menu - Natural Docs

| Language Support Output Formats Documenting Your Code Keywords Running Troubleshooting Organizing the Menu CSS Styles Topics and Keywords Languages, Indexes, and Prototypes Web Site Mailing Lists Message Boards Bugs and Feature Requests | Organizing the Menu Natural Docs creates a file called `Menu.txt` in your project directory that you can edit to organize the menu. It normally takes care of this on its own, but you have the option of improving it manually if you want to. Order and Titles If you’ve never looked in it before, the menu file will have some comments explaining its syntax and a list like you see below.
    File: ClassA  (ClassA.h)
    File: ClassB  (ClassB.h)
    File: Globals  (Globals.h)
The list gets turned into a menu that looks like this:
ClassA ClassB Globals
The lines are in the format “`File: [title] ([filename])`”. When Natural Docs made the menu, it decided on its own what the title of each file should be and then put them in alphabetical order. However, suppose we don’t want this. We want Globals above the classes and we want spaces in the menu titles. So we edit the file.
    File: Globals  (Globals.h)
    File: Class A  (ClassA.h)
    File: Class B  (ClassB.h)
Run Natural Docs again and the menu is updated.
Globals Class A Class B
However, open the menu file again and you’ll see something interesting.
    File: Globals  (Globals.h)
    File: Class A  (no auto-title, ClassA.h)
    File: Class B  (no auto-title, ClassB.h)
Natural Docs noticed that you changed a couple of the titles and added a `no auto-title` attribute to each one. This tells it to never change them on it’s own in the future, so your changes won’t be lost. You don’t have to worry about adding this, Natural Docs will always do it automatically. However, to go back to automatic titles you’d have to manually remove it. Grouping This menu is good for our example, but in the real world they get much, much longer. We can add groups to organize it further. Natural Docs will create them automatically based on the each file’s directory, but once again you can improve it manually if that’s not good enough. You can add groups as shown below.
    File: Globals  (Globals.h)
    Group: Classes {
       File: Class A  (no auto-title, ClassA.h)
       File: Class B  (no auto-title, ClassB.h) }
Globals Classes Class A Class B
You can also nest them inside each other.
    File: Globals  (Globals.h)
    Group: Classes {
       File: Class A  (no auto-title, ClassA.h)
       Group: Nested Group {
          File: Class B  (no auto-title, ClassB.h)  }
       }
Globals Classes Class A Nested Group Class B
We’ll get rid of the nested group because it doesn’t make sense for our example. Run Natural Docs, open up the menu file again and take a look.
    File: Globals  (Globals.h)

    Group: Classes  {

       File: Class A  (no auto-title, ClassA.h)
       File: Class B  (no auto-title, ClassB.h)
       }  # Group: Classes
Natural Docs reformatted it. When you’re organizing the menu, you don’t have to worry about the indentation or otherwise keeping it neat. The file is reformatted every time it changes, so you can make quick and dirty edits and Natural Docs will keep it readable. Besides breaking up long lists, groups also serve another purpose. Clicking on them will make it expand and collapse. Go ahead and try it in the examples above. When the menu gets too long its groups will start being collapsed by default, allowing easier navigation on large projects where it would just be impractical to show everything at once. Indexes and Search Natural Docs will automatically determine what indexes your project needs and add them to the menu. Anything indexed will also be used for the search feature. The entries will look like this:
    Group: Index {

       Index: Everything
       Class Index: Classes
       Function Index: Functions
       }  # Group: Index
Like the file entries we saw before, you can rename them by editing the title and reorder them by cutting and pasting. However, if you decide you don’t want a particular index to be generated, just delete its entry and it will go away. Just like before, Natural Docs will detect this and add something new:
    Don't Index: Functions
As with `no auto-title`, Natural Docs adds this automatically to make sure it doesn’t later undo your changes. Automatic Changes Natural Docs tries to manage the menu on its own as much as possible so you don’t have to worry about it. This is just a peek into some of the things it does so you know what to expect. You already saw that by default Natural Docs tries to guess what title should be for each file. If you leave it this way, Natural Docs will always update the menu for you if the file’s content changes significantly enough to change its guess, such as if you rename the first class defined in it. If you’d like to take advantage of this to define the menu title in each source file instead of in the menu itself, add a “`Title: [title]`” comment to the top of the file. When you add and delete source files, Natural Docs will automatically add and remove them from the menu file. When adding one it will look for the best group to put it in by directory. If your grouping mirrors the source tree somewhat, this will be a lot more accurate. Also, if the group it’s putting it in is alphabetized, Natural Docs will put it in the correct place to maintain that alphabetization. In fact, even if an existing file’s automatic title changes, it will change it’s position to make sure a previously alphabetized group stays that way. There are exceptions in alphabetization for the indexes. If a group only contains indexes, it can be the last item on the menu or in its parent group without making it count as unsorted. Also, within groups that only contain indexes, the general index can be first, also without making the group count as unsorted. Finally, if Natural Docs adds some files to a group that causes it to become too long, it will attempt to sub-group it based on directory. However, it will only do this when its adding files on its own, so you don’t have to worry about it constantly messing up your groups. Since new files aren’t added to a project that often, if you change the menu manually it should stay that way for quite some time. Extras There’s more you can do with the menu than just renaming and reorganizing its entries. Natural Docs has a few extras you can add to it as well. Title and Subtitle You can add a title and subtitle to your menu.
    Title: My Project
    SubTitle: Something That Does Something

    File: Globals  (Globals.h)
    Group: Classes
       File: Class A  (no auto-title, ClassA.h)
       File: Class B  (no auto-title, ClassB.h)
My Project Something That Does Something Globals Classes Class A Class B
In addition to adding the title to the menu, the Title tag will also change the HTML page titles from “Class A” to “Class A - My Project”, making bookmarks clearer. Text and Web Links You can also add arbitrary text and web links to your menu.
    File: Globals  (Globals.h)
    Group: Classes  {
       Text: I couldn't think of good names for these classes.
       File: Class A  (no auto-title, ClassA.h)
       File: Class B  (no auto-title, ClassB.h)
       }
    Link: Built with Natural Docs  (http://www.naturaldocs.org)
Globals Classes I couldn’t think of good names for these classes. Class A Class B Built with Natural Docs
Even though comments use the # character, adding an anchor to a link (such as “http://www.website.com/page.html#anchor”) will still work. Footers Finally, you can add a footer to all your pages, such as a copyright notice. Natural Docs will change any (c)’s it finds into real copyright symbols.
    Footer: Copyright (C) 2010 Me
Copyright © 2010 Me · Generated by Natural Docs
You can also add a timestamp in any format you want. The tokens you can use in building it are:

`m` | One or two digit month. | January is “1”

`mm` | Always two digit month. | January is “01”

`mon` | Short month word. | January is “Jan”

`month` | Long month word. | January is “January”

`d` | One or two digit day. | 1 is “1”

`dd` | Always two digit day. | 1 is “01”

`day` | Day with letter extension. | 1 is “1st”

`yy` | Two digit year. | 2010 is “10”

`yyyy` | Four digit year. | 2010 is “2010”

`year` | Four digit year. | 2010 is “2010”

Everything else appears literally, so we can add:
    Timestamp: Updated month day, year
and get:
Copyright © 2010 Me · Updated January 1st, 2010 · Generated by Natural Docs
Errors If there’s ever an error in the menu file, Natural Docs will tell you when it’s run. It also adds a comment for each one in the menu file itself so that you can search for them in a text editor.
    # There is an error in this file.  Search for ERROR to find it.

    File: Globals  (Globals.h)
    Group: Classes  {
    # ERROR: Txet is not a valid keyword.
       Txet: I couldn't think of good names for these classes.
       File: Class A  (no auto-title, ClassA.h)
       File: Class B  (no auto-title, ClassB.h)
       }
Remember that Natural Docs reformats the menu file whenever it’s run, so you only need to correct the error. Natural Docs will remove the error comments on its own. Portability and Versioning Systems If you only use one input directory, all the files in the menu will have relative paths. However, if you have more Natural Docs will use the absolute path instead. This is not a problem. The menu file can still be shared between machines even if they don’t keep the source tree in the exact same location. As long as you have the same layout within the source tree and point to the same base directories in the command line, Natural Docs will be able to convert the paths automatically for the new machine. However, if you’re putting the menu file in a versioning system like Subversion or SourceSafe, it might be very desirable to only have relative paths so anybody can check it in and only the real changes show. In that case, instead of using multiple input directories, see if it’s possible to only have one input directory and use the `-xi` command line option to exclude the subdirectories you don’t want scanned. That’s It! And we’re done. The syntax to do all of this is included in the menu file itself, so you don’t need to memorize everything. You shouldn’t need to organize the menu very often, just after a lot of new files have been added and if you don’t like the default. Note that if you’re using the non-framed HTML output format, changing the menu does require every output file to be updated. However, Natural Docs has a special process just for this so it won’t take nearly as long as if it were rebuilding them all from scratch. Still, if you’re working on a large project, it may be worth considering the framed HTML output format.
| Copyright © 2003-2010 Greg Valure