dw_ipf.pp 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341
  1. {
  2. FPDoc - Free Pascal Documentation Tool
  3. Copyright (C) 2000 - 2003 by
  4. Areca Systems GmbH / Sebastian Guenther, [email protected]
  5. * IPF output generator
  6. See the file COPYING, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. }
  12. unit dw_IPF;
  13. {$MODE objfpc}
  14. {$H+}
  15. interface
  16. uses SysUtils, Classes, dWriter, DOM, dGlobals, PasTree;
  17. const
  18. IPFHighLight : Boolean = False;
  19. IPFExtension : String = '.ipf';
  20. type
  21. TLabelType = (ltConst,ltVar,ltType,ltFunction,ltProcedure,ltClass,
  22. ltChapter,ltSection,ltSubsection,
  23. ltTable,ltFigure);
  24. { TIPFWriter }
  25. TIPFWriter = class(TFPDocWriter)
  26. protected
  27. f: Text;
  28. FLink: String;
  29. PackageName: String;
  30. Module: TPasModule;
  31. ModuleName: String;
  32. FTableCount : Integer;
  33. TableRowStartFlag, TableCaptionWritten: Boolean;
  34. function GetLabel(AElement: TPasElement): String;
  35. procedure Write(const s: String);
  36. procedure WriteF(const s: String; const Args: array of const);
  37. procedure WriteLn(const s: String);
  38. procedure WriteLnF(const s: String; const Args: array of const);
  39. // Tex functions
  40. procedure WriteLabel(El: TPasElement);
  41. procedure WriteLabel(const s: String);
  42. procedure WriteIndex(El: TPasElement);
  43. procedure WriteIndex(const s: String);
  44. procedure StartListing(Frames: Boolean; const name: String);
  45. procedure StartListing(Frames: Boolean);
  46. procedure EndListing;
  47. Function EscapeTex(S : String) : String;
  48. Function StripTex(S : String) : String;
  49. procedure WriteCommentLine;
  50. procedure WriteComment(Comment : String);
  51. procedure StartSection(SectionName : String; SectionLabel : String);
  52. // procedure StartSection(SectionName : String);
  53. procedure StartSubSection(SubSectionName : String; SubSectionLabel : String);
  54. // procedure StartSubSection(SubSectionName : String);
  55. procedure StartChapter(ChapterName : String; ChapterLabel : String);
  56. procedure StartChapter(ChapterName : String);
  57. // Description node conversion
  58. procedure DescrWriteText(const AText: DOMString); override;
  59. procedure DescrBeginBold; override;
  60. procedure DescrEndBold; override;
  61. procedure DescrBeginItalic; override;
  62. procedure DescrEndItalic; override;
  63. procedure DescrBeginEmph; override;
  64. procedure DescrEndEmph; override;
  65. procedure DescrWriteFileEl(const AText: DOMString); override;
  66. procedure DescrWriteKeywordEl(const AText: DOMString); override;
  67. procedure DescrWriteVarEl(const AText: DOMString); override;
  68. procedure DescrBeginLink(const AId: DOMString); override;
  69. procedure DescrEndLink; override;
  70. procedure DescrWriteLinebreak; override;
  71. procedure DescrBeginParagraph; override;
  72. procedure DescrBeginCode(HasBorder: Boolean; const AHighlighterName: String); override;
  73. procedure DescrWriteCodeLine(const ALine: String); override;
  74. procedure DescrEndCode; override;
  75. procedure DescrEndParagraph; override;
  76. procedure DescrBeginOrderedList; override;
  77. procedure DescrEndOrderedList; override;
  78. procedure DescrBeginUnorderedList; override;
  79. procedure DescrEndUnorderedList; override;
  80. procedure DescrBeginDefinitionList; override;
  81. procedure DescrEndDefinitionList; override;
  82. procedure DescrBeginListItem; override;
  83. procedure DescrEndListItem; override;
  84. procedure DescrBeginDefinitionTerm; override;
  85. procedure DescrEndDefinitionTerm; override;
  86. procedure DescrBeginDefinitionEntry; override;
  87. procedure DescrEndDefinitionEntry; override;
  88. procedure DescrBeginSectionTitle; override;
  89. procedure DescrBeginSectionBody; override;
  90. procedure DescrEndSection; override;
  91. procedure DescrBeginRemark; override;
  92. procedure DescrEndRemark; override;
  93. procedure DescrBeginTable(ColCount: Integer; HasBorder: Boolean); override;
  94. procedure DescrEndTable; override;
  95. procedure DescrBeginTableCaption; override;
  96. procedure DescrEndTableCaption; override;
  97. procedure DescrBeginTableHeadRow; override;
  98. procedure DescrEndTableHeadRow; override;
  99. procedure DescrBeginTableRow; override;
  100. procedure DescrEndTableRow; override;
  101. procedure DescrBeginTableCell; override;
  102. procedure DescrEndTableCell; override;
  103. function ConstValue(ConstDecl: TPasConst): String;
  104. procedure ProcessSection(ASection: TPasSection);
  105. // Documentation writing methods.
  106. procedure WriteResourceStrings(ASection: TPasSection);
  107. procedure WriteUnitOverview(ASection: TPasSection);
  108. procedure WriteVarsConstsTypes(ASection: TPasSection);
  109. procedure WriteConsts(ASection: TPasSection);
  110. procedure WriteTypes(ASection: TPasSection);
  111. procedure WriteEnumElements(TypeDecl : TPasEnumType);
  112. procedure WriteVars(ASection: TPasSection);
  113. procedure WriteFunctionsAndProcedures(ASection: TPasSection);
  114. procedure WriteProcedure(ProcDecl: TPasProcedureBase);
  115. procedure WriteClasses(ASection: TPasSection);
  116. procedure WriteClassDecl(ClassDecl: TPasClassType);
  117. procedure WriteClassMethodOverview(ClassDecl: TPasClassType);
  118. procedure WriteClassPropertyOverview(ClassDecl: TPasClassType);
  119. procedure WriteProperty(PropDecl: TPasProperty);
  120. procedure WriteExample(ADocNode: TDocNode);
  121. procedure WriteSeeAlso(ADocNode: TDocNode);
  122. procedure SortElementList(List : TList);
  123. Function ShowMember(M : TPasElement) : boolean;
  124. public
  125. constructor Create(APackage: TPasPackage; AEngine: TFPDocEngine); override;
  126. procedure WriteDoc; override;
  127. end;
  128. implementation
  129. constructor TIPFWriter.Create(APackage: TPasPackage; AEngine: TFPDocEngine);
  130. procedure AddLabel(AElement: TPasElement);
  131. begin
  132. Engine.AddLink(AElement.PathName, GetLabel(AElement));
  133. end;
  134. procedure AddList(AElement: TPasElement; AList: TList);
  135. var
  136. i: Integer;
  137. begin
  138. for i := 0 to AList.Count - 1 do
  139. AddLabel(TPasElement(AList[i]));
  140. end;
  141. procedure ScanModule(AModule: TPasModule);
  142. var
  143. i, j, k: Integer;
  144. s: String;
  145. ClassEl: TPasClassType;
  146. FPEl, AncestorMemberEl: TPasElement;
  147. DocNode: TDocNode;
  148. DidAutolink: Boolean;
  149. begin
  150. AddLabel(AModule);
  151. with AModule do
  152. begin
  153. AddList(AModule, InterfaceSection.ResStrings);
  154. AddList(AModule, InterfaceSection.Consts);
  155. AddList(AModule, InterfaceSection.Types);
  156. if InterfaceSection.Classes.Count > 0 then
  157. begin
  158. for i := 0 to InterfaceSection.Classes.Count - 1 do
  159. begin
  160. ClassEl := TPasClassType(InterfaceSection.Classes[i]);
  161. AddLabel(ClassEl);
  162. for j := 0 to ClassEl.Members.Count - 1 do
  163. begin
  164. FPEl := TPasElement(ClassEl.Members[j]);
  165. if ((FPEl.Visibility = visPrivate) and Engine.HidePrivate) or
  166. ((FPEl.Visibility = visProtected) and Engine.HideProtected) then
  167. continue;
  168. DocNode := Engine.FindDocNode(FPEl);
  169. if not Assigned(DocNode) then
  170. begin
  171. DidAutolink := False;
  172. if Assigned(ClassEl.AncestorType) and
  173. (ClassEl.AncestorType.ClassType = TPasClassType) then
  174. begin
  175. for k := 0 to TPasClassType(ClassEl.AncestorType).Members.Count - 1 do
  176. begin
  177. AncestorMemberEl :=
  178. TPasElement(TPasClassType(ClassEl.AncestorType).Members[k]);
  179. if AncestorMemberEl.Name = FPEl.Name then
  180. begin
  181. DocNode := Engine.FindDocNode(AncestorMemberEl);
  182. if Assigned(DocNode) then
  183. begin
  184. DidAutolink := True;
  185. Engine.AddLink(FPEl.PathName,
  186. Engine.FindAbsoluteLink(AncestorMemberEl.PathName));
  187. break;
  188. end;
  189. end;
  190. end;
  191. end;
  192. if not DidAutolink then
  193. AddLabel(FPEl);
  194. end else
  195. AddLabel(FPEl);
  196. end;
  197. end;
  198. end;
  199. AddList(AModule, InterfaceSection.Functions);
  200. AddList(AModule, InterfaceSection.Variables);
  201. end;
  202. end;
  203. var
  204. i: Integer;
  205. begin
  206. inherited ;
  207. { Allocate labels for all elements for which we are going to create
  208. documentation. This is needed for links to work correctly. }
  209. // Allocate label for the package itself, if a name is given (i.e. <> '#')
  210. if Length(Package.Name) > 1 then
  211. AddLabel(Package);
  212. for i := 0 to Package.Modules.Count - 1 do
  213. ScanModule(TPasModule(Package.Modules[i]));
  214. end;
  215. procedure TIPFWriter.WriteDoc;
  216. var
  217. i : Integer;
  218. begin
  219. PackageName := LowerCase(Copy(Package.Name, 2, 255));
  220. If (Engine.OutPut='') then
  221. Engine.Output:=PackageName+IPFExtension;
  222. Assign(f, Engine.Output);
  223. Rewrite(f);
  224. try
  225. WriteLn('.* This file has been created automatically by FPDoc,');
  226. WriteLn('.* (c) 2000-2003 by Areca Systems GmbH / Sebastian Guenther ([email protected])');
  227. for i := 0 to Package.Modules.Count - 1 do
  228. begin
  229. Module := TPasModule(Package.Modules[i]);
  230. ModuleName := LowerCase(Module.Name);
  231. WriteLn('');
  232. Write(':h1 name=');
  233. WriteLabel(Module);
  234. WriteLnF('.%s', [EscapeTex(Format(SDocUnitTitle, [Module.Name]))]);
  235. ProcessSection(Module.InterfaceSection);
  236. end;
  237. finally
  238. Close(f);
  239. end;
  240. end;
  241. function TIPFWriter.GetLabel(AElement: TPasElement): String;
  242. var
  243. i: Integer;
  244. begin
  245. if AElement.ClassType = TPasUnresolvedTypeRef then
  246. Result := Engine.ResolveLink(Module, AElement.Name)
  247. else
  248. begin
  249. Result := AElement.PathName;
  250. Result := LowerCase(Copy(Result, 2, Length(Result) - 1));
  251. end;
  252. for i := 1 to Length(Result) do
  253. if Result[i] = '.' then
  254. Result[i] := '_';
  255. end;
  256. procedure TIPFWriter.Write(const s: String);
  257. begin
  258. System.Write(f, s);
  259. end;
  260. procedure TIPFWriter.WriteF(const s: String; const Args: array of const);
  261. begin
  262. System.Write(f, Format(s, Args));
  263. end;
  264. procedure TIPFWriter.WriteLn(const s: String);
  265. begin
  266. System.WriteLn(f, s);
  267. end;
  268. procedure TIPFWriter.WriteLnF(const s: String; const Args: array of const);
  269. begin
  270. System.WriteLn(f, Format(s, Args));
  271. end;
  272. Function TIPFWriter.EscapeTex(S : String) : String;
  273. var
  274. i: Integer;
  275. begin
  276. SetLength(Result, 0);
  277. for i := 1 to Length(S) do
  278. case S[i] of
  279. '.': // Escape these characters
  280. Result := Result + '&per.';
  281. ':':
  282. Result := Result + '&colon.';
  283. ',':
  284. Result := Result + '&comma.';
  285. '&':
  286. Result := Result + '&amp.';
  287. (*
  288. ³&amp. ³ampersand ³& ³
  289. ³&and. ³and ³^ ³
  290. ³&apos. ³apostrophe ³' ³
  291. ³&asterisk. ³asterisk ³* ³
  292. ³&atsign. ³at sign ³@ ³
  293. ³&bslash., &bsl. ³back slash ³\ ³
  294. ³&caret. ³caret symbol ³^ ³
  295. ³&cdq. ³close double quote ³" ³
  296. ³&csq. ³close single quote ³' ³
  297. ³&comma. ³comma ³, ³
  298. ³&colon. ³colon ³: ³
  299. ³&dash. ³dash ³- ³
  300. ³&degree., &deg. ³degree ³ø ³
  301. ³&dollar. ³dollar sign ³$ ³
  302. ³&dot. ³dot ³ú ³
  303. ³&darrow. ³down arrow ³ ³
  304. ³&emdash. ³em dash ³- ³
  305. ³&endash. ³en dash ³- ³
  306. ³&eq., &equals., ³equal sign ³= ³
  307. ³&eqsym. ³ ³ ³
  308. ³&xclm., &xclam. ³exclamation point ³! ³
  309. ³&gtsym., &gt. ³greater than ³> ³
  310. ³&house. ³house ³ ³
  311. ³&hyphen. ³hyphen ³- ³
  312. ³&larrow. ³left arrow ³ ³
  313. ³&lahead. ³left arrowhead ³ ³
  314. ³&lbrace., &lbrc. ³left brace ³{ ³
  315. ³&lbracket. &lbrk. ³left bracket ³[ ³
  316. ³&lpar. , &lparen. ³left parenthesis ³( ³
  317. ³&mdash. ³em dash ³- ³
  318. ³&minus. ³minus sign ³- ³
  319. ³&ndash. ³en dash ³- ³
  320. ³&numsign. ³number sign ³# ³
  321. ³&odq. ³open double quote ³" ³
  322. ³&osq. ³open single quote ³` ³
  323. ³&percent. ³percent ³% ³
  324. ³&per. ³period ³. ³
  325. ³&plus. ³plus sign ³+ ³
  326. ³&rbrace., &rbrc. ³right brace ³} ³
  327. ³&rbracket., &rbrk. ³right bracket ³] ³
  328. ³&rpar., &rparen. ³right parenthesis ³) ³
  329. ³&slash., &slr. ³slash ³/ ³
  330. ³&splitvbar. ³split vertical bar ³| ³
  331. ³ ³(piping symbol) ³ ³
  332. ³&sqbul. ³square bullet ³þ ³
  333. ³&tilde. ³tilde ³~ ³
  334. ³&us. ³underscore ³_ ³
  335. *)
  336. else
  337. Result := Result + S[i];
  338. end;
  339. end;
  340. Function TIPFWriter.StripTex(S : String) : String;
  341. var
  342. I,L: Integer;
  343. begin
  344. Result:=S;
  345. // SetLength(Result, 0);
  346. // for i := 1 to Length(S) do
  347. // If not (S[i] in ['&','{','}','#','_','$','%','''','~','^', '\']) then
  348. // Result := Result + S[i];
  349. end;
  350. procedure TIPFWriter.DescrWriteText(const AText: DOMString);
  351. begin
  352. Write(EscapeTex(AText));
  353. end;
  354. procedure TIPFWriter.DescrBeginBold;
  355. begin
  356. Write(':hp2.');
  357. end;
  358. procedure TIPFWriter.DescrEndBold;
  359. begin
  360. WriteLn(':ehp2.');
  361. end;
  362. procedure TIPFWriter.DescrBeginItalic;
  363. begin
  364. Write(':hp1.');
  365. end;
  366. procedure TIPFWriter.DescrEndItalic;
  367. begin
  368. WriteLn(':ehp1.');
  369. end;
  370. procedure TIPFWriter.DescrBeginEmph;
  371. begin
  372. Write(':hp2.');
  373. end;
  374. procedure TIPFWriter.DescrEndEmph;
  375. begin
  376. Write(':ehp2.');
  377. end;
  378. procedure TIPFWriter.DescrWriteFileEl(const AText: DOMString);
  379. begin
  380. Write(':hp2.');
  381. DescrWriteText(AText);
  382. Write(':ehp2.');
  383. end;
  384. procedure TIPFWriter.DescrWriteKeywordEl(const AText: DOMString);
  385. begin
  386. Write(':hp2.');
  387. DescrWriteText(AText);
  388. Write(':ehp2.');
  389. end;
  390. procedure TIPFWriter.DescrWriteVarEl(const AText: DOMString);
  391. begin
  392. Write(':hp2.');
  393. DescrWriteText(AText);
  394. Write(':ehp2.');
  395. end;
  396. procedure TIPFWriter.DescrBeginLink(const AId: DOMString);
  397. var
  398. i: Integer;
  399. begin
  400. FLink := Engine.ResolveLink(Module, AId);
  401. While pos(':',flink)>0 do flink[pos(':',flink)]:='_';
  402. // System.WriteLn('Link "', AId, '" => ', FLink);
  403. WriteF(':link reftype=hd refid=%s.', [flink]);
  404. end;
  405. procedure TIPFWriter.DescrEndLink;
  406. begin
  407. Write(':elink.');
  408. end;
  409. procedure TIPFWriter.DescrWriteLinebreak;
  410. begin
  411. WriteLn('.br');
  412. end;
  413. procedure TIPFWriter.DescrBeginParagraph;
  414. begin
  415. WriteLn(':p.');
  416. // Do nothing
  417. end;
  418. procedure TIPFWriter.DescrEndParagraph;
  419. begin
  420. WriteLn('');
  421. WriteLn('');
  422. end;
  423. procedure TIPFWriter.DescrBeginCode(HasBorder: Boolean;
  424. const AHighlighterName: String);
  425. begin
  426. StartListing(HasBorder);
  427. end;
  428. procedure TIPFWriter.DescrWriteCodeLine(const ALine: String);
  429. begin
  430. WriteLn(EscapeTex(ALine));
  431. end;
  432. procedure TIPFWriter.DescrEndCode;
  433. begin
  434. EndListing
  435. end;
  436. procedure TIPFWriter.DescrBeginOrderedList;
  437. begin
  438. WriteLn(':ol.');
  439. end;
  440. procedure TIPFWriter.DescrEndOrderedList;
  441. begin
  442. WriteLn(':eol.');
  443. end;
  444. procedure TIPFWriter.DescrBeginUnorderedList;
  445. begin
  446. WriteLn(':ul.');
  447. end;
  448. procedure TIPFWriter.DescrEndUnorderedList;
  449. begin
  450. WriteLn(':eul.');
  451. end;
  452. procedure TIPFWriter.DescrBeginDefinitionList;
  453. begin
  454. WriteLn(':dl.');
  455. end;
  456. procedure TIPFWriter.DescrEndDefinitionList;
  457. begin
  458. WriteLn(':edl.');
  459. end;
  460. procedure TIPFWriter.DescrBeginListItem;
  461. begin
  462. Write(':li.');
  463. end;
  464. procedure TIPFWriter.DescrEndListItem;
  465. begin
  466. WriteLn('');
  467. end;
  468. procedure TIPFWriter.DescrBeginDefinitionTerm;
  469. begin
  470. Write(':li.');
  471. end;
  472. procedure TIPFWriter.DescrEndDefinitionTerm;
  473. begin
  474. WriteLn('');
  475. end;
  476. procedure TIPFWriter.DescrBeginDefinitionEntry;
  477. begin
  478. WriteLn('');
  479. // Do nothing
  480. end;
  481. procedure TIPFWriter.DescrEndDefinitionEntry;
  482. begin
  483. WriteLn('');
  484. end;
  485. procedure TIPFWriter.DescrBeginSectionTitle;
  486. begin
  487. Write(':h3.');
  488. end;
  489. procedure TIPFWriter.DescrBeginSectionBody;
  490. begin
  491. WriteLn('');
  492. end;
  493. procedure TIPFWriter.DescrEndSection;
  494. begin
  495. WriteLn('');
  496. // Do noting
  497. end;
  498. procedure TIPFWriter.DescrBeginRemark;
  499. begin
  500. WriteLn(':note.');
  501. end;
  502. procedure TIPFWriter.DescrEndRemark;
  503. begin
  504. WriteLn('');
  505. end;
  506. procedure TIPFWriter.DescrBeginTable(ColCount: Integer; HasBorder: Boolean);
  507. begin
  508. // !!!: How do we set the border?
  509. // for i := 1 to ColCount do
  510. // Write('l');
  511. // write('}{');
  512. TableCaptionWritten:=False;
  513. end;
  514. procedure TIPFWriter.DescrEndTable;
  515. begin
  516. WriteLn(':etable.');
  517. end;
  518. procedure TIPFWriter.DescrBeginTableCaption;
  519. begin
  520. // Do nothing.
  521. end;
  522. procedure TIPFWriter.DescrEndTableCaption;
  523. begin
  524. Write('');
  525. // Inc(FTableCount);
  526. // Write(IntToStr(FTableCount));
  527. // Writeln('}');
  528. TableCaptionWritten := True;
  529. Write(':table cols=''30 50''.');
  530. end;
  531. procedure TIPFWriter.DescrBeginTableHeadRow;
  532. begin
  533. if not TableCaptionWritten then
  534. DescrEndTableCaption;
  535. TableRowStartFlag := True;
  536. WriteLn(':row.:c.');
  537. end;
  538. procedure TIPFWriter.DescrEndTableHeadRow;
  539. begin
  540. WriteLn('');
  541. end;
  542. procedure TIPFWriter.DescrBeginTableRow;
  543. begin
  544. if not TableCaptionWritten then
  545. DescrEndTableCaption;
  546. TableRowStartFlag := True;
  547. WriteLn(':row.:c.');
  548. end;
  549. procedure TIPFWriter.DescrEndTableRow;
  550. begin
  551. end;
  552. procedure TIPFWriter.DescrBeginTableCell;
  553. begin
  554. if TableRowStartFlag then
  555. TableRowStartFlag := False
  556. else
  557. WriteLn(':c.');
  558. end;
  559. procedure TIPFWriter.DescrEndTableCell;
  560. begin
  561. WriteLn('');
  562. // Do nothing
  563. end;
  564. function TIPFWriter.ConstValue(ConstDecl: TPasConst): String;
  565. begin
  566. if Assigned(ConstDecl) then
  567. Result := ConstDecl.ClassName
  568. else
  569. Result := '<nil>';
  570. end;
  571. procedure TIPFWriter.WriteUnitOverview(ASection: TPasSection);
  572. var
  573. i: Integer;
  574. UnitRef: TPasType;
  575. DocNode: TDocNode;
  576. begin
  577. if ASection.UsesList.Count > 0 then
  578. begin
  579. WriteLnF(':h2.%s', [SDocUsedUnits]);
  580. WriteLn(':ol.');
  581. for i := 0 to ASection.UsesList.Count - 1 do
  582. begin
  583. UnitRef := TPasType(ASection.UsesList[i]);
  584. WriteLnF(':li.%s', [UnitRef.Name]);
  585. end;
  586. WriteLn(':eol.');
  587. end;
  588. DocNode := Engine.FindDocNode(ASection.Parent);
  589. if Assigned(DocNode) and not IsDescrNodeEmpty(DocNode.Descr) then
  590. begin
  591. WriteLnF(':h2.%s', [EscapeTex(SDocOverview)]);
  592. WriteDescr(ASection.Parent, DocNode.Descr);
  593. Writeln('');
  594. end;
  595. end;
  596. procedure TIPFWriter.WriteResourceStrings(ASection: TPasSection);
  597. var
  598. ResStrDecl: TPasResString;
  599. i: Integer;
  600. begin
  601. if ASection.ResStrings.Count > 0 then
  602. begin
  603. StartSubSection(SDocResStrings,ModuleName+'ResStrings');
  604. for i := 0 to ASection.ResStrings.Count - 1 do
  605. begin
  606. ResStrDecl := TPasResString(ASection.ResStrings[i]);
  607. StartListing(false, '');
  608. Writeln(ResStrDecl.GetDeclaration(True));
  609. EndListing;
  610. WriteLabel(ResStrDecl);
  611. WriteIndex(ResStrDecl);
  612. WriteDescr(ResStrDecl);
  613. Writeln('');
  614. end;
  615. end;
  616. end;
  617. procedure TIPFWriter.WriteConsts(ASection: TPasSection);
  618. var
  619. i: Integer;
  620. ConstDecl: TPasConst;
  621. begin
  622. if ASection.Consts.Count > 0 then
  623. begin
  624. WriteLnF(':h3 name=suse_%sconstants.%s', [EscapeTex(ModuleName), EscapeTex(SDocConstants)]);
  625. for i := 0 to ASection.Consts.Count - 1 do
  626. begin
  627. ConstDecl := TPasConst(ASection.Consts[i]);
  628. StartListing(False);
  629. WriteLn(EscapeTex(ConstDecl.GetDeclaration(True)));
  630. EndListing;
  631. // WriteLabel(ConstDecl);
  632. // WriteIndex(ConstDecl);
  633. WriteDescr(ConstDecl);
  634. end;
  635. end;
  636. end;
  637. procedure TIPFWriter.WriteEnumElements(TypeDecl : TPasEnumType);
  638. Var
  639. EV : TPasEnumValue;
  640. I : Integer;
  641. DocNode : TDocNode;
  642. begin
  643. With TypeDecl do
  644. begin
  645. SortElementList(Values);
  646. DescrBeginTable(2,True);
  647. DescrBeginTableCaption;
  648. Writeln(EscapeTex(Format(SDocValuesForEnum,[TypeDecl.Name])));
  649. DescrEndTableCaption;
  650. DescrBeginTableHeadRow;
  651. DescrBeginTableCell;
  652. Writeln(EscapeTex(SDocValue));
  653. DescrEndTableCell;
  654. DescrBeginTableCell;
  655. Writeln(EscapeTex(SDocExplanation));
  656. DescrEndTableCell;
  657. DescrEndTableHeadRow;
  658. For I:=0 to Values.Count-1 do
  659. begin
  660. EV:=TPasEnumValue(Values[i]);
  661. DescrBeginTableRow;
  662. DescrBeginTableCell;
  663. Writeln(EscapeTex(EV.Name));
  664. DescrEndTableCell;
  665. DescrBeginTableCell;
  666. DocNode := Engine.FindDocNode(EV);
  667. if Assigned(DocNode) and (not IsDescrNodeEmpty(DocNode.ShortDescr)) then
  668. WriteDescr(EV,DocNode.ShortDescr);
  669. DescrEndTableCell;
  670. DescrEndTableRow;
  671. end;
  672. DescrEndTable;
  673. end;
  674. end;
  675. procedure TIPFWriter.WriteTypes(ASection: TPasSection);
  676. var
  677. i: Integer;
  678. TypeDecl: TPasType;
  679. begin
  680. if ASection.Types.Count > 0 then
  681. begin
  682. StartSubSection(SDocTypes,ModuleName+'Types');
  683. for i := 0 to ASection.Types.Count - 1 do
  684. begin
  685. TypeDecl := TPasType(ASection.Types[i]);
  686. WriteLn(':h4 name='+GetLabel(TypeDecl)+'.');
  687. // WriteLn(':hdref refid='+GetLabel(TypeDecl)+'.');
  688. // WriteLabel(TypeDecl);
  689. // WriteIndex(TypeDecl);
  690. StartListing(False);
  691. Writeln(EscapeTex(TypeDecl.GetDeclaration(True)));
  692. EndListing;
  693. If TypeDecl is TPasEnumType then
  694. begin
  695. WriteENumElements(TypeDecl as TPasEnumType);
  696. end;
  697. WriteDescr(TypeDecl);
  698. end;
  699. end;
  700. end;
  701. procedure TIPFWriter.WriteVars(ASection: TPasSection);
  702. var
  703. VarDecl: TPasVariable;
  704. i: Integer;
  705. begin
  706. if ASection.Variables.Count > 0 then
  707. begin
  708. StartSubsection(SDocVariables,ModuleName+'Variables');
  709. for i := 0 to ASection.Variables.Count - 1 do
  710. begin
  711. // WriteIndex(VarDecl);
  712. VarDecl := TPasVariable(ASection.Variables[i]);
  713. WriteLn(':h4 name='+GetLabel(VarDecl)+'.');
  714. StartListing(False);
  715. WriteLn(EscapeTex(VarDecl.GetDeclaration(True)));
  716. EndListing;
  717. WriteDescr(VarDecl);
  718. end;
  719. end;
  720. end;
  721. procedure TIPFWriter.WriteVarsConstsTypes(ASection: TPasSection);
  722. begin
  723. With Asection do
  724. if (Consts.Count > 0) or
  725. (Types.Count > 0) or
  726. (Variables.Count > 0) or
  727. (ResStrings.Count>0) then
  728. begin
  729. StartSection(SDocConstsTypesVars, ModuleName+'ConstsTypesVars');
  730. WriteResourceStrings(ASection);
  731. WriteConsts(ASection);
  732. WriteTypes(ASection);
  733. WriteVars(ASection);
  734. end;
  735. end;
  736. procedure TIPFWriter.WriteProcedure(ProcDecl : TPasProcedureBase);
  737. var
  738. DocNode: TDocNode;
  739. OP : TPasOverloadedProc;
  740. i : integer;
  741. begin
  742. With ProcDecl do
  743. begin
  744. if Not (Assigned(Parent) and Parent.InheritsFrom(TPasClassType)) then
  745. begin
  746. StartSubSection(Name, GetLabel(ProcDecl));
  747. // WriteLabel(ProcDecl);
  748. // WriteIndex(ProcDecl);
  749. end
  750. else
  751. begin // Parent assigned and hence method.
  752. StartSubSection(Parent.Name+'&per.'+Name, GetLabel(ProcDecl));
  753. // WriteLabel(ProcDecl);
  754. // WriteIndex(Parent.Name+'.'+Name);
  755. end;
  756. // Writeln('\begin{FPCList}');
  757. DocNode := Engine.FindDocNode(ProcDecl);
  758. if Assigned(DocNode) and Assigned(DocNode.ShortDescr) then
  759. begin
  760. Writeln(':hp2.Synopsis:ehp2.&colon. ');
  761. WriteDescr(ProcDecl, DocNode.ShortDescr);
  762. WriteLn('');
  763. WriteLn('.br');
  764. end;
  765. Writeln(':hp2.Declaration:ehp2.&colon. ');
  766. StartListing(False);
  767. if ClassType = TPasOverloadedProc then
  768. begin
  769. OP:=TPasOverloadedProc(ProcDecl);
  770. for i := 0 to OP.Overloads.Count - 1 do
  771. begin
  772. WriteLn(TPasProcedure(OP.Overloads[i]).GetDeclaration(True));
  773. end;
  774. end
  775. else
  776. WriteLn(GetDeclaration(True));
  777. EndListing;
  778. WriteLn('');
  779. WriteLn('.br');
  780. If Assigned(Parent) then
  781. begin
  782. Writeln(':hp2.Visibility:ehp2.&colon. ');
  783. Writeln(VisibilityNames[Visibility]);
  784. WriteLn('');
  785. WriteLn('.br');
  786. end;
  787. if Assigned(DocNode) and Assigned(DocNode.Descr) then
  788. begin
  789. Writeln(':hp2.Description:ehp2.&colon. ');
  790. WriteDescr(ProcDecl);
  791. WriteLn('');
  792. WriteLn('.br');
  793. end;
  794. if Assigned(DocNode) and Assigned(DocNode.ErrorsDoc) then
  795. begin
  796. Writeln(':hp2.Errors:ehp2.&colon.');
  797. WriteDescr(ProcDecl, DocNode.ErrorsDoc);
  798. WriteLn('');
  799. WriteLn('.br');
  800. end;
  801. WriteSeeAlso(DocNode);
  802. WriteLn('');
  803. WriteLn('.br');
  804. // Writeln('\end{FPCList}');
  805. WriteExample(DocNode);
  806. end;
  807. end;
  808. procedure TIPFWriter.WriteFunctionsAndProcedures(ASection: TPasSection);
  809. var
  810. i: Integer;
  811. begin
  812. if ASection.Functions.Count > 0 then
  813. begin
  814. StartSection(SDocProceduresAndFunctions,ModuleName+'Functions');
  815. for i := 0 to ASection.Functions.Count - 1 do
  816. WriteProcedure(TPasProcedureBase(ASection.Functions[i]));
  817. end;
  818. end;
  819. procedure TIPFWriter.WriteExample(ADocNode: TDocNode);
  820. var
  821. Example: TDOMElement;
  822. begin
  823. if Assigned(ADocNode) then
  824. begin
  825. Example := ADocNode.FirstExample;
  826. while Assigned(Example) do
  827. begin
  828. WritelnF(':xmp.%s:exmp.', [EscapeTex(Engine.GetExampleFileName(Example))]);
  829. if Assigned(Example.NextSibling) then
  830. WriteLn('');
  831. Example := TDomElement(Example.NextSibling);
  832. end;
  833. end;
  834. end;
  835. procedure TIPFWriter.WriteSeeAlso(ADocNode: TDocNode);
  836. var
  837. Node: TDOMNode;
  838. s: String;
  839. begin
  840. if Assigned(ADocNode) and Assigned(ADocNode.SeeAlso) and
  841. Assigned(ADocNode.SeeAlso.FirstChild) then
  842. begin
  843. Writeln(':hp2.SeeAlso:ehp2.');
  844. Node := ADocNode.SeeAlso.FirstChild;
  845. while Assigned(Node) do
  846. begin
  847. if (Node.NodeType = ELEMENT_NODE) and
  848. (Node.NodeName = 'link') then
  849. begin
  850. S:=TDomElement(Node)['id'];
  851. DescrBeginLink(S);
  852. Writeln(S);
  853. DescrEndLink();
  854. if Assigned(Node.NextSibling) Then
  855. Writeln(',');
  856. end;
  857. Node:=Node.NextSibling;
  858. end;
  859. end;
  860. end;
  861. procedure TIPFWriter.WriteClasses(ASection: TPasSection);
  862. var
  863. i: Integer;
  864. begin
  865. if (ASection.Classes.Count > 0) then
  866. begin
  867. for i := 0 to ASection.Classes.Count - 1 do
  868. WriteClassDecl(TPasClassType(ASection.Classes[i]));
  869. end;
  870. end;
  871. procedure TIPFWriter.ProcessSection(ASection: TPasSection);
  872. begin
  873. With ASection do
  874. begin
  875. SortElementList(UsesList);
  876. SortElementList(Declarations);
  877. SortElementList(ResStrings);
  878. SortElementList(Types);
  879. SortElementList(Consts);
  880. SortElementList(Classes);
  881. SortElementList(Functions);
  882. SortElementList(Variables);
  883. end;
  884. WriteUnitOverView(ASection);
  885. WriteVarsConstsTypes(ASection);
  886. WriteFunctionsAndProcedures(ASection);
  887. WriteClasses(ASection);
  888. end;
  889. Function TIPFWriter.ShowMember(M : TPasElement) : boolean;
  890. begin
  891. Result:=not ((M.Visibility=visPrivate) and Engine.HidePrivate);
  892. If Result then
  893. Result:=Not ((M.Visibility=visProtected) and Engine.HideProtected)
  894. end;
  895. procedure TIPFWriter.WriteClassMethodOverview(ClassDecl : TPasClassType);
  896. var
  897. Member: TPasElement;
  898. i: Integer;
  899. DocNode: TDocNode;
  900. List : TStringList;
  901. begin
  902. List:=TStringList.Create;
  903. Try
  904. List.Sorted:=True;
  905. for i := 0 to ClassDecl.Members.Count - 1 do
  906. begin
  907. Member := TPasElement(ClassDecl.Members[i]);
  908. With Member do
  909. if InheritsFrom(TPasProcedureBase) and ShowMember(Member) then
  910. List.AddObject(Member.Name,Member);
  911. end;
  912. If List.Count>0 then
  913. begin
  914. StartSubSection(SDocMethodOverview, GetLabel(ClassDecl) + ':Methods');
  915. // WriteLabel();
  916. WriteLn(':parml.');
  917. // WriteLnF('%s & %s & %s \\ \hline', [EscapeTex(SDocPage), EscapeTex(SDocMethod), EscapeTex(SDocDescription)]);
  918. For I:=0 to List.Count-1 do
  919. begin
  920. Member:=TPasElement(List.Objects[i]);
  921. DocNode := Engine.FindDocNode(Member);
  922. WriteF(':pt.:link reftype=hd refid=%s.%s:elink.:pd.',[StripTex(GetLabel(Member)), EscapeTex(Member.Name)]);
  923. if Assigned(DocNode) and Assigned(DocNode.ShortDescr) then
  924. WriteDescr(Member, DocNode.ShortDescr);
  925. WriteLn('');
  926. WriteLn('.br');
  927. end;
  928. WriteLn(':eparml.');
  929. // WriteLn('\end{tabularx}');
  930. end;
  931. Finally
  932. List.Free;
  933. end;
  934. end;
  935. procedure TIPFWriter.WriteClassPropertyOverview(ClassDecl : TPasClassType);
  936. var
  937. Member: TPasElement;
  938. i: Integer;
  939. s: String;
  940. DocNode: TDocNode;
  941. List : TStringList;
  942. begin
  943. // Write property overview
  944. List:=TStringList.Create;
  945. Try
  946. List.Sorted:=True;
  947. for i := 0 to ClassDecl.Members.Count - 1 do
  948. begin
  949. Member := TPasElement(ClassDecl.Members[i]);
  950. With Member do
  951. if InheritsFrom(TPasProperty) and SHowMember(Member) then
  952. List.AddObject(Member.Name,Member)
  953. end;
  954. If (List.Count>0) then
  955. begin
  956. StartSubSection(SDocPropertyOverview, GetLabel(ClassDecl) + ':Properties');
  957. // WriteLabel(GetLabel(ClassDecl) + ':Properties');
  958. WriteLn(':parml.');
  959. // WriteLn('\begin{tabularx}{\textwidth}{lllX}');
  960. // WriteLnF('%s & %s & %s & %s \\ \hline',
  961. // [EscapeTex(SDocPage), EscapeTex(SDocProperty), EscapeTex(SDocAccess), EscapeTex(SDocDescription)]);
  962. For I:=0 to List.Count-1 do
  963. begin
  964. Member:=TPasElement(List.objects[i]);
  965. WriteF(':pt.:link reftype=hd refid=%s.%s:elink.:pd.',[StripTex(GetLabel(Member)), EscapeTex(Member.Name)]);
  966. setlength(S,0);
  967. if Length(TPasProperty(Member).ReadAccessorName) > 0 then
  968. s := s + 'r';
  969. if Length(TPasProperty(Member).WriteAccessorName) > 0 then
  970. s := s + 'w';
  971. if Length(TPasProperty(Member).StoredAccessorName) > 0 then
  972. s := s + 's';
  973. // Write(s + ' & ');
  974. DocNode := Engine.FindDocNode(Member);
  975. if Assigned(DocNode) and Assigned(DocNode.ShortDescr) then
  976. WriteDescr(Member, DocNode.ShortDescr);
  977. WriteLn('');
  978. WriteLn('.br');
  979. end;
  980. WriteLn(':eparml.');
  981. end;
  982. Finally
  983. List.Free;
  984. end;
  985. end;
  986. procedure TIPFWriter.WriteClassDecl(ClassDecl: TPasClassType);
  987. var
  988. DocNode: TDocNode;
  989. Vis: TPasMemberVisibilities;
  990. Member: TPasElement;
  991. i: Integer;
  992. begin
  993. StartSection(ClassDecl.Name, GetLabel(ClassDecl));
  994. // WriteLabel(ClassDecl);
  995. // WriteIndex(ClassDecl);
  996. DocNode := Engine.FindDocNode(ClassDecl);
  997. if Assigned(DocNode) and ((not IsDescrNodeEmpty(DocNode.Descr)) or
  998. (not IsDescrNodeEmpty(DocNode.ShortDescr))) then
  999. begin
  1000. // StartSubSection(SDocDescription, GetLabel(ClassDecl) + ':Description');
  1001. WriteDescr(ClassDecl);
  1002. end;
  1003. // Write method overview
  1004. WriteClassMethodOverView(ClassDecl);
  1005. // Write Property Overview;
  1006. WriteClassPropertyOverView(ClassDecl);
  1007. // Write method & property descriptions
  1008. // Determine visibilities
  1009. Vis := AllVisibilities;
  1010. if Engine.HidePrivate then
  1011. Exclude(Vis,visPrivate);
  1012. if Engine.HideProtected then
  1013. Exclude(Vis,visProtected);
  1014. for i := 0 to ClassDecl.Members.Count - 1 do
  1015. begin
  1016. Member := TPasElement(ClassDecl.Members[i]);
  1017. if ((Member.InheritsFrom(TPasProcedureBase)) and
  1018. (Member.Visibility in Vis)) then
  1019. WriteProcedure(TPasProcedureBase(Member));
  1020. end;
  1021. // properties.
  1022. for i := 0 to ClassDecl.Members.Count - 1 do
  1023. begin
  1024. Member := TPasElement(ClassDecl.Members[i]);
  1025. if ((Member.InheritsFrom(TPasProperty)) and
  1026. (Member.Visibility in Vis)) then
  1027. WriteProperty(TPasProperty(Member));
  1028. end;
  1029. end;
  1030. procedure TIPFWriter.WriteProperty(PropDecl : TPasProperty);
  1031. var
  1032. DocNode: TDocNode;
  1033. S: String;
  1034. begin
  1035. With PropDecl do
  1036. begin
  1037. StartSubSection(Parent.Name+'&per.'+Name, GetLabel(PropDecl));
  1038. // WriteLabel(PropDecl);
  1039. // WriteIndex(Parent.Name+'.'+Name);
  1040. // Writeln('\begin{FPCList}');
  1041. DocNode := Engine.FindDocNode(PropDecl);
  1042. if Assigned(DocNode) and Assigned(DocNode.ShortDescr) then
  1043. begin
  1044. Writeln(':hp2.Synopsis:ehp2.&colon. ');
  1045. WriteDescr(PropDecl, DocNode.ShortDescr);
  1046. WriteLn('');
  1047. WriteLn('.br');
  1048. end;
  1049. Writeln(':hp2.Declaration:ehp2.&colon. ');
  1050. StartListing(False);
  1051. WriteLn('Property '+GetDeclaration(True));
  1052. EndListing;
  1053. WriteLn('');
  1054. WriteLn('.br');
  1055. If Assigned(Parent) then
  1056. begin
  1057. Writeln(':hp2.Visibility:ehp2.&colon. ');
  1058. Writeln(VisibilityNames[Visibility]);
  1059. WriteLn('');
  1060. WriteLn('.br');
  1061. end;
  1062. Writeln(':hp2.Access:ehp2.&colon.');
  1063. Setlength(S,0);
  1064. If Length(ReadAccessorName) > 0 then
  1065. S:='Read';
  1066. if Length(WriteAccessorName) > 0 then
  1067. begin
  1068. If S<>'' then
  1069. S:=S+',';
  1070. S:=S+'Write';
  1071. end;
  1072. Writeln(S);
  1073. WriteLn('');
  1074. WriteLn('.br');
  1075. if Assigned(DocNode) and Assigned(DocNode.Descr) then
  1076. begin
  1077. Writeln(':hp2.Description:ehp2.&colon.');
  1078. WriteDescr(PropDecl);
  1079. WriteLn('');
  1080. WriteLn('.br');
  1081. end;
  1082. if Assigned(DocNode) and Assigned(DocNode.ErrorsDoc) then
  1083. begin
  1084. Writeln(':hp2.Errors:ehp2.&colon. ');
  1085. WriteDescr(PropDecl, DocNode.ErrorsDoc);
  1086. WriteLn('');
  1087. WriteLn('.br');
  1088. end;
  1089. WriteSeeAlso(DocNode);
  1090. WriteLn('');
  1091. WriteLn('.br');
  1092. // Writeln('\end{FPCList}');
  1093. WriteExample(DocNode);
  1094. end;
  1095. end;
  1096. Function CompareElements(P1,P2 : Pointer) : Integer;
  1097. begin
  1098. Result:=CompareText(TPasElement(P1).Name,TPasElement(P2).Name);
  1099. end;
  1100. procedure TIPFWriter.SortElementList(List : TList);
  1101. begin
  1102. List.Sort(@CompareElements)
  1103. end;
  1104. procedure TIPFWriter.WriteLabel(El: TPasElement);
  1105. begin
  1106. WriteLabel(GetLabel(El));
  1107. end;
  1108. procedure TIPFWriter.WriteLabel(const s: String);
  1109. var
  1110. x: String;
  1111. begin
  1112. X:=s;
  1113. While pos(':',x)>0 do x[pos(':',x)]:='_';
  1114. WriteF('%s', [LowerCase(StripTex(x))]);
  1115. end;
  1116. procedure TIPFWriter.WriteIndex(El : TPasElement);
  1117. begin
  1118. WriteIndex(El.Name);
  1119. end;
  1120. procedure TIPFWriter.WriteIndex(const s : String);
  1121. begin
  1122. // Write('\index{');
  1123. // Write(EscapeTex(s));
  1124. // Writeln('}');
  1125. end;
  1126. procedure TIPFWriter.StartListing(Frames: Boolean; const name: String);
  1127. begin
  1128. Writeln(':xmp.')
  1129. end;
  1130. procedure TIPFWriter.StartListing(Frames : Boolean);
  1131. begin
  1132. StartListing(Frames,'');
  1133. end;
  1134. procedure TIPFWriter.EndListing;
  1135. begin
  1136. Writeln(':exmp.')
  1137. end;
  1138. procedure TIPFWriter.WriteCommentLine;
  1139. const
  1140. CommentLine =
  1141. '.* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%';
  1142. begin
  1143. WriteLn('');
  1144. Writeln(CommentLine);
  1145. end;
  1146. procedure TIPFWriter.WriteComment(Comment : String);
  1147. begin
  1148. // Write('.* ');
  1149. // Writeln(Comment);
  1150. end;
  1151. procedure TIPFWriter.StartSection(SectionName : String; SectionLabel : String);
  1152. begin
  1153. // StartSection(SectionName);
  1154. WriteCommentLine;
  1155. WriteComment(SectionName);
  1156. Write(':h2 name=');
  1157. WriteLabel(SectionLabel);
  1158. WriteLn('.'+EscapeTex(SectionName));
  1159. end;
  1160. //procedure TIPFWriter.StartSection(SectionName : String);
  1161. //begin
  1162. //end;
  1163. procedure TIPFWriter.StartSubSection(SubSectionName : String; SubSectionLabel : String);
  1164. begin
  1165. Writeln('');
  1166. WriteComment(SubsectionName);
  1167. Write(':h3 name=');
  1168. WriteLabel(SubsectionLabel);
  1169. WriteLn('.'+{EscapeTex(}SubSectionName{)});
  1170. end;
  1171. //procedure TIPFWriter.StartSubSection(SubSectionName : String);
  1172. //begin
  1173. //end;
  1174. procedure TIPFWriter.StartChapter(ChapterName : String; ChapterLabel : String);
  1175. begin
  1176. StartChapter(ChapterName);
  1177. WriteLabel(ChapterLabel);
  1178. end;
  1179. procedure TIPFWriter.StartChapter(ChapterName : String);
  1180. begin
  1181. Writeln('');
  1182. WriteCommentLine;
  1183. WriteComment(ChapterName);
  1184. WriteCommentLine;
  1185. Writeln(':h1.'+{EscapeTex(}ChapterName{)});
  1186. end;
  1187. initialization
  1188. // Do not localize.
  1189. RegisterWriter(TIPFWriter,'ipf','IPF output.');
  1190. finalization
  1191. UnRegisterWriter('ipf');
  1192. end.