dw_ipf.pp 37 KB

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