#### 16.5.17 Adding documentation

New documentation can be added in GPS in various ways. This is useful if you want to point to your own project documentation for instance.

The first possibility is to create a new menu, through a `<menu>` tag in an XML file, associated with an action that either spawn an external web browser or calls the internal `GPS.Help.browse()` shell command.

However, this will not show the documentation in the `Help->Contents` menu, which you also might want to do.

To have both results, you should use the `<documentation_file>` tag in an XML file. These tags are generally found in the `gps_index.xml` files, as documented in see Adding New Help Files, but you can in fact add them in any of your customization files.

The documentation files you display can contain the usual type of html links. In addition, GPS will treat specially links starting with '%', and consider them as script commands to execute instead of file to display. The following example show how to insert a link that will in effect open a file in GPS when clicked by the user

         <a href="%shell:Editor.editor g-os_lib.ads">Open runtime file</a>

The first word after '%' is the name of the language, and the command to execute is found after the ':' character.

The `<documentation_file>` accepts a number of child nodes:

name
  This is the name of the file. It can be either an absolute file name, or a file name relative to one of the directories in `GPS_DOC_PATH`. If this child is omitted, you must specify a `<shell>` child.

  This name can contain a reference to a specific anchor in the html file, using the standard HTML syntax.

                  <name>file#anchor</name>

shell
  This child specifies the name of a shell command to execute to get the name of the HTML file. This command can for instance create the HTML file dynamically, or download it locally using some special mechanism. This child accepts one attribute, `"lang"`, which is the name of the language in which the command is written
descr
  This is the description for this help file. It appears in a tool tip for the menu item.
category
  This is used in the `Help->Contents` menu to organize all the documentation files.
menu
  This is the full path to the menu. It behaves like a UNIX path, except it reference the various menus, starting from the menu bar itself. The first character of this path must be `"/"`. The last part of the path is the name of the new menu item. If not set, no menu is displayed for this file, although it will still appear in the `Help->Contents` menu

  The `<menu>` child tag accepts two attributes.

  before (optional, default="")
    The name of the menu before which the new entry should be inserted. If the new menu is inserted in some submenus, this tag controls the deeper nesting. Parent menus are created as needed, but if you wish to control their specific order, you should create them first with a `<menu>` tag.
  after (optional, default="")
    The name of the menu after which the new entry should be inserted.

The following example shows how to create a new entry "item" in the Help menu, that will display `file.html`. The latter is searched in the `GPS_DOC_PATH` list of directories.

         <?xml version="1.0"?>
         <index>
            <documentation_file>
               <name>file.html</name>
               <descr>Tooltip text</descr>
               <category>name</category>
               <menu>/Help/item</menu>
            </documentation_file>
         </index>

As mentioned above, HTML files are looked for through the `GPS_DOC_PATH` environment variable. However, you can also use the `<doc_path>` XML node to defined additional directories to be searched.

Such a directory is relative to the installation directory of GPS.

         <?xml version="1.0"?>
         <GPS>
            <doc_path>doc/application/</doc_path>
         </GPS>

will add the directory `<prefix>/doc/application` to the search path for the documentation.

Such a directory can also be added through Python, as in:

         GPS.HTML.add_doc_directory ('doc/application')