dwlinear.pp 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405
  1. {$mode objfpc}
  2. {$H+}
  3. unit dwlinear;
  4. interface
  5. uses
  6. Classes, SysUtils, DGlobals, dWriter, pastree, dom;
  7. Type
  8. { TLinearWriter }
  9. TLinearWriter = Class(TFPDocWriter)
  10. FStream : TStream;
  11. PackageName: String;
  12. Module: TPasModule;
  13. FLastURL : DomString;
  14. private
  15. FDupLinkedDoc: Boolean;
  16. Protected
  17. ModuleName: String;
  18. // Writing support.
  19. procedure Write(const s: String); virtual;
  20. procedure WriteLn(const s: String); virtual;
  21. procedure WriteF(const s: String; const Args: array of const); virtual;
  22. procedure WriteLnF(const s: String; const Args: array of const); virtual;
  23. Function PushWriteContext(S : TStream) : TStream;
  24. Procedure PopWriteContext(S : TSTream);
  25. procedure WriteLabel(El: TPasElement);
  26. procedure WriteIndex(El: TPasElement);
  27. procedure WriteTypeDecl(El: TPasElement); virtual;
  28. procedure WriteVariableDecl(El: TPasElement); virtual;
  29. procedure WriteConstDecl(El: TPasElement); virtual;
  30. // Auxiliary routines
  31. procedure DescrBeginURL(const AURL: DOMString); override; // Provides a default implementation
  32. procedure DescrEndURL; override;
  33. procedure SortElementList(List : TFPList);
  34. procedure StartListing(Frames: Boolean);
  35. Function ShowMember(M : TPasElement) : boolean;
  36. procedure StartChapter(ChapterName : String; ChapterLabel : String); virtual;
  37. procedure StartSection(SectionName : String; SectionLabel : String); virtual;
  38. procedure StartSubSection(SubSectionName : String; SubSectionLabel : String); virtual;
  39. procedure StartSubSubSection(SubSubSectionName : String; SubSubSectionLabel : String); virtual;
  40. Function GetDescrString(AContext: TPasElement; DescrNode: TDOMElement) : String;
  41. function ConstValue(ConstDecl: TPasConst): String; virtual;
  42. procedure ProcessSection(ASection: TPasSection); virtual;
  43. // Procedures which MAY be overridden in descendents
  44. procedure WriteBeginDocument; virtual;
  45. procedure WriteEndDocument; virtual;
  46. Function EscapeText(S : String) : String; virtual;
  47. Function StripText(S : String) : String; virtual;
  48. Procedure StartProcedure; Virtual;
  49. Procedure EndProcedure; Virtual;
  50. Procedure StartProperty; Virtual;
  51. Procedure EndProperty; Virtual;
  52. Procedure StartSynopsis; Virtual;
  53. Procedure StartDeclaration; Virtual;
  54. Procedure StartVisibility; Virtual;
  55. Procedure StartDescription; Virtual;
  56. Procedure StartAccess; Virtual;
  57. Procedure StartErrors; Virtual;
  58. Procedure StartVersion; Virtual;
  59. Procedure StartSeealso; Virtual;
  60. Procedure EndSeealso; Virtual;
  61. // Procedures which MUST be overridden in descendents;
  62. procedure WriteCommentLine; virtual; abstract;
  63. procedure WriteComment(Comment : String); virtual; abstract;
  64. function GetLabel(AElement: TPasElement): String; virtual; abstract;
  65. procedure WriteLabel(Const S : String); virtual; abstract;
  66. procedure WriteIndex(Const S : String); virtual; abstract;
  67. procedure WriteType(const s: string); virtual;
  68. procedure WriteVariable(const s: string); virtual;
  69. procedure WriteConstant(const s: string); virtual;
  70. procedure StartChapter(ChapterName : String); virtual; abstract;
  71. procedure StartSection(SectionName : String); virtual; abstract;
  72. procedure StartSubSection(SubSectionName : String); virtual; abstract;
  73. procedure StartSubSubSection(SubSubSectionName : String); virtual; abstract;
  74. procedure StartListing(Frames: Boolean; const name: String); virtual; abstract;
  75. procedure EndListing; virtual; abstract;
  76. Procedure WriteExampleFile(FN : String); virtual; abstract;
  77. procedure StartOverview(WithAccess : Boolean); virtual; Abstract;
  78. procedure EndOverview; virtual; Abstract;
  79. procedure WriteOverviewMember(const ALabel,AName,Access,ADescr : String); virtual; Abstract;
  80. procedure WriteOverviewMember(const ALabel,AName,ADescr : String); virtual; Abstract;
  81. procedure StartUnitOverview(AModuleName,AModuleLabel : String);virtual; Abstract;
  82. procedure WriteUnitEntry(UnitRef : TPasType);virtual; Abstract;
  83. procedure EndUnitOverview; virtual; Abstract;
  84. Property LastURL : DomString Read FLastURL Write FLastURL;
  85. // Overriden from fpdocwriter;
  86. procedure DescrWriteText(const AText: DOMString); override;
  87. Public
  88. Constructor Create(APackage: TPasPackage; AEngine: TFPDocEngine); override;
  89. function InterpretOption(const Cmd, Arg: String): Boolean; override;
  90. class procedure Usage(List: TStrings); override;
  91. procedure WriteDoc; override;
  92. // Linear Documentation writing methods.
  93. Procedure ProcessPackage;
  94. Procedure ProcessTopics(DocNode : TDocNode; Alevel : Integer);
  95. procedure WriteResourceStrings(ASection: TPasSection);
  96. procedure WriteUnitOverview(ASection: TPasSection);
  97. procedure WriteVarsConstsTypes(ASection: TPasSection);
  98. procedure WriteConsts(ASection: TPasSection);
  99. procedure WriteTypes(ASection: TPasSection); virtual;
  100. procedure WriteEnumElements(TypeDecl : TPasEnumType);
  101. procedure WriteVars(ASection: TPasSection);
  102. procedure WriteFunctionsAndProcedures(ASection: TPasSection);
  103. procedure WriteProcedure(ProcDecl: TPasProcedureBase);
  104. procedure WriteClasses(ASection: TPasSection);
  105. procedure WriteClassDecl(ClassDecl: TPasClassType);
  106. procedure WriteClassMethodOverview(ClassDecl: TPasClassType);
  107. procedure WriteClassPropertyOverview(ClassDecl: TPasClassType);
  108. procedure WriteClassInterfacesOverview(ClassDecl: TPasClassType);
  109. procedure WriteClassInheritanceOverview(ClassDecl: TPasClassType); virtual;
  110. procedure WriteProperty(PropDecl: TPasProperty);
  111. procedure WriteExample(ADocNode: TDocNode);
  112. procedure WriteSeeAlso(ADocNode: TDocNode);
  113. Procedure WriteTopicNode(Node : TDocNode; Level : Integer);
  114. end;
  115. implementation
  116. const
  117. cDupLinkedDocParam = '--duplinkeddoc';
  118. { TLinearWriter }
  119. { ---------------------------------------------------------------------
  120. Writing support
  121. ---------------------------------------------------------------------}
  122. Function TLinearWriter.PushWriteContext(S : TStream) : TStream;
  123. begin
  124. Result:=FStream;
  125. FStream:=S;
  126. end;
  127. Procedure TLinearWriter.PopWriteContext(S : TSTream);
  128. begin
  129. FStream:=S;
  130. end;
  131. procedure TLinearWriter.Write(const s: String);
  132. Var
  133. L : Integer;
  134. begin
  135. L:=Length(S);
  136. If (L>0) then
  137. FStream.Write(PChar(S)^,L);
  138. end;
  139. procedure TLinearWriter.WriteF(const s: String; const Args: array of const);
  140. begin
  141. Write(Format(S,Args));
  142. end;
  143. procedure TLinearWriter.WriteLn(const s: String);
  144. begin
  145. Write(S);
  146. Write(LineEnding);
  147. end;
  148. procedure TLinearWriter.WriteLnF(const s: String; const Args: array of const);
  149. begin
  150. Write(Format(S,Args));
  151. Write(LineEnding);
  152. end;
  153. procedure TLinearWriter.DescrWriteText(const AText: DOMString);
  154. begin
  155. Write(EscapeText(AText));
  156. end;
  157. Function TLinearWriter.GetDescrString(AContext: TPasElement; DescrNode: TDOMElement) : String;
  158. Var
  159. S : TStringStream;
  160. F : TStream;
  161. begin
  162. Result:='';
  163. if Assigned(DescrNode) then
  164. begin
  165. S:=TStringStream.Create('');
  166. Try
  167. F:=PushWriteContext(S);
  168. Try
  169. ConvertDescr(AContext, DescrNode, False);
  170. Result:=S.DataString;
  171. FInally
  172. PopWriteContext(F);
  173. end;
  174. finally
  175. S.FRee;
  176. end;
  177. end;
  178. end;
  179. { ---------------------------------------------------------------------
  180. Auxiliary routines
  181. ---------------------------------------------------------------------}
  182. procedure TLinearWriter.WriteLabel(El: TPasElement);
  183. begin
  184. WriteLabel(GetLabel(El));
  185. end;
  186. procedure TLinearWriter.WriteIndex(El: TPasElement);
  187. begin
  188. WriteIndex(EL.Name);
  189. end;
  190. procedure TLinearWriter.WriteTypeDecl(El: TPasElement);
  191. begin
  192. WriteType(El.Name);
  193. end;
  194. procedure TLinearWriter.WriteVariableDecl(El: TPasElement);
  195. begin
  196. WriteVariable(El.Name);
  197. end;
  198. procedure TLinearWriter.WriteConstDecl(El: TPasElement);
  199. begin
  200. WriteConstant(El.Name);
  201. end;
  202. procedure TLinearWriter.DescrBeginURL(const AURL: DOMString);
  203. begin
  204. FLastURL:=AURL;
  205. end;
  206. procedure TLinearWriter.DescrEndURL;
  207. begin
  208. If (FLastURL<>'') then
  209. Writeln(Format(SSeeURL,[EscapeText(FLastURL)]));
  210. FLastURL:='';
  211. end;
  212. procedure TLinearWriter.StartListing(Frames: Boolean);
  213. begin
  214. StartListing(Frames,'');
  215. end;
  216. procedure TLinearWriter.StartChapter(ChapterName: String; ChapterLabel: String);
  217. begin
  218. StartChapter(ChapterName);
  219. WriteLabel(ChapterLabel);
  220. end;
  221. procedure TLinearWriter.StartSection(SectionName: String; SectionLabel: String);
  222. begin
  223. StartSection(SectionName);
  224. WriteLabel(SectionLabel);
  225. end;
  226. procedure TLinearWriter.StartSubSection(SubSectionName: String; SubSectionLabel: String);
  227. begin
  228. StartSubSection(SubSectionName);
  229. WriteLabel(SubSectionLabel);
  230. end;
  231. procedure TLinearWriter.StartSubSubSection(SubSubSectionName: String;
  232. SubSubSectionLabel: String);
  233. begin
  234. StartSubSubSection(SubSubSectionName);
  235. WriteLabel(SubSubSectionLabel);
  236. end;
  237. { ---------------------------------------------------------------------
  238. Default implementations, may be overridden in descendents
  239. ---------------------------------------------------------------------}
  240. Function TLinearWriter.EscapeText(S : String) : String;
  241. begin
  242. Result:=S;
  243. end;
  244. Function TLinearWriter.StripText(S : String) : String;
  245. begin
  246. Result:=S;
  247. end;
  248. Procedure TLinearWriter.StartProcedure;
  249. begin
  250. Writeln(SDocProcedure+':');
  251. end;
  252. Procedure TLinearWriter.StartSynopsis;
  253. begin
  254. Writeln('');
  255. Writeln(SDocSynopsis+':');
  256. end;
  257. Procedure TLinearWriter.StartDeclaration;
  258. begin
  259. Writeln('');
  260. Writeln(SDocDeclaration+':');
  261. end;
  262. Procedure TLinearWriter.StartVisibility;
  263. begin
  264. Writeln('');
  265. Writeln(SDocVisibility+':');
  266. end;
  267. Procedure TLinearWriter.StartDescription;
  268. begin
  269. Writeln('');
  270. Writeln(SDocDescription+':');
  271. end;
  272. Procedure TLinearWriter.StartAccess;
  273. begin
  274. Writeln('');
  275. Writeln(SDocAccess+':');
  276. end;
  277. Procedure TLinearWriter.StartErrors;
  278. begin
  279. Writeln('');
  280. Writeln(SDocErrors+':');
  281. end;
  282. Procedure TLinearWriter.StartVersion;
  283. begin
  284. Writeln('');
  285. Writeln(SDocVersion+':');
  286. end;
  287. Procedure TLinearWriter.StartSeealso;
  288. begin
  289. Writeln('');
  290. Writeln(SDocSeeAlso+':');
  291. end;
  292. Procedure TLinearWriter.StartProperty;
  293. begin
  294. Writeln('');
  295. Writeln(SDocProperty+':');
  296. end;
  297. Procedure TLinearWriter.EndProcedure;
  298. begin
  299. Writeln('');
  300. end;
  301. Procedure TLinearWriter.EndProperty;
  302. begin
  303. Writeln('');
  304. end;
  305. procedure TLinearWriter.EndSeealso;
  306. begin
  307. Writeln('');
  308. end;
  309. procedure TLinearWriter.WriteType(const s: string);
  310. begin
  311. // do nothing
  312. end;
  313. procedure TLinearWriter.WriteVariable(const s: string);
  314. begin
  315. // do nothing
  316. end;
  317. procedure TLinearWriter.WriteConstant(const s: string);
  318. begin
  319. // do nothing
  320. end;
  321. procedure TLinearWriter.WriteClassDecl(ClassDecl: TPasClassType);
  322. var
  323. DocNode: TDocNode;
  324. Member: TPasElement;
  325. i: Integer;
  326. begin
  327. StartSection(ClassDecl.Name);
  328. WriteLabel(ClassDecl);
  329. WriteIndex(ClassDecl);
  330. DocNode := Engine.FindDocNode(ClassDecl);
  331. if Assigned(DocNode) and ((not IsDescrNodeEmpty(DocNode.Descr)) or
  332. (not IsDescrNodeEmpty(DocNode.ShortDescr))) then
  333. begin
  334. StartSubSection(SDocDescription);
  335. WriteDescr(ClassDecl,DocNode);
  336. If Assigned(DocNode.Version) then
  337. begin
  338. StartSubSection(SDocVersion);
  339. WriteDescr(ClassDecl,DocNode.Version);
  340. end;
  341. if Assigned(DocNode.SeeAlso) then
  342. begin
  343. WriteSeeAlso(DocNode);
  344. end;
  345. ConvertNotes(ClassDecl,DocNode.Notes);
  346. end;
  347. // graemeg: this must move above SeeAlso, Version and Notes written above.
  348. // Write Class Hierarchy (Inheritance) Overview;
  349. WriteClassInheritanceOverView(ClassDecl);
  350. // Write Interfaces Overview;
  351. WriteClassInterfacesOverView(ClassDecl);
  352. // Write method overview
  353. WriteClassMethodOverView(ClassDecl);
  354. // Write Property Overview;
  355. WriteClassPropertyOverView(ClassDecl);
  356. // Write method & property descriptions
  357. // Determine visibilities
  358. for i := 0 to ClassDecl.Members.Count - 1 do
  359. begin
  360. Member := TPasElement(ClassDecl.Members[i]);
  361. if Member.InheritsFrom(TPasProcedureBase) and Engine.ShowElement(Member) then
  362. WriteProcedure(TPasProcedureBase(Member));
  363. end;
  364. // properties.
  365. for i := 0 to ClassDecl.Members.Count - 1 do
  366. begin
  367. Member := TPasElement(ClassDecl.Members[i]);
  368. if Member.InheritsFrom(TPasProperty) and Engine.ShowElement(Member) then
  369. WriteProperty(TPasProperty(Member));
  370. end;
  371. end;
  372. procedure TLinearWriter.WriteClassPropertyOverview(ClassDecl : TPasClassType);
  373. var
  374. Member: TPasElement;
  375. i: Integer;
  376. L,N,S,A: String;
  377. DocNode: TDocNode;
  378. List : TStringList;
  379. lNode: TDocNode;
  380. begin
  381. // Write property overview
  382. List:=TStringList.Create;
  383. Try
  384. List.Sorted:=True;
  385. for i := 0 to ClassDecl.Members.Count - 1 do
  386. begin
  387. Member := TPasElement(ClassDecl.Members[i]);
  388. With Member do
  389. if InheritsFrom(TPasProperty) and SHowMember(Member) then
  390. List.AddObject(Member.Name,Member)
  391. end;
  392. If (List.Count>0) then
  393. begin
  394. StartSubSection(SDocPropertyOverview);
  395. WriteLabel(GetLabel(ClassDecl) + ':Properties');
  396. StartOverView(True);
  397. For I:=0 to List.Count-1 do
  398. begin
  399. Member:=TPasElement(List.objects[i]);
  400. L:=StripText(GetLabel(Member));
  401. N:=EscapeText(Member.Name);
  402. DocNode := Engine.FindDocNode(Member);
  403. if Assigned(DocNode) then
  404. begin
  405. if FDupLinkedDoc and (DocNode.Link <> '') then
  406. begin
  407. lNode := Engine.FindLinkedNode(DocNode);
  408. if not Assigned(lNode) then
  409. lNode := DocNode;
  410. end
  411. else
  412. lNode := DocNode;
  413. S := GetDescrString(Member, lNode.ShortDescr);
  414. end
  415. else
  416. S := '';
  417. A:='';
  418. if Length(TPasProperty(Member).ReadAccessorName) > 0 then
  419. a := a + 'r';
  420. if Length(TPasProperty(Member).WriteAccessorName) > 0 then
  421. a := a + 'w';
  422. if Length(TPasProperty(Member).StoredAccessorName) > 0 then
  423. a := a + 's';
  424. WriteOverviewMember(L,N,A,S);
  425. S := '';
  426. end;
  427. EndOverview;
  428. end;
  429. Finally
  430. List.Free;
  431. end;
  432. end;
  433. procedure TLinearWriter.WriteClassInterfacesOverview(ClassDecl: TPasClassType);
  434. var
  435. lInterface: TPasElement;
  436. i: Integer;
  437. L,N,S,A: String;
  438. DocNode: TDocNode;
  439. List : TStringList;
  440. lNode: TDocNode;
  441. begin
  442. // Write Interfaces overview
  443. List:=TStringList.Create;
  444. try
  445. List.Sorted:=True;
  446. for i := 0 to ClassDecl.Interfaces.Count-1 do
  447. begin
  448. lInterface := TPasElement(ClassDecl.Interfaces[i]);
  449. List.AddObject(lInterface.Name,lInterface);
  450. end;
  451. if (List.Count>0) then
  452. begin
  453. StartSubSection(SDocInterfacesOverview);
  454. WriteLabel(GetLabel(ClassDecl) + ':Interfaces');
  455. StartOverView(False);
  456. for i := 0 to List.Count-1 do
  457. begin
  458. lInterface := TPasElement(List.Objects[i]);
  459. L := StripText(GetLabel(lInterface));
  460. N := EscapeText(lInterface.Name);
  461. DocNode := Engine.FindDocNode(lInterface);
  462. if Assigned(DocNode) then
  463. begin
  464. if FDupLinkedDoc and (DocNode.Link <> '') then
  465. begin
  466. lNode := Engine.FindLinkedNode(DocNode);
  467. if not Assigned(lNode) then
  468. lNode := DocNode;
  469. end
  470. else
  471. lNode := DocNode;
  472. S := GetDescrString(lInterface, lNode.ShortDescr);
  473. end
  474. else
  475. S := '';
  476. WriteOverviewMember(L,N,S);
  477. S := '';
  478. end;
  479. EndOverview;
  480. end;
  481. finally
  482. List.Free;
  483. end;
  484. end;
  485. procedure TLinearWriter.WriteClassInheritanceOverview(ClassDecl: TPasClassType);
  486. begin
  487. { Do nothing by default. This will be implemented by descendant writers. See
  488. the IPF Writer for an example. }
  489. end;
  490. function TLinearWriter.ConstValue(ConstDecl: TPasConst): String;
  491. begin
  492. if Assigned(ConstDecl) then
  493. Result := ConstDecl.ClassName
  494. else
  495. Result := '<nil>';
  496. end;
  497. procedure TLinearWriter.WriteDoc;
  498. var
  499. i : Integer;
  500. L : TstringList;
  501. begin
  502. PackageName := LowerCase(Copy(Package.Name, 2, 255));
  503. If (Engine.OutPut='') then
  504. Engine.Output:=PackageName+FileNameExtension
  505. else if (ExtractFileExt(Engine.output)='') and (FileNameExtension<>'') then
  506. Engine.Output:=ChangeFileExt(Engine.output,FileNameExtension);
  507. FStream:=TFileStream.Create(Engine.Output,fmCreate);
  508. try
  509. WriteBeginDocument;
  510. ProcessPackage;
  511. L:=TStringList.Create;
  512. Try
  513. L.Sorted:=True;
  514. // Sort modules.
  515. For I:=0 to Package.Modules.Count-1 do
  516. L.AddObject(TPasModule(Package.Modules[i]).Name,TPasModule(Package.Modules[i]));
  517. // Now create table.
  518. for i:=0 to L.Count - 1 do
  519. begin
  520. Module := TPasModule(L.Objects[i]);
  521. ModuleName := LowerCase(Module.Name);
  522. WriteCommentLine;
  523. StartChapter(Format(SDocUnitTitle, [Module.Name]));
  524. WriteLabel(Module);
  525. // extra Topics now get processed in ProcessSection()
  526. ProcessSection(Module.InterfaceSection);
  527. end;
  528. Finally
  529. L.Free;
  530. end;
  531. WriteEndDocument;
  532. finally
  533. FSTream.Free;
  534. end;
  535. end;
  536. procedure TLinearWriter.ProcessSection(ASection: TPasSection);
  537. var
  538. DocNode: TDocNode;
  539. begin
  540. With ASection do
  541. begin
  542. SortElementList(UsesList);
  543. SortElementList(Declarations);
  544. SortElementList(ResStrings);
  545. SortElementList(Types);
  546. SortElementList(Consts);
  547. SortElementList(Classes);
  548. SortElementList(Functions);
  549. SortElementList(Variables);
  550. end;
  551. WriteUnitOverView(ASection);
  552. // Now process unit (extra) Topics
  553. DocNode:=Engine.FindDocNode(Module);
  554. If Assigned(DocNode) then
  555. ProcessTopics(DocNode,1);
  556. WriteVarsConstsTypes(ASection);
  557. WriteFunctionsAndProcedures(ASection);
  558. WriteClasses(ASection);
  559. end;
  560. procedure TLinearWriter.WriteVarsConstsTypes(ASection: TPasSection);
  561. begin
  562. With Asection do
  563. if (Consts.Count>0) or (Types.Count>0) or
  564. (Variables.Count>0) or (ResStrings.Count>0) then
  565. begin
  566. StartSection(SDocConstsTypesVars, ModuleName+'ConstsTypesVars');
  567. WriteResourceStrings(ASection);
  568. WriteConsts(ASection);
  569. WriteTypes(ASection);
  570. WriteVars(ASection);
  571. end;
  572. end;
  573. procedure TLinearWriter.WriteResourceStrings(ASection: TPasSection);
  574. var
  575. ResStrDecl: TPasResString;
  576. i: Integer;
  577. DocNode : TDocNode;
  578. begin
  579. if ASection.ResStrings.Count > 0 then
  580. begin
  581. StartSubSection(SDocResStrings,ModuleName+'ResStrings');
  582. for i := 0 to ASection.ResStrings.Count - 1 do
  583. begin
  584. ResStrDecl := TPasResString(ASection.ResStrings[i]);
  585. StartListing(false, '');
  586. DescrWriteText(ResStrDecl.GetDeclaration(True)); // instead of WriteLn() so we can do further processing like manual line wrapping in descendants
  587. EndListing;
  588. WriteLabel(ResStrDecl);
  589. WriteIndex(ResStrDecl);
  590. DocNode:=WriteDescr(ResStrDecl);
  591. If Assigned(DocNode) and Assigned(DocNode.Version) then
  592. begin
  593. Writeln(Format('%s : ',[SDocVersion]));
  594. WriteDescr(ResStrDecl, DocNode.Version);
  595. end;
  596. end;
  597. end;
  598. end;
  599. procedure TLinearWriter.WriteUnitOverview(ASection: TPasSection);
  600. var
  601. i: Integer;
  602. UnitRef: TPasType;
  603. DocNode: TDocNode;
  604. begin
  605. if ASection.UsesList.Count > 0 then
  606. begin
  607. StartSection(SDocUsedUnits);
  608. StartUnitOverview(Module.Name,ModuleName);
  609. for i := 0 to ASection.UsesList.Count - 1 do
  610. begin
  611. UnitRef := TPasType(ASection.UsesList[i]);
  612. WriteUnitEntry(UnitRef);
  613. end;
  614. EndUnitOverview;
  615. end;
  616. DocNode := Engine.FindDocNode(ASection.Parent);
  617. if Assigned(DocNode) and not IsDescrNodeEmpty(DocNode.Descr) then
  618. begin
  619. StartSection(SDocOverview);
  620. WriteDescr(ASection.Parent, DocNode.Descr);
  621. ConvertNotes(ASection.Parent,DocNode.Notes);
  622. end;
  623. end;
  624. Procedure TLinearWriter.ProcessPackage;
  625. var
  626. DocNode: TDocNode;
  627. begin
  628. DocNode:=Engine.FindDocNode(Package);
  629. if not Assigned(DocNode) then
  630. exit;
  631. if Assigned(DocNode) and not IsDescrNodeEmpty(DocNode.Descr) then
  632. begin
  633. StartSection(SDocOverview);
  634. WriteDescr(Package, DocNode.Descr);
  635. end;
  636. WriteSeeAlso(DocNode);
  637. ConvertNotes(Nil,DocNode.Notes);
  638. ProcessTopics(DocNode,1);
  639. end;
  640. Procedure TLinearWriter.ProcessTopics(DocNode : TDocNode; Alevel : Integer);
  641. Var
  642. Node : TDocNode;
  643. begin
  644. If Not Assigned(DocNode) then
  645. Exit;
  646. Node:=DocNode.FirstChild;
  647. While Assigned(Node) do
  648. begin
  649. If Node.TopicNode then
  650. WriteTopicNode(Node,ALevel);
  651. Node:=Node.NextSibling;
  652. end;
  653. end;
  654. Procedure TLinearWriter.WriteTopicNode(Node : TDocNode; Level : Integer);
  655. Var
  656. Element : TTopicElement;
  657. SubNode : TDocNode;
  658. S : String;
  659. begin
  660. Element:=FindTopicElement(Node);
  661. If Not Assigned(Element) then
  662. Exit;
  663. S:=GetDescrString(Element,Node.ShortDescr);
  664. Case Level of
  665. 1 : StartSection(S);
  666. 2 : StartSubSection(S);
  667. 3 : StartSubSubSection(S);
  668. end;
  669. WriteLabel(Element);
  670. If Assigned(Node.Descr) then
  671. WriteDescr(Element,Node.Descr);
  672. WriteSeeAlso(Node);
  673. ConvertNotes(Element,Node.Notes);
  674. If Level<3 then
  675. begin
  676. SubNode:=Node.FirstChild;
  677. While Assigned(SubNode) do
  678. begin
  679. If SubNode.TopicNode then
  680. WriteTopicNode(SubNode,Level+1);
  681. SubNode:=SubNode.NextSibling;
  682. end;
  683. end;
  684. WriteExample(Node);
  685. end;
  686. procedure TLinearWriter.WriteConsts(ASection: TPasSection);
  687. var
  688. i: Integer;
  689. ConstDecl: TPasConst;
  690. begin
  691. if ASection.Consts.Count > 0 then
  692. begin
  693. StartSubSection(SDocConstants,EscapeText(ModuleName));
  694. for i := 0 to ASection.Consts.Count - 1 do
  695. begin
  696. DescrBeginParaGraph;
  697. ConstDecl := TPasConst(ASection.Consts[i]);
  698. WriteConstDecl(ConstDecl);
  699. StartListing(False,'');
  700. WriteLn(EscapeText(ConstDecl.GetDeclaration(True)));
  701. EndListing;
  702. WriteLabel(ConstDecl);
  703. WriteIndex(ConstDecl);
  704. WriteDescr(ConstDecl);
  705. DescrEndParaGraph;
  706. end;
  707. end;
  708. end;
  709. procedure TLinearWriter.WriteEnumElements(TypeDecl : TPasEnumType);
  710. Var
  711. EV : TPasEnumValue;
  712. I : Integer;
  713. DocNode : TDocNode;
  714. begin
  715. With TypeDecl do
  716. begin
  717. SortElementList(Values);
  718. DescrBeginTable(2,True);
  719. DescrBeginTableCaption;
  720. Writeln(EscapeText(Format(SDocValuesForEnum,[TypeDecl.Name])));
  721. DescrEndTableCaption;
  722. DescrBeginTableHeadRow;
  723. DescrBeginTableCell;
  724. Writeln(EscapeText(SDocValue));
  725. DescrEndTableCell;
  726. DescrBeginTableCell;
  727. Writeln(EscapeText(SDocExplanation));
  728. DescrEndTableCell;
  729. DescrEndTableHeadRow;
  730. For I:=0 to Values.Count-1 do
  731. begin
  732. EV:=TPasEnumValue(Values[i]);
  733. DescrBeginTableRow;
  734. DescrBeginTableCell;
  735. Writeln(EscapeText(EV.Name));
  736. DescrEndTableCell;
  737. DescrBeginTableCell;
  738. DocNode := Engine.FindDocNode(EV);
  739. if Assigned(DocNode) and (not IsDescrNodeEmpty(DocNode.ShortDescr)) then
  740. WriteDescr(EV,DocNode.ShortDescr);
  741. DescrEndTableCell;
  742. DescrEndTableRow;
  743. end;
  744. DescrEndTable;
  745. end;
  746. end;
  747. procedure TLinearWriter.WriteTypes(ASection: TPasSection);
  748. var
  749. i: Integer;
  750. TypeDecl: TPasType;
  751. DocNode : TDocNode;
  752. begin
  753. if ASection.Types.Count > 0 then
  754. begin
  755. StartSubSection(SDocTypes,ModuleName+'Types');
  756. for i := 0 to ASection.Types.Count - 1 do
  757. begin
  758. DescrBeginParagraph;
  759. TypeDecl := TPasType(ASection.Types[i]);
  760. WriteTypeDecl(TypeDecl);
  761. StartListing(False,'');
  762. DocNode := Engine.FindDocNode(TypeDecl);
  763. If Assigned(DocNode) and
  764. Assigned(DocNode.Node) and
  765. (Docnode.Node['opaque']='1') then
  766. Writeln(TypeDecl.Name+' = '+SDocOpaque)
  767. else
  768. begin
  769. Writeln(EscapeText(TypeDecl.GetDeclaration(True)));
  770. end;
  771. EndListing;
  772. WriteLabel(TypeDecl);
  773. WriteIndex(TypeDecl);
  774. If TypeDecl is TPasEnumType then
  775. WriteENumElements(TypeDecl as TPasEnumType)
  776. else If (TypeDecl is TPasSetType)
  777. and (TPasSetType(TypeDecl).EnumType is TPasEnumType)
  778. and (TPasSetType(TypeDecl).EnumType.Name='') then
  779. WriteENumElements(TPasSetType(TypeDecl).EnumType as TPasEnumType);
  780. WriteDescr(TypeDecl,DocNode);
  781. If Assigned(DocNode) and Assigned(DocNode.Version) then
  782. begin
  783. Writeln(Format('%s : ',[SDocVersion]));
  784. WriteDescr(TypeDecl, DocNode.Version);
  785. end;
  786. if Assigned(DocNode) and assigned(DocNode.Notes) then
  787. ConvertNotes(TypeDecl,DocNode.Notes);
  788. DescrEndParagraph;
  789. end;
  790. end;
  791. end;
  792. procedure TLinearWriter.WriteVars(ASection: TPasSection);
  793. var
  794. VarDecl: TPasVariable;
  795. i: Integer;
  796. DocNode : TDocNode;
  797. begin
  798. if ASection.Variables.Count > 0 then
  799. begin
  800. StartSubsection(SDocVariables,ModuleName+'Variables');
  801. for i := 0 to ASection.Variables.Count - 1 do
  802. begin
  803. DescrBeginParaGraph;
  804. VarDecl := TPasVariable(ASection.Variables[i]);
  805. WriteVariableDecl(VarDecl);
  806. StartListing(False,'');
  807. WriteLn(EscapeText(VarDecl.GetDeclaration(True)));
  808. EndListing;
  809. WriteLabel(VarDecl);
  810. WriteIndex(VarDecl);
  811. DocNode:=WriteDescr(VarDecl);
  812. If Assigned(DocNode) and Assigned(DocNode.Version) then
  813. begin
  814. Writeln(Format('%s : ',[SDocVersion]));
  815. WriteDescr(VarDecl, DocNode.Version);
  816. ConvertNotes(VarDecl,DocNode.Notes);
  817. end;
  818. DescrEndParaGraph;
  819. end;
  820. end;
  821. end;
  822. procedure TLinearWriter.WriteProcedure(ProcDecl : TPasProcedureBase);
  823. var
  824. DocNode: TDocNode;
  825. OP : TPasOverloadedProc;
  826. i : integer;
  827. begin
  828. With ProcDecl do
  829. begin
  830. if Not (Assigned(Parent) and Parent.InheritsFrom(TPasClassType)) then
  831. begin
  832. StartSubSection(Name);
  833. WriteLabel(ProcDecl);
  834. WriteIndex(ProcDecl);
  835. end
  836. else
  837. begin // Parent assigned and hence method.
  838. StartSubSection(Parent.Name+'.'+Name);
  839. WriteLabel(ProcDecl);
  840. WriteIndex(Parent.Name+'.'+Name);
  841. end;
  842. StartProcedure;
  843. DocNode := Engine.FindDocNode(ProcDecl);
  844. if Assigned(DocNode) and Assigned(DocNode.ShortDescr) then
  845. begin
  846. StartSynopsis;
  847. WriteDescr(ProcDecl, DocNode.ShortDescr);
  848. end;
  849. StartDeclaration;
  850. StartListing(False);
  851. if ClassType = TPasOverloadedProc then
  852. begin
  853. OP:=TPasOverloadedProc(ProcDecl);
  854. for i := 0 to OP.Overloads.Count - 1 do
  855. begin
  856. WriteLn(TPasProcedure(OP.Overloads[i]).GetDeclaration(True));
  857. end;
  858. end
  859. else
  860. WriteLn(GetDeclaration(True));
  861. EndListing;
  862. If Assigned(Parent) then
  863. begin
  864. StartVisibility;
  865. Writeln(VisibilityNames[Visibility])
  866. end;
  867. if Assigned(DocNode) then
  868. begin
  869. If Assigned(DocNode.Descr) then
  870. begin
  871. StartDescription;
  872. WriteDescr(ProcDecl);
  873. end;
  874. if Assigned(DocNode.ErrorsDoc) and (DocNode.ErrorsDoc.HasChildNodes) then
  875. begin
  876. StartErrors;
  877. WriteDescr(ProcDecl, DocNode.ErrorsDoc);
  878. end;
  879. if Assigned(DocNode.Version) then
  880. begin
  881. StartVersion;
  882. WriteDescr(ProcDecl, DocNode.Version);
  883. end;
  884. WriteSeeAlso(DocNode);
  885. EndProcedure;
  886. WriteExample(DocNode);
  887. ConvertNotes(ProcDecl,DocNode.Notes);
  888. end
  889. else
  890. EndProcedure;
  891. end;
  892. end;
  893. procedure TLinearWriter.WriteFunctionsAndProcedures(ASection: TPasSection);
  894. var
  895. i: Integer;
  896. begin
  897. if ASection.Functions.Count > 0 then
  898. begin
  899. StartSection(SDocProceduresAndFunctions,ModuleName+'Functions');
  900. for i := 0 to ASection.Functions.Count - 1 do
  901. WriteProcedure(TPasProcedureBase(ASection.Functions[i]));
  902. end;
  903. end;
  904. procedure TLinearWriter.WriteExample(ADocNode: TDocNode);
  905. var
  906. Example: TDOMElement;
  907. S : string;
  908. begin
  909. S:='';
  910. if Assigned(ADocNode) then
  911. begin
  912. Example := ADocNode.FirstExample;
  913. while Assigned(Example) do
  914. begin
  915. if IsExampleNode(Example) then
  916. begin
  917. if (S<>'') then // not first example, start new paragraph
  918. DescrBeginParagraph;
  919. s:=Engine.GetExampleFileName(Example);
  920. if (S<>'') then
  921. WriteExampleFile(S);
  922. if Assigned(Example.NextSibling) then
  923. DescrEndParaGraph;
  924. end;
  925. Example := TDomElement(Example.NextSibling);
  926. end;
  927. end;
  928. end;
  929. procedure TLinearWriter.WriteProperty(PropDecl : TPasProperty);
  930. var
  931. DocNode: TDocNode;
  932. S: String;
  933. lNode: TDocNode;
  934. begin
  935. With PropDecl do
  936. begin
  937. StartSubSection(Parent.Name+'.'+Name);
  938. WriteLabel(PropDecl);
  939. WriteIndex(Parent.Name+'.'+Name);
  940. StartProperty;
  941. DocNode := Engine.FindDocNode(PropDecl);
  942. if Assigned(DocNode) then
  943. begin
  944. if FDupLinkedDoc and (DocNode.Link <> '') then
  945. begin
  946. lNode := Engine.FindLinkedNode(DocNode);
  947. if not Assigned(lNode) then
  948. lNode := DocNode;
  949. end
  950. else
  951. lNode := DocNode;
  952. if Assigned(lNode.ShortDescr) then
  953. begin
  954. StartSynopsis;
  955. WriteDescr(PropDecl, lNode.ShortDescr);
  956. end;
  957. end;
  958. StartDeclaration;
  959. StartListing(False);
  960. WriteLn('Property '+GetDeclaration(True));
  961. EndListing;
  962. If Assigned(Parent) then
  963. begin
  964. StartVisibility;
  965. Writeln(VisibilityNames[Visibility])
  966. end;
  967. StartAccess;
  968. Setlength(S,0);
  969. If Length(ReadAccessorName) > 0 then
  970. S:='Read';
  971. if Length(WriteAccessorName) > 0 then
  972. begin
  973. If S<>'' then
  974. S:=S+',';
  975. S:=S+'Write';
  976. end;
  977. Writeln(S);
  978. if Assigned(DocNode) then
  979. begin
  980. if Assigned(lNode.Descr) then // lNode will be assigned if DocNode exists
  981. begin
  982. StartDescription;
  983. WriteDescr(PropDecl, lNode);
  984. end;
  985. if Assigned(lNode.ErrorsDoc) and (lNode.ErrorsDoc.HasChildNodes) then
  986. begin
  987. StartErrors;
  988. WriteDescr(PropDecl, DocNode.ErrorsDoc);
  989. end;
  990. if Assigned(lNode.Version) then
  991. begin
  992. StartVersion;
  993. WriteDescr(PropDecl, lNode.Version);
  994. end;
  995. WriteSeeAlso(lNode);
  996. ConvertNotes(PropDecl,lNode.Notes);
  997. EndProperty;
  998. WriteExample(lNode);
  999. end
  1000. else
  1001. EndProperty;
  1002. end;
  1003. end;
  1004. procedure TLinearWriter.WriteSeeAlso(ADocNode: TDocNode);
  1005. var
  1006. Node: TDOMNode;
  1007. s: String;
  1008. First : Boolean;
  1009. begin
  1010. if Not (Assigned(ADocNode) and Assigned(ADocNode.SeeAlso)) then
  1011. Exit;
  1012. Node := ADocNode.SeeAlso.FirstChild;
  1013. First:=True;
  1014. while Assigned(Node) do
  1015. begin
  1016. if IsLinkNode(Node) then
  1017. begin
  1018. If First then
  1019. begin
  1020. StartSeealso;
  1021. First:=False;
  1022. end
  1023. else
  1024. Writeln(',');
  1025. S:=TDomElement(Node)['id'];
  1026. DescrBeginLink(S);
  1027. if Node.FirstChild <> nil then
  1028. s := Node.FirstChild.NodeValue;
  1029. Write(EscapeText(S));
  1030. DescrEndLink();
  1031. end;
  1032. Node:=Node.NextSibling;
  1033. end;
  1034. If Not First then
  1035. EndSeeAlso
  1036. end;
  1037. Function CompareElements(P1,P2 : Pointer) : Integer;
  1038. begin
  1039. Result:=CompareText(TPasElement(P1).Name,TPasElement(P2).Name);
  1040. end;
  1041. procedure TLinearWriter.SortElementList(List : TFPList);
  1042. begin
  1043. List.Sort(@CompareElements);
  1044. end;
  1045. Function TLinearWriter.ShowMember(M : TPasElement) : boolean;
  1046. begin
  1047. Result:=Engine.ShowElement(M);
  1048. end;
  1049. procedure TLinearWriter.WriteClasses(ASection: TPasSection);
  1050. var
  1051. i: Integer;
  1052. begin
  1053. if (ASection.Classes.Count > 0) then
  1054. for i := 0 to ASection.Classes.Count - 1 do
  1055. WriteClassDecl(TPasClassType(ASection.Classes[i]));
  1056. end;
  1057. procedure TLinearWriter.WriteClassMethodOverview(ClassDecl: TPasClassType);
  1058. var
  1059. Member : TPasElement;
  1060. i : Integer;
  1061. L,N,S : String;
  1062. DocNode : TDocNode;
  1063. List : TStringList;
  1064. begin
  1065. List:=TStringList.Create;
  1066. Try
  1067. List.Sorted:=True;
  1068. for i := 0 to ClassDecl.Members.Count - 1 do
  1069. begin
  1070. Member := TPasElement(ClassDecl.Members[i]);
  1071. With Member do
  1072. if InheritsFrom(TPasProcedureBase) and ShowMember(Member) then
  1073. List.AddObject(Member.Name,Member);
  1074. end;
  1075. If List.Count>0 then
  1076. begin
  1077. StartSubSection(SDocMethodOverview);
  1078. WriteLabel(GetLabel(ClassDecl) + ':Methods');
  1079. StartOverview(False);
  1080. For I:=0 to List.Count-1 do
  1081. begin
  1082. Member:=TPasElement(List.Objects[i]);
  1083. L:=StripText(GetLabel(Member));
  1084. N:=EscapeText(Member.Name);
  1085. DocNode := Engine.FindDocNode(Member);
  1086. If Assigned(DocNode) then
  1087. S:=GetDescrString(Member, DocNode.ShortDescr)
  1088. else
  1089. S:='';
  1090. WriteOverviewMember(L,N,S);
  1091. end;
  1092. EndOverview;
  1093. end;
  1094. Finally
  1095. List.Free;
  1096. end;
  1097. end;
  1098. constructor TLinearWriter.Create(APackage: TPasPackage; AEngine: TFPDocEngine);
  1099. procedure AddLabel(AElement: TPasElement);
  1100. begin
  1101. Engine.AddLink(AElement.PathName, GetLabel(AElement));
  1102. end;
  1103. procedure AddList(AElement: TPasElement; AList: TFPList);
  1104. var
  1105. i: Integer;
  1106. begin
  1107. for i := 0 to AList.Count - 1 do
  1108. AddLabel(TPasElement(AList[i]));
  1109. end;
  1110. procedure AddTopicPages(AElement: TPasElement);
  1111. var
  1112. PreviousTopic,
  1113. TopicElement : TTopicElement;
  1114. DocNode,
  1115. TopicNode : TDocNode;
  1116. begin
  1117. DocNode:=Engine.FindDocNode(AElement);
  1118. If not Assigned(DocNode) then
  1119. exit;
  1120. TopicNode:=DocNode.FirstChild;
  1121. PreviousTopic:=Nil;
  1122. While Assigned(TopicNode) do
  1123. begin
  1124. If TopicNode.TopicNode then
  1125. begin
  1126. TopicElement:=TTopicElement.Create(TopicNode.Name,AElement);
  1127. Topics.Add(TopicElement);
  1128. TopicElement.TopicNode:=TopicNode;
  1129. TopicElement.Previous:=PreviousTopic;
  1130. If Assigned(PreviousTopic) then
  1131. PreviousTopic.Next:=TopicElement;
  1132. PreviousTopic:=TopicElement;
  1133. if AElement is TTopicElement then
  1134. TTopicElement(AElement).SubTopics.Add(TopicElement);
  1135. Engine.AddLink(TopicElement.PathName, GetLabel(TopicElement));
  1136. if AElement is TTopicElement then
  1137. TTopicElement(AElement).SubTopics.Add(TopicElement)
  1138. else // Only one level of recursion.
  1139. AddTopicPages(TopicElement);
  1140. end;
  1141. TopicNode:=TopicNode.NextSibling;
  1142. end;
  1143. end;
  1144. procedure ScanModule(AModule: TPasModule);
  1145. var
  1146. i, j, k: Integer;
  1147. ClassEl: TPasClassType;
  1148. FPEl, AncestorMemberEl: TPasElement;
  1149. DocNode: TDocNode;
  1150. DidAutolink: Boolean;
  1151. begin
  1152. AddLabel(AModule);
  1153. AddTopicPages(AModule);
  1154. with AModule do
  1155. begin
  1156. AddList(AModule, InterfaceSection.ResStrings);
  1157. AddList(AModule, InterfaceSection.Consts);
  1158. AddList(AModule, InterfaceSection.Types);
  1159. if InterfaceSection.Classes.Count > 0 then
  1160. begin
  1161. for i := 0 to InterfaceSection.Classes.Count - 1 do
  1162. begin
  1163. ClassEl := TPasClassType(InterfaceSection.Classes[i]);
  1164. AddLabel(ClassEl);
  1165. for j := 0 to ClassEl.Members.Count - 1 do
  1166. begin
  1167. FPEl := TPasElement(ClassEl.Members[j]);
  1168. if Not Engine.ShowElement(FPEl) then
  1169. continue;
  1170. DocNode := Engine.FindDocNode(FPEl);
  1171. if not Assigned(DocNode) then
  1172. begin
  1173. DidAutolink := False;
  1174. if Assigned(ClassEl.AncestorType) and
  1175. (ClassEl.AncestorType.ClassType = TPasClassType) then
  1176. begin
  1177. for k := 0 to TPasClassType(ClassEl.AncestorType).Members.Count - 1 do
  1178. begin
  1179. AncestorMemberEl :=
  1180. TPasElement(TPasClassType(ClassEl.AncestorType).Members[k]);
  1181. if AncestorMemberEl.Name = FPEl.Name then
  1182. begin
  1183. DocNode := Engine.FindDocNode(AncestorMemberEl);
  1184. if Assigned(DocNode) then
  1185. begin
  1186. DidAutolink := True;
  1187. Engine.AddLink(FPEl.PathName,
  1188. Engine.FindAbsoluteLink(AncestorMemberEl.PathName));
  1189. break;
  1190. end;
  1191. end;
  1192. end;
  1193. end;
  1194. if not DidAutolink then
  1195. AddLabel(FPEl);
  1196. end else
  1197. AddLabel(FPEl);
  1198. end;
  1199. end;
  1200. end;
  1201. AddList(AModule, InterfaceSection.Functions);
  1202. AddList(AModule, InterfaceSection.Variables);
  1203. end;
  1204. end;
  1205. var
  1206. i: Integer;
  1207. begin
  1208. inherited ;
  1209. FDupLinkedDoc := False; // by default we don't duplicate linked element documentation
  1210. { Allocate labels for all elements for which we are going to create
  1211. documentation. This is needed for links to work correctly. }
  1212. // Allocate label for the package itself, if a name is given (i.e. <> '#')
  1213. if Length(Package.Name) > 1 then
  1214. begin
  1215. AddLabel(Package);
  1216. AddTopicPages(Package);
  1217. end;
  1218. for i := 0 to Package.Modules.Count - 1 do
  1219. ScanModule(TPasModule(Package.Modules[i]));
  1220. end;
  1221. procedure TLinearWriter.WriteBeginDocument;
  1222. begin
  1223. WriteComment('This file has been created automatically by FPDoc.');
  1224. WriteComment('Linear output (c) 2005 Michael Van Canneyt');
  1225. end;
  1226. procedure TLinearWriter.WriteEndDocument;
  1227. begin
  1228. // do nothing
  1229. end;
  1230. function TLinearWriter.InterpretOption(const Cmd: String; const Arg: String): Boolean;
  1231. begin
  1232. Result := True;
  1233. if Cmd = cDupLinkedDocParam then
  1234. begin
  1235. FDupLinkedDoc := True;
  1236. end
  1237. else
  1238. Result := False;
  1239. end;
  1240. class procedure TLinearWriter.Usage(List: TStrings);
  1241. begin
  1242. List.Add(cDupLinkedDocParam);
  1243. List.Add(SLinearUsageDupLinkedDocsP1);
  1244. List.Add('');
  1245. List.Add(SLinearUsageDupLinkedDocsP2);
  1246. end;
  1247. end.