Sign in Join
Wiki copytemporary

Creating IDE Help

Deutsch · English · Русский · 日本語

Overview

The IDE can search help for various things and there are various sources in various help formats. Here is a short list to understand the complexity:

Demos and explore

You can see the currently installed help under View / IDE Internals / About IDE / Help.

There is a test and demonstration package under examples/idehelp/demoidehelp.lpk. It contains example code how you can add help to the IDE.

To show your help in the user's browser see examples/helphtml/htmlhelp1.lpi.

To show HTML help in a LCL control see examples/htmlhelp_ipro/htmlhelpsample.lpi.

Help for LCL units

Whenever the user presses F1 for an Object Inspector property or on an identifier in the source editor the IDE searches the declaration and invokes the HTML viewer for the fpdoc item. The items can be edited easily via the FPDoc Editor tool.

You can see the state of the LCL documentation here: LCL Documentation Roadmap.

Help for IDE windows

This feature exists since 0.9.15.

The help for the IDE windows (i.e. 'Object Inspector' or the 'Compiler Options') are documented in this wiki. The IDE has a mapping file docs/IDEWindowHelpTree.xml, which contains the paths from the various IDE forms/controls to wiki pages. This mapping file is edited via an editor that is shown at any place in the IDE via Ctrl+Shift+F1, except for controls that catch all keys, like synedit. You can set the shortcut in the editor options -> key mapping.

The root page of the IDE window docs is Lazarus IDE.

Example

Redirect

The TreeView in the IDE options dialog redirects the help to the help of the selected frame:

ide/ideoptionsdlg.pas

pascal
procedure TIDEOptionsDialog.CategoryTreeKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var
  Command: Word;
begin
  Command := EditorOpts.KeyMap.TranslateKey(Key,Shift,nil);
  if (Command=ecContextHelp) and (PrevEditor <> nil) then begin
    Key:=VK_UNKNOWN;
    ShowContextHelpForIDE(PrevEditor);
  end;
end;

Help for FPC keywords

You can register a help for fpc keywords. Note: One database can handle multiple contexts, for example help for fpc keywords, help for sources and help for messages.

pascal
uses
  IDEHelpIntfs, HelpIntfs, LazHelpIntf, LazHelpHTML...

  { TSimpleFPCKeywordHelpDatabase }

  TSimpleFPCKeywordHelpDatabase = class(THTMLHelpDatabase) // you can use any type of database you like
  private
    FKeywordPrefixNode: THelpNode;
  public
    function GetNodesForKeyword(const HelpKeyword: string;
                        var ListOfNodes: THelpNodeQueryList; var ErrMsg: string
                        ): TShowHelpResult; override;
    function ShowHelp(Query: THelpQuery; BaseNode, NewNode: THelpNode;
                      QueryItem: THelpQueryItem;
                      var ErrMsg: string): TShowHelpResult; override;
  end;

function TSimpleFPCKeywordHelpDatabase.GetNodesForKeyword(
  const HelpKeyword: string; var ListOfNodes: THelpNodeQueryList;
  var ErrMsg: string): TShowHelpResult;
var
  KeyWord: String;
begin
  Result:=shrHelpNotFound;
  if (csDesigning in ComponentState) then exit;
  if (FPCKeyWordHelpPrefix<>'')
  and (LeftStr(HelpKeyword,length(FPCKeyWordHelpPrefix))=FPCKeyWordHelpPrefix) then begin
    // HelpKeyword starts with KeywordPrefix
    KeyWord:=copy(HelpKeyword,length(FPCKeyWordHelpPrefix)+1,length(HelpKeyword));
    // test: testfcpkeyword
    if KeyWord='testfcpkeyword' then begin
      // this help database knows this keyword
      // => add a node, so that if there are several possibilities the IDE can
      //    show the user a dialog to choose
      // Note: In your own database you can create one dummy node or
      // one node per keyword or one node per group of keywords
      // or whatever you like.
      if FKeywordPrefixNode=nil then
        FKeywordPrefixNode:=THelpNode.CreateURL(Self,'','');
      FKeywordPrefixNode.Title:='Pascal keyword '+KeyWord;
      CreateNodeQueryListAndAdd(FKeywordPrefixNode,nil,ListOfNodes,true);
      Result:=shrSuccess;
    end;
  end;
end;

function TSimpleFPCKeywordHelpDatabase.ShowHelp(Query: THelpQuery; BaseNode,
  NewNode: THelpNode; QueryItem: THelpQueryItem; var ErrMsg: string
  ): TShowHelpResult;
var
  KeywordQuery: THelpQueryKeyword;
  KeyWord: String;
begin
  Result:=shrHelpNotFound;
  if not (Query is THelpQueryKeyword) then exit;
  KeywordQuery:=THelpQueryKeyword(Query);
  KeyWord:=copy(KeywordQuery.Keyword,length(FPCKeyWordHelpPrefix)+1,length(KeywordQuery.Keyword));
  debugln(['TSimpleFPCKeywordHelpDatabase.ShowHelp Keyword=',Keyword]);
  // ShowURL ...
end;

procedure Register;
begin
 FPCKeywordsHelpDB:=HelpDatabases.CreateHelpDatabase('NameYourHelpDB',
                                            TSimpleFPCKeywordHelpDatabase,true);
end;

Help for Messages

This feature exists since 0.9.15 and requires the FPC sources installed locally.

This is invoked when the user presses F1 or uses the Help menu item of the message window.

Normally the IDE will search the errore.msg file in the FPC sources and show the comment for the message. But some messages like unit not found need extra help. The following describes how to do that:

To add a wiki help page for a message, do the following:

The items are stored in <lazarusdir>/docs/additionalmsghelp.xml.

Adding Kylix help

For wow to use the Borland Help files within the IDE editor, see Adding Kylix Help.


From the Free Pascal wiki, page "Creating IDE Help", as it stood on 2020-08-22 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 2, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.