Sign in Join
Wiki copytemporary

chm backend for fpdoc: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11### Examples
22
33This link has information about the TOC and Index files in chms: <http://www.nongnu.org/chmspec/latest/Sitemap.html>
44
55These formats are based on HTML and use the following doctype:
66
77```html4strict
88<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
99```
1010
1111The \<HEAD\> tag contains a
1212
1313tag providing information on the program that generated the files and a comment indicating the version of the file, e.g.:
1414
1515```html4strict
1616<meta name="GENERATOR"content="Microsoft® HTML Help Workshop 4.1">
1717
1818```
1919
2020The \<BODY\> tag contains an \<OBJECT\> tag that stores properties of the file in \<param\> tags, followed by a \<UL\> tag, whose \<LI\> tags have \<OBJECT\> tags that store the properties of the Contents/Index items in \<param\> tags. e.g.:
2121
2222```html4strict
2323<BODY>
2424<OBJECT type="text/site properties">
2525 <param name="Property Name" value="Property Value">
2626 …
2727</OBJECT>
2828<UL>
2929 <LI> <OBJECT type="text/sitemap">
3030 <param name="Property Name" value="Property Value">
3131 …
3232 </OBJECT>
3333 …
3434</UL>
3535</BODY>
3636```
3737
3838Note that the Property Names and Property Values and tags are not case-sensitive, but HHW will always write all three in the default capitalization, when appropriate.
3939
4040Note that the tags are mostly in uppercase and the \<LI\> tag is not closed; this is in compliance with the doctype.
4141
4242Some properties that were seen in HHA.dll that may or may not be used are Background Image, NumberImages, InformationTypeDecl, Secondary, Icon, Display, Keyword, Instruction, Section Title, Favorites, QueryType, SendEvent, SendMessage, HHI, Inclusive & Exclusive.
4343
4444This the beginning chunk of an autogenerated (the autogenerated TOC stinks) hhc (Table of Contents/TOC) file for the RTL: .hhk are in the same format but are for the Index pane and do not have subitems.
4545
4646```html4strict
4747<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
4848<HTML>
4949<HEAD>
5050<meta name="GENERATOR" content="Microsoft® HTML Help Workshop 4.1">
5151
5252</HEAD><BODY>
5353<OBJECT type="text/site properties">
5454 <param name="Auto Generated" value="Yes">
5555</OBJECT>
5656<UL>
5757 <LI> <OBJECT type="text/sitemap">
5858 <param name="Name" value="Reference for package 'rtl'">
5959 <param name="Local" value="rtl/index.html">
6060 </OBJECT>
6161 <UL>
6262 <LI> <OBJECT type="text/sitemap">
6363 <param name="Name" value="Units">
6464 <param name="Local" value="rtl/index.html">
6565 </OBJECT>
6666 <LI> <OBJECT type="text/sitemap">
6767 <param name="Name" value="Description">
6868 <param name="Local" value="rtl/index.html">
6969 </OBJECT>
7070 </UL>
7171 <LI> <OBJECT type="text/sitemap">
7272 <param name="Name" value="Reference for unit 'BaseUnix'">
7373 <param name="Local" value="rtl/baseunix/index.html">
7474 </OBJECT>
7575 <UL>
7676 <LI> <OBJECT type="text/sitemap">
7777 <param name="Name" value="Overview">
7878 <param name="Local" value="rtl/baseunix/index.html">
7979 </OBJECT>
8080 </UL>
8181
8282......
8383</UL>
8484</BODY></HTML>
8585```
8686
8787## Generating FPC CHM docs via fpdoc
8888
8989As of October 2008, the fpdoc part of the documentation (the part that documents the various units) can be compiled to CHM fairly easily, a
9090
9191``` bash
9292make clean html HTMLFMT=chm CSSFILE=/path/to/fpdoc.css
9393```
9494
9595will generate rtl.chm and fcl.chm. Note that the cssfile is currently in a different repository (I used fpc/utils/fpdoc/fpdoc.css since it has the correct name). A script **fixdocs.sh** automates most of the CHM related options. (*nix, requires latex + tex4ht)
9696
9797Significant fixes to the CHM, XML and makefiles backend were introduced in the sources (fpcdocs,chm, fcl-xml and fpdoc) from the 2.3.1 branch, July 31st 2009 and newer.
9898
9999### Remaining problems
100100
1011011. The text mode IDE crashes on loading the LCL.chm's index on all architectures and OSes. Other CHM viewers don't seem to suffer from this, but there is always a chance it is CHM pkg related. (**fixed**)
1021022. The prog and user documents don't have an index. Ref guide only has keywords.
1031033. FCL-XML generates UTF-8, which some CHM browsers (kchmviewer) don't seem to handle properly. *Note: is this still applicable in March 2014?* Workaround: ISO8859-1 default? KCHMviewer seem to work fine on windows.
1041044. compiling LCL finds a lot of unknown identifiers. These should be documented?
1051055. crosslinking between user,ref,prog and fpdoc?
106106
107107And the major one:
108108
1091091. How to combine the indexes to a master index (including duplicate handling)? Currently additional disambiguating context is only added to the index if a dupe _within_ a CHM is detected.
110110
111111## Generating LCL CHM via build_lcl_docs
112112
113113Lazarus provides the build_lcl_docs.lpr tool: a wrapper which simplifies calling fpdoc to generate an LCL CHM.
114114
115115It can be run both in GUI mode and command line mode.
116116
117117Useful command line parameters
118118
1191191. `--fpdoc` \<fpdoc executable to be used to generate CHM\>
1201202. `--css-file=`\<css file to be used for layout, e.g. fpdoc.css\>
1211213. `--outfmt chm` Set output format to CHM
122122
123123## Generating LCL CHM via fpdoc
124124
125125Only tested on *nix
126126
127127> **Warning:** this script enables all fpdoc bells and whistles, takes about 4 minutes and 400MB memory on a Core2-6600. If you want to do this regularly, make sure you have a fpdoc from trunk, preferably from a checkout that was compiled with optimization on which saves about half a minute
128128
129129``` bash
130130export HTMLFMT=chm
131131cd lazarus/docs/html
132132sh build_lcl_html.sh "fpdoc" "" /path/to/fpcdocs
133133```
134134
135135The generated .xct file is an index file for fpdoc cross file links, and is of no use to the end user, unless you want to link to the chm. That is also why we have to specify the fpcdocs archive. If we have previously built the FPC docs there, lcl will use this to craft cross CHM links.
136136
137137## Generating FPC CHM docs for the latex documentation
138138
139139Building CHMs for the documentation that is not in fpdoc format (but normal latex files) is harder. The process can be fairly easily be separated into two stages:
140140
1411411. generate HTML from latex sources
1421422. compile HTML to CHM
143143 1. raw compile
144144 2. generating indexes and TOC
145145
146146### Generating HTML
147147
148148The first is currently the hard part. During the years several converters have been tried, the current one used is tex4ht. While the theory is easy (install latex, install tex4ht, run make html), the practice is difficult (*), and the generated docs are usually corrupt (ligatures converted to pics or unicode escapes, bad "next" links etc). Luckily, these docs mutates less often, so one probably can use a generated set of CHMs for the entire duration of a release cycle. Still it would be great to have a definitive, reproducable solution.
149149
150150For the moment, the "bad" output of tex4ht is fixed by a DOM based (FCL-XML) FPC tool, relinkdocs. Relinkdocs scans the HTML docs and relinks the next/up/prev links.
151151
152152(*) to the degree that the version on the FPC front page is more often broken than not.
153153
154154### Compiling and TOC generation
155155
156156To compile the resulting HTML to CHM, another tool was written, called compilelatexchm, which also relies on FCL-XML for the TOC scanning. The CHM is searchable, but does not yet have an index. (I don't know a suitable algoritm to come up with the keywords)
157157
158158A batch file that automates these steps is added to the fpcdocs repository (fixdocs.sh), but is not idiot proof yet. If you have troubles, ask me (Marco/oliebol) on IRC.
159159
160160### Plastex
161161
162162A week after I did the above fixing of tex4ht output, Andrew Haines came with a patch that supported using PlasTeX as tex2chm converter. I don't entirely like the output (chapter and paragraph numbers drop off, which makes it harder to correspond over documentation, and the template is a bit playful), but I haven't looked into customizing it at all, so maybe something can be done there. I haven't tested the generated CHMs with the textmode IDE yet too.
163163
164164One can select PlasTeX by passing USEPLASTEX=1 to the make process.
165165
166166## chmcmd understood options
167167
168168While the chmcmd program responds to e.g. --help by outputting the command-line options it understands, it doesn't report what options are acceptable in the .hhp file. Refer to the OptionKeys constant in fpcsrc/packages/chm/src/chmfilewriter.pas, and documentation available at e.g. [1](http://www.nongnu.org/chmspec/latest/INI.html#HHP).
169169
170170For anybody determined to "roll their own", an absolutely minimal .hhp file reads something like
171171
172-`[OPTIONS]`\
173-`Compiled file=test.chm`\
174-`Contents file=./Default.hhc`\
175-`[FILES]`\
176-`./Borg-UI_MainForm_HelpButton.html`\
177-`./Borg-UM_MainForm_HelpButton.html`
172+```text
173+[OPTIONS]
174+Compiled file=test.chm
175+Contents file=./Default.hhc
176+[FILES]
177+./Borg-UI_MainForm_HelpButton.html
178+./Borg-UM_MainForm_HelpButton.html
179+```
178180
179181with the TOC file being
180182
181183```html4strict
182184 <html><head></head><body><object type="text/site properties"></object><ul>
183185 <li><object type="text/sitemap">
184186 <param name="Name" value="Borg-UI_MainForm_HelpButton">
185187 <param name="Local" value="Borg-UI_MainForm_HelpButton.html">
186188 </object>
187189 <li><object type="text/sitemap">
188190 <param name="Name" value="Borg-UM_MainForm_HelpButton">
189191 <param name="Local" value="Borg-UM_MainForm_HelpButton.html">
190192 </object>
191193 </ul></body></html>
192194```
193195
194196## Troubleshooting
195197
196198### Trouble viewing in Vista
197199
198200The chm file could be marked as blocked. To unblock, use the chmls tool (included in \$(fpcdir)\packages\chm\src\\):
199201
200202```dos
201203chmls unblockchm yourfile.chm
202204```
203205
204206#### Alternative ways and background
205207
206208Have a look at [this link](http://blog.crowe.co.nz/archive/2007/04/13/719.aspx). We still must find something that make the installer do this automatically.
207209
208210Or turn it off entirely using:
209211
210-`[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HTMLHelp\1.x\HHRestrictions]`\
211-` "MaxAllowedZone"=dword:00000001`\
212-`[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HTMLHelp\1.x\ItssRestrictions]`\
213-` "MaxAllowedZone"=dword:00000001`
212+```text
213+[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HTMLHelp\1.x\HHRestrictions]
214+ "MaxAllowedZone"=dword:00000001
215+[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HTMLHelp\1.x\ItssRestrictions]
216+ "MaxAllowedZone"=dword:00000001
217+```
214218
215219You can add a registry key to repair this issue in XP and Vista by setting the ItssRestrictions.MaxAllowedZone to 3 or 4 or 5.
216220
217221A simpler solution is to unzip with e.g. infozip, instead of Windows built-in support. (beware, newer infozips might conform at any time!)
218222
219223Apparently this is an alternate filestream: <http://stackoverflow.com/questions/1617509/unblock-a-file-with-powershell>
220224
221225---
222226*From the Free Pascal wiki, page "chm backend for fpdoc", as it stood on 2020-12-21 after a change by Marcov, 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](/wiki-contact).*
223227Category: CHM
224228Category: Help and Docs

Back to history