Next: Adding stock icons, Previous: Adding casing exceptions, Up: Customizing through XML and Python files
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:
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>
"lang"
, which is the name of the
language in which the command is written
Help->Contents
menu to organize all the
documentation files.
"/"
. 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.
<menu>
tag.
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')