dwlinear.pp 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403
  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 Assigned(DocNode) and not IsDescrNodeEmpty(DocNode.Descr) then
  630. begin
  631. StartSection(SDocOverview);
  632. WriteDescr(Package, DocNode.Descr);
  633. end;
  634. WriteSeeAlso(DocNode);
  635. ConvertNotes(Nil,DocNode.Notes);
  636. ProcessTopics(DocNode,1);
  637. end;
  638. Procedure TLinearWriter.ProcessTopics(DocNode : TDocNode; Alevel : Integer);
  639. Var
  640. Node : TDocNode;
  641. begin
  642. If Not Assigned(DocNode) then
  643. Exit;
  644. Node:=DocNode.FirstChild;
  645. While Assigned(Node) do
  646. begin
  647. If Node.TopicNode then
  648. WriteTopicNode(Node,ALevel);
  649. Node:=Node.NextSibling;
  650. end;
  651. end;
  652. Procedure TLinearWriter.WriteTopicNode(Node : TDocNode; Level : Integer);
  653. Var
  654. Element : TTopicElement;
  655. SubNode : TDocNode;
  656. S : String;
  657. begin
  658. Element:=FindTopicElement(Node);
  659. If Not Assigned(Element) then
  660. Exit;
  661. S:=GetDescrString(Element,Node.ShortDescr);
  662. Case Level of
  663. 1 : StartSection(S);
  664. 2 : StartSubSection(S);
  665. 3 : StartSubSubSection(S);
  666. end;
  667. WriteLabel(Element);
  668. If Assigned(Node.Descr) then
  669. WriteDescr(Element,Node.Descr);
  670. WriteSeeAlso(Node);
  671. ConvertNotes(Element,Node.Notes);
  672. If Level<3 then
  673. begin
  674. SubNode:=Node.FirstChild;
  675. While Assigned(SubNode) do
  676. begin
  677. If SubNode.TopicNode then
  678. WriteTopicNode(SubNode,Level+1);
  679. SubNode:=SubNode.NextSibling;
  680. end;
  681. end;
  682. WriteExample(Node);
  683. end;
  684. procedure TLinearWriter.WriteConsts(ASection: TPasSection);
  685. var
  686. i: Integer;
  687. ConstDecl: TPasConst;
  688. begin
  689. if ASection.Consts.Count > 0 then
  690. begin
  691. StartSubSection(SDocConstants,EscapeText(ModuleName));
  692. for i := 0 to ASection.Consts.Count - 1 do
  693. begin
  694. DescrBeginParaGraph;
  695. ConstDecl := TPasConst(ASection.Consts[i]);
  696. WriteConstDecl(ConstDecl);
  697. StartListing(False,'');
  698. WriteLn(EscapeText(ConstDecl.GetDeclaration(True)));
  699. EndListing;
  700. WriteLabel(ConstDecl);
  701. WriteIndex(ConstDecl);
  702. WriteDescr(ConstDecl);
  703. DescrEndParaGraph;
  704. end;
  705. end;
  706. end;
  707. procedure TLinearWriter.WriteEnumElements(TypeDecl : TPasEnumType);
  708. Var
  709. EV : TPasEnumValue;
  710. I : Integer;
  711. DocNode : TDocNode;
  712. begin
  713. With TypeDecl do
  714. begin
  715. SortElementList(Values);
  716. DescrBeginTable(2,True);
  717. DescrBeginTableCaption;
  718. Writeln(EscapeText(Format(SDocValuesForEnum,[TypeDecl.Name])));
  719. DescrEndTableCaption;
  720. DescrBeginTableHeadRow;
  721. DescrBeginTableCell;
  722. Writeln(EscapeText(SDocValue));
  723. DescrEndTableCell;
  724. DescrBeginTableCell;
  725. Writeln(EscapeText(SDocExplanation));
  726. DescrEndTableCell;
  727. DescrEndTableHeadRow;
  728. For I:=0 to Values.Count-1 do
  729. begin
  730. EV:=TPasEnumValue(Values[i]);
  731. DescrBeginTableRow;
  732. DescrBeginTableCell;
  733. Writeln(EscapeText(EV.Name));
  734. DescrEndTableCell;
  735. DescrBeginTableCell;
  736. DocNode := Engine.FindDocNode(EV);
  737. if Assigned(DocNode) and (not IsDescrNodeEmpty(DocNode.ShortDescr)) then
  738. WriteDescr(EV,DocNode.ShortDescr);
  739. DescrEndTableCell;
  740. DescrEndTableRow;
  741. end;
  742. DescrEndTable;
  743. end;
  744. end;
  745. procedure TLinearWriter.WriteTypes(ASection: TPasSection);
  746. var
  747. i: Integer;
  748. TypeDecl: TPasType;
  749. DocNode : TDocNode;
  750. begin
  751. if ASection.Types.Count > 0 then
  752. begin
  753. StartSubSection(SDocTypes,ModuleName+'Types');
  754. for i := 0 to ASection.Types.Count - 1 do
  755. begin
  756. DescrBeginParagraph;
  757. TypeDecl := TPasType(ASection.Types[i]);
  758. WriteTypeDecl(TypeDecl);
  759. StartListing(False,'');
  760. DocNode := Engine.FindDocNode(TypeDecl);
  761. If Assigned(DocNode) and
  762. Assigned(DocNode.Node) and
  763. (Docnode.Node['opaque']='1') then
  764. Writeln(TypeDecl.Name+' = '+SDocOpaque)
  765. else
  766. begin
  767. Writeln(EscapeText(TypeDecl.GetDeclaration(True)));
  768. end;
  769. EndListing;
  770. WriteLabel(TypeDecl);
  771. WriteIndex(TypeDecl);
  772. If TypeDecl is TPasEnumType then
  773. WriteENumElements(TypeDecl as TPasEnumType)
  774. else If (TypeDecl is TPasSetType)
  775. and (TPasSetType(TypeDecl).EnumType is TPasEnumType)
  776. and (TPasSetType(TypeDecl).EnumType.Name='') then
  777. WriteENumElements(TPasSetType(TypeDecl).EnumType as TPasEnumType);
  778. WriteDescr(TypeDecl,DocNode);
  779. If Assigned(DocNode) and Assigned(DocNode.Version) then
  780. begin
  781. Writeln(Format('%s : ',[SDocVersion]));
  782. WriteDescr(TypeDecl, DocNode.Version);
  783. end;
  784. if Assigned(DocNode) and assigned(DocNode.Notes) then
  785. ConvertNotes(TypeDecl,DocNode.Notes);
  786. DescrEndParagraph;
  787. end;
  788. end;
  789. end;
  790. procedure TLinearWriter.WriteVars(ASection: TPasSection);
  791. var
  792. VarDecl: TPasVariable;
  793. i: Integer;
  794. DocNode : TDocNode;
  795. begin
  796. if ASection.Variables.Count > 0 then
  797. begin
  798. StartSubsection(SDocVariables,ModuleName+'Variables');
  799. for i := 0 to ASection.Variables.Count - 1 do
  800. begin
  801. DescrBeginParaGraph;
  802. VarDecl := TPasVariable(ASection.Variables[i]);
  803. WriteVariableDecl(VarDecl);
  804. StartListing(False,'');
  805. WriteLn(EscapeText(VarDecl.GetDeclaration(True)));
  806. EndListing;
  807. WriteLabel(VarDecl);
  808. WriteIndex(VarDecl);
  809. DocNode:=WriteDescr(VarDecl);
  810. If Assigned(DocNode) and Assigned(DocNode.Version) then
  811. begin
  812. Writeln(Format('%s : ',[SDocVersion]));
  813. WriteDescr(VarDecl, DocNode.Version);
  814. ConvertNotes(VarDecl,DocNode.Notes);
  815. end;
  816. DescrEndParaGraph;
  817. end;
  818. end;
  819. end;
  820. procedure TLinearWriter.WriteProcedure(ProcDecl : TPasProcedureBase);
  821. var
  822. DocNode: TDocNode;
  823. OP : TPasOverloadedProc;
  824. i : integer;
  825. begin
  826. With ProcDecl do
  827. begin
  828. if Not (Assigned(Parent) and Parent.InheritsFrom(TPasClassType)) then
  829. begin
  830. StartSubSection(Name);
  831. WriteLabel(ProcDecl);
  832. WriteIndex(ProcDecl);
  833. end
  834. else
  835. begin // Parent assigned and hence method.
  836. StartSubSection(Parent.Name+'.'+Name);
  837. WriteLabel(ProcDecl);
  838. WriteIndex(Parent.Name+'.'+Name);
  839. end;
  840. StartProcedure;
  841. DocNode := Engine.FindDocNode(ProcDecl);
  842. if Assigned(DocNode) and Assigned(DocNode.ShortDescr) then
  843. begin
  844. StartSynopsis;
  845. WriteDescr(ProcDecl, DocNode.ShortDescr);
  846. end;
  847. StartDeclaration;
  848. StartListing(False);
  849. if ClassType = TPasOverloadedProc then
  850. begin
  851. OP:=TPasOverloadedProc(ProcDecl);
  852. for i := 0 to OP.Overloads.Count - 1 do
  853. begin
  854. WriteLn(TPasProcedure(OP.Overloads[i]).GetDeclaration(True));
  855. end;
  856. end
  857. else
  858. WriteLn(GetDeclaration(True));
  859. EndListing;
  860. If Assigned(Parent) then
  861. begin
  862. StartVisibility;
  863. Writeln(VisibilityNames[Visibility])
  864. end;
  865. if Assigned(DocNode) then
  866. begin
  867. If Assigned(DocNode.Descr) then
  868. begin
  869. StartDescription;
  870. WriteDescr(ProcDecl);
  871. end;
  872. if Assigned(DocNode.ErrorsDoc) and (DocNode.ErrorsDoc.HasChildNodes) then
  873. begin
  874. StartErrors;
  875. WriteDescr(ProcDecl, DocNode.ErrorsDoc);
  876. end;
  877. if Assigned(DocNode.Version) then
  878. begin
  879. StartVersion;
  880. WriteDescr(ProcDecl, DocNode.Version);
  881. end;
  882. WriteSeeAlso(DocNode);
  883. EndProcedure;
  884. WriteExample(DocNode);
  885. ConvertNotes(ProcDecl,DocNode.Notes);
  886. end
  887. else
  888. EndProcedure;
  889. end;
  890. end;
  891. procedure TLinearWriter.WriteFunctionsAndProcedures(ASection: TPasSection);
  892. var
  893. i: Integer;
  894. begin
  895. if ASection.Functions.Count > 0 then
  896. begin
  897. StartSection(SDocProceduresAndFunctions,ModuleName+'Functions');
  898. for i := 0 to ASection.Functions.Count - 1 do
  899. WriteProcedure(TPasProcedureBase(ASection.Functions[i]));
  900. end;
  901. end;
  902. procedure TLinearWriter.WriteExample(ADocNode: TDocNode);
  903. var
  904. Example: TDOMElement;
  905. S : string;
  906. begin
  907. S:='';
  908. if Assigned(ADocNode) then
  909. begin
  910. Example := ADocNode.FirstExample;
  911. while Assigned(Example) do
  912. begin
  913. if IsExampleNode(Example) then
  914. begin
  915. if (S<>'') then // not first example, start new paragraph
  916. DescrBeginParagraph;
  917. s:=Engine.GetExampleFileName(Example);
  918. if (S<>'') then
  919. WriteExampleFile(S);
  920. if Assigned(Example.NextSibling) then
  921. DescrEndParaGraph;
  922. end;
  923. Example := TDomElement(Example.NextSibling);
  924. end;
  925. end;
  926. end;
  927. procedure TLinearWriter.WriteProperty(PropDecl : TPasProperty);
  928. var
  929. DocNode: TDocNode;
  930. S: String;
  931. lNode: TDocNode;
  932. begin
  933. With PropDecl do
  934. begin
  935. StartSubSection(Parent.Name+'.'+Name);
  936. WriteLabel(PropDecl);
  937. WriteIndex(Parent.Name+'.'+Name);
  938. StartProperty;
  939. DocNode := Engine.FindDocNode(PropDecl);
  940. if Assigned(DocNode) then
  941. begin
  942. if FDupLinkedDoc and (DocNode.Link <> '') then
  943. begin
  944. lNode := Engine.FindLinkedNode(DocNode);
  945. if not Assigned(lNode) then
  946. lNode := DocNode;
  947. end
  948. else
  949. lNode := DocNode;
  950. if Assigned(lNode.ShortDescr) then
  951. begin
  952. StartSynopsis;
  953. WriteDescr(PropDecl, lNode.ShortDescr);
  954. end;
  955. end;
  956. StartDeclaration;
  957. StartListing(False);
  958. WriteLn('Property '+GetDeclaration(True));
  959. EndListing;
  960. If Assigned(Parent) then
  961. begin
  962. StartVisibility;
  963. Writeln(VisibilityNames[Visibility])
  964. end;
  965. StartAccess;
  966. Setlength(S,0);
  967. If Length(ReadAccessorName) > 0 then
  968. S:='Read';
  969. if Length(WriteAccessorName) > 0 then
  970. begin
  971. If S<>'' then
  972. S:=S+',';
  973. S:=S+'Write';
  974. end;
  975. Writeln(S);
  976. if Assigned(DocNode) then
  977. begin
  978. if Assigned(lNode.Descr) then // lNode will be assigned if DocNode exists
  979. begin
  980. StartDescription;
  981. WriteDescr(PropDecl, lNode);
  982. end;
  983. if Assigned(lNode.ErrorsDoc) and (lNode.ErrorsDoc.HasChildNodes) then
  984. begin
  985. StartErrors;
  986. WriteDescr(PropDecl, DocNode.ErrorsDoc);
  987. end;
  988. if Assigned(lNode.Version) then
  989. begin
  990. StartVersion;
  991. WriteDescr(PropDecl, lNode.Version);
  992. end;
  993. WriteSeeAlso(lNode);
  994. ConvertNotes(PropDecl,lNode.Notes);
  995. EndProperty;
  996. WriteExample(lNode);
  997. end
  998. else
  999. EndProperty;
  1000. end;
  1001. end;
  1002. procedure TLinearWriter.WriteSeeAlso(ADocNode: TDocNode);
  1003. var
  1004. Node: TDOMNode;
  1005. s: String;
  1006. First : Boolean;
  1007. begin
  1008. if Not (Assigned(ADocNode) and Assigned(ADocNode.SeeAlso)) then
  1009. Exit;
  1010. Node := ADocNode.SeeAlso.FirstChild;
  1011. First:=True;
  1012. while Assigned(Node) do
  1013. begin
  1014. if IsLinkNode(Node) then
  1015. begin
  1016. If First then
  1017. begin
  1018. StartSeealso;
  1019. First:=False;
  1020. end
  1021. else
  1022. Writeln(',');
  1023. S:=TDomElement(Node)['id'];
  1024. DescrBeginLink(S);
  1025. if Node.FirstChild <> nil then
  1026. s := Node.FirstChild.NodeValue;
  1027. Write(EscapeText(S));
  1028. DescrEndLink();
  1029. end;
  1030. Node:=Node.NextSibling;
  1031. end;
  1032. If Not First then
  1033. EndSeeAlso
  1034. end;
  1035. Function CompareElements(P1,P2 : Pointer) : Integer;
  1036. begin
  1037. Result:=CompareText(TPasElement(P1).Name,TPasElement(P2).Name);
  1038. end;
  1039. procedure TLinearWriter.SortElementList(List : TFPList);
  1040. begin
  1041. List.Sort(@CompareElements);
  1042. end;
  1043. Function TLinearWriter.ShowMember(M : TPasElement) : boolean;
  1044. begin
  1045. Result:=Engine.ShowElement(M);
  1046. end;
  1047. procedure TLinearWriter.WriteClasses(ASection: TPasSection);
  1048. var
  1049. i: Integer;
  1050. begin
  1051. if (ASection.Classes.Count > 0) then
  1052. for i := 0 to ASection.Classes.Count - 1 do
  1053. WriteClassDecl(TPasClassType(ASection.Classes[i]));
  1054. end;
  1055. procedure TLinearWriter.WriteClassMethodOverview(ClassDecl: TPasClassType);
  1056. var
  1057. Member : TPasElement;
  1058. i : Integer;
  1059. L,N,S : String;
  1060. DocNode : TDocNode;
  1061. List : TStringList;
  1062. begin
  1063. List:=TStringList.Create;
  1064. Try
  1065. List.Sorted:=True;
  1066. for i := 0 to ClassDecl.Members.Count - 1 do
  1067. begin
  1068. Member := TPasElement(ClassDecl.Members[i]);
  1069. With Member do
  1070. if InheritsFrom(TPasProcedureBase) and ShowMember(Member) then
  1071. List.AddObject(Member.Name,Member);
  1072. end;
  1073. If List.Count>0 then
  1074. begin
  1075. StartSubSection(SDocMethodOverview);
  1076. WriteLabel(GetLabel(ClassDecl) + ':Methods');
  1077. StartOverview(False);
  1078. For I:=0 to List.Count-1 do
  1079. begin
  1080. Member:=TPasElement(List.Objects[i]);
  1081. L:=StripText(GetLabel(Member));
  1082. N:=EscapeText(Member.Name);
  1083. DocNode := Engine.FindDocNode(Member);
  1084. If Assigned(DocNode) then
  1085. S:=GetDescrString(Member, DocNode.ShortDescr)
  1086. else
  1087. S:='';
  1088. WriteOverviewMember(L,N,S);
  1089. end;
  1090. EndOverview;
  1091. end;
  1092. Finally
  1093. List.Free;
  1094. end;
  1095. end;
  1096. constructor TLinearWriter.Create(APackage: TPasPackage; AEngine: TFPDocEngine);
  1097. procedure AddLabel(AElement: TPasElement);
  1098. begin
  1099. Engine.AddLink(AElement.PathName, GetLabel(AElement));
  1100. end;
  1101. procedure AddList(AElement: TPasElement; AList: TFPList);
  1102. var
  1103. i: Integer;
  1104. begin
  1105. for i := 0 to AList.Count - 1 do
  1106. AddLabel(TPasElement(AList[i]));
  1107. end;
  1108. procedure AddTopicPages(AElement: TPasElement);
  1109. var
  1110. PreviousTopic,
  1111. TopicElement : TTopicElement;
  1112. DocNode,
  1113. TopicNode : TDocNode;
  1114. begin
  1115. DocNode:=Engine.FindDocNode(AElement);
  1116. If not Assigned(DocNode) then
  1117. exit;
  1118. TopicNode:=DocNode.FirstChild;
  1119. PreviousTopic:=Nil;
  1120. While Assigned(TopicNode) do
  1121. begin
  1122. If TopicNode.TopicNode then
  1123. begin
  1124. TopicElement:=TTopicElement.Create(TopicNode.Name,AElement);
  1125. Topics.Add(TopicElement);
  1126. TopicElement.TopicNode:=TopicNode;
  1127. TopicElement.Previous:=PreviousTopic;
  1128. If Assigned(PreviousTopic) then
  1129. PreviousTopic.Next:=TopicElement;
  1130. PreviousTopic:=TopicElement;
  1131. if AElement is TTopicElement then
  1132. TTopicElement(AElement).SubTopics.Add(TopicElement);
  1133. Engine.AddLink(TopicElement.PathName, GetLabel(TopicElement));
  1134. if AElement is TTopicElement then
  1135. TTopicElement(AElement).SubTopics.Add(TopicElement)
  1136. else // Only one level of recursion.
  1137. AddTopicPages(TopicElement);
  1138. end;
  1139. TopicNode:=TopicNode.NextSibling;
  1140. end;
  1141. end;
  1142. procedure ScanModule(AModule: TPasModule);
  1143. var
  1144. i, j, k: Integer;
  1145. ClassEl: TPasClassType;
  1146. FPEl, AncestorMemberEl: TPasElement;
  1147. DocNode: TDocNode;
  1148. DidAutolink: Boolean;
  1149. begin
  1150. AddLabel(AModule);
  1151. AddTopicPages(AModule);
  1152. with AModule do
  1153. begin
  1154. AddList(AModule, InterfaceSection.ResStrings);
  1155. AddList(AModule, InterfaceSection.Consts);
  1156. AddList(AModule, InterfaceSection.Types);
  1157. if InterfaceSection.Classes.Count > 0 then
  1158. begin
  1159. for i := 0 to InterfaceSection.Classes.Count - 1 do
  1160. begin
  1161. ClassEl := TPasClassType(InterfaceSection.Classes[i]);
  1162. AddLabel(ClassEl);
  1163. for j := 0 to ClassEl.Members.Count - 1 do
  1164. begin
  1165. FPEl := TPasElement(ClassEl.Members[j]);
  1166. if Not Engine.ShowElement(FPEl) then
  1167. continue;
  1168. DocNode := Engine.FindDocNode(FPEl);
  1169. if not Assigned(DocNode) then
  1170. begin
  1171. DidAutolink := False;
  1172. if Assigned(ClassEl.AncestorType) and
  1173. (ClassEl.AncestorType.ClassType = TPasClassType) then
  1174. begin
  1175. for k := 0 to TPasClassType(ClassEl.AncestorType).Members.Count - 1 do
  1176. begin
  1177. AncestorMemberEl :=
  1178. TPasElement(TPasClassType(ClassEl.AncestorType).Members[k]);
  1179. if AncestorMemberEl.Name = FPEl.Name then
  1180. begin
  1181. DocNode := Engine.FindDocNode(AncestorMemberEl);
  1182. if Assigned(DocNode) then
  1183. begin
  1184. DidAutolink := True;
  1185. Engine.AddLink(FPEl.PathName,
  1186. Engine.FindAbsoluteLink(AncestorMemberEl.PathName));
  1187. break;
  1188. end;
  1189. end;
  1190. end;
  1191. end;
  1192. if not DidAutolink then
  1193. AddLabel(FPEl);
  1194. end else
  1195. AddLabel(FPEl);
  1196. end;
  1197. end;
  1198. end;
  1199. AddList(AModule, InterfaceSection.Functions);
  1200. AddList(AModule, InterfaceSection.Variables);
  1201. end;
  1202. end;
  1203. var
  1204. i: Integer;
  1205. begin
  1206. inherited ;
  1207. FDupLinkedDoc := False; // by default we don't duplicate linked element documentation
  1208. { Allocate labels for all elements for which we are going to create
  1209. documentation. This is needed for links to work correctly. }
  1210. // Allocate label for the package itself, if a name is given (i.e. <> '#')
  1211. if Length(Package.Name) > 1 then
  1212. begin
  1213. AddLabel(Package);
  1214. AddTopicPages(Package);
  1215. end;
  1216. for i := 0 to Package.Modules.Count - 1 do
  1217. ScanModule(TPasModule(Package.Modules[i]));
  1218. end;
  1219. procedure TLinearWriter.WriteBeginDocument;
  1220. begin
  1221. WriteComment('This file has been created automatically by FPDoc.');
  1222. WriteComment('Linear output (c) 2005 Michael Van Canneyt');
  1223. end;
  1224. procedure TLinearWriter.WriteEndDocument;
  1225. begin
  1226. // do nothing
  1227. end;
  1228. function TLinearWriter.InterpretOption(const Cmd: String; const Arg: String): Boolean;
  1229. begin
  1230. Result := True;
  1231. if Cmd = cDupLinkedDocParam then
  1232. begin
  1233. FDupLinkedDoc := True;
  1234. end
  1235. else
  1236. Result := False;
  1237. end;
  1238. class procedure TLinearWriter.Usage(List: TStrings);
  1239. begin
  1240. List.Add(cDupLinkedDocParam);
  1241. List.Add(SLinearUsageDupLinkedDocsP1);
  1242. List.Add('');
  1243. List.Add(SLinearUsageDupLinkedDocsP2);
  1244. end;
  1245. end.