Writing Documentation and Help for Eclipse Projects and Plug-ins
SidebarKeyContent AccountLast changes
Key FeaturesKey Ads |
This article (continually in progress) documents my experiences in creating documentation and help for an Eclipse plug-in. If you're delivering documentation or help for an Eclipse-based project, feel free to add to this article.
Contents Table of contentsReturn to the list of Key Articles. Eclipse The BasicsSince Eclipse is Java-based, it stands to reason that its help system is based on Sun's JavaHelpIf you're familiar with JavaHelp you'll be ahead of the curve. If you're not, don't worry... the curve isn't too sharp. An Eclipse documentation project (called a "plug-in") is made up of:
Sample Documentation DemoCreating the Plug-inYour documentation plug-in is defined by a plugin.xml file. This file contains:
The -+plugin.xml+- file is similar to JavaHelps's *.hs (helpset) file. This table defines some of the key differences:
Here is a sample -+plugin.xml+- file for our sample documentation plug-in. <?xml version="1.0" encoding="UTF-8"?><plug-in name="Demo Documentation Plug-in" id="org.eclipse.demo.doc" version="1.0.0"> <extension point="org.eclipse.help.toc"> <toc file="toc.xml" primary="true"/> </extension> <extension point="org.eclipse.help.index"> <index file="index.xml"/> </extension></plug-in>Creating the Table of ContentsThe table of contents for the documentation is defined by the -+toc.xml+- file, just as it is in JavaHelp (and OHJ). The key differences are the names of the labels, as defined in this table:
Turning your JavaHelp's table of contents into Eclipse is fairly straightforward and trivial. You'll also need to include a definition type of org.eclipse.help.toc at the beginning of the file.Here's a sample Eclipse toc.xml: <?xml version="1.0" encoding="UTF-8"?><?NLS TYPE="org.eclipse.help.toc"?> <toc label="My Guide"> <topic label="Getting Started"> <topic href="file002.htm" label="Some Topic" /> <topic href="file004.htm" label="Yet Another Topic" /> </topic> </toc>This would produce the following table of contents in Eclipse:
To Open or Show?By including (or omitting) the label attribute in the topic element of each item in thetoc.xml, you can control its behavior: Will clicking the link open a specific page, expand the items to show its children, or both?In the previous example, clicking the Getting Started node will simply expand the node to show the its child (Some Topic). Clicking the Some Topic node will show the page file002.htm and its child node (Yet Another Topic). Multiple Tables of ContentsIf you have an exceptionally long (or detailed) table of contents, you may consider creating a separate toc.xml file for each major category (e.g., concepts, tasks, references, etc.). You simply add each toc file to your -+plugin.xml+-.For example, if your project contained three toc files:
Your plugin.xml would define each file within the toc extension point: <extension point="org.eclipse.help.toc"> <toc file="toc.xml" primary="true" /> <toc file="toc_concepts.xml" /> <toc file="toc_tasks.xml" /> <toc file="toc_references.xml" /> </extension>The Eclipse documentation Defining the Keyword IndexThe keyword index (not to be confused with the search index) is a traditional "back of the book" index: an alphabetical list of keywords and terms. This functionality was introduced in Eclipse 3.2.The index for the documentation set is defined by the -+index.xml+- file, just as it is in JavaHelp (and OHJ). The key differences are the names of the labels, as defined in this table:
As with the table of contents, turning your JavaHelp's index into Eclipse is fairly straightforward and trivial. Here's a sample Eclipse -+index.xml+-: <?xml version="1.0" encoding="UTF-8"?> <index version="1.0"> <entry keyword="alpha"> <topic href="mypage.htm" /> </entry> <entry keyword="beta"> <entry keyword="foo"> <topic href="myotherpage.htm" /> </entry> <entry keyword="bar"> <topic href="morepages.htm" /> </entry> </entry> </index>This would produce the following table of contents in Eclipse:
Adding Documentation TopicsIn Eclipse, the documentation pages are delivered as HTML pages. For this sample documentation plug-in, you'll need three HTML files: mypage.htm, myotherpage.htm, and morepages.htm.Note that the Eclipse help system is case sensitive — in order to link between pages you'll need the exact filename. The Eclipse Doc Style Guide Packaging and Testing the SampleTo test the sample plug-in:
After the Eclipse workbench appears, select Help > Help Contents. Your documentation should appear in the Contents pane of the Eclipse Help Center:
You can expand and collapse the items in My Guide and open the documentation pages. Adding Online HelpYou have seen how to add documentation to Eclipse and have it appear in the Eclipse Help Center. Now we will add online help to the plug-in. Let me first define some terms to makes sure we're all on the same page:
Note: Eclipse help is also "dynamic" in the sense that the content displayed in the Help view can change automatically as the user selects a different UI widget. This happens without forcing the user to re-press F1. Adding Context-Sensitive Online HelpFor Eclipse, the online help content, (i.e., the text shown in either an infopop or the Help view as the result of pressing F1) is contained in a separate XML file: -+contexts.xml+-.First, we need to "add" this contexts.xml file to the documentation plug-in. We need to add the following extension to the plugin.xml file: <extension point="org.eclipse.help.contexts"> <contexts file="contexts.xml" plug-in="org.eclipse.demo.doc"/></extension>Now we can create the actual contexts.xml file. Remember, the online help shows only a few lines of text — not a complete page. This is much different than JavaHelp, which uses a mapping file to match help topic IDs with a specific HTML page. The infopop and help view samples shown earlier were created with a -+contexts.xml+- file similar to: <?xml version="1.0" encoding="UTF-8"?><?NLS TYPE="org.eclipse.help.contexts"?><contexts> <context id="select_a_wizard_dialog"> <description>Choose the type of resource you would like to create.</description> <topic label="Resources" href="./org.eclipse.platform.doc.user/concepts/concepts-12.htm" /> </context></contexts>
Setting the ID in CodeTo assign the help topic to the UI widget, your developer simply uses the setHelp method inorg.eclipse.ui.help.WorkbenchHelp. You must supply both your plug-in's ID and the help topic ID.For example, to add the ID "select_a_wizard_dialog" with a the dialog box in the application (as shown in the previous samples), you would use the following code: WorkbenchHelp.setHelp(myDialogBoxn, org.eclipse.demo.doc.example.select_a_wizard_dialog);The Eclipse documentation contains additional information on how to declare a help topic in code Searching the DocumentationThe search functionality for your documentation plug-in is handled automatically by Eclipse. The first time you perform a search, you may notice a message indicating that the search index is being rebuilt.If you make changes to the doc set, you'll need to have Eclipse rebuild the search index. This ensures that when users perform a search of the documentation, they will be getting results from the current doc set. To force Eclipse to rebuild the search index, delete the following folder: \eclipse\configuration\org.eclipse.help.base\indexThen restart Eclipse with the -clean option. After starting up, Eclipse will rebuild the index.Using the Eclipse Plug-in ToolYou can create the beginnings of a documentation plug-in from within Eclipse, itself. Eclipse contains a documentation plug-in template that will help you get started defining most of the XML file.
Eclipse creates your project, including the plugin.xml, toc.xml and all additional toc files. ![]() The Eclipse documentation contains additional information on creating plug-ins Using Other Help Authoring Tools (HATs)There are several third-party tools that can be used to generate Eclipse documentation plug-ins from your source material (such as FrameMaker, MS-Word, etc.):
Although some do not support Eclipse help directly, they do generate JavaHelp. As shown in this article, conversion from JavaHelp to Eclipse is straightforward. Setting End-user PreferencesThe end-user can control several interface and display options, while using your documentation plug-in.
Some of these options include:
Getting Fancycoming soonUsing Cheat SheetsCheat sheetsUsers can select a cheat sheet from Help > Cheat Sheets. ![]() To add cheat sheets to your plug-in, fist add the extension to the plugin.xml file: <extension point="org.eclipse.ui.cheatsheets.cheatSheetContent"> <category name="My Cheatsheets" id="com.eclipse.myplugin.category"/> <cheatsheet name="Title of my cheatsheet" category="com.eclipse.myplugin.category" contentFile="$nl$/cheatsheets/my_cheatsheet.xml" id="com.eclipse.myplugin.cheatsheet.my_cheatsheet"> <description>This is my first Eclipse cheatsheet.</description> </cheatsheet></extension>
![]() Using Call Backscoming soonFinding More Help
Contributors to this page: Rick Sapir
,
Bill Albing
,
Jeremy H. Griffith
,
Chief Editor
and
System Administrator
.
|
Sidebar |
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||