dwlinear.pp 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394
  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. Class Function FileNameExtension : String;virtual; Abstract;
  85. Property LastURL : DomString Read FLastURL Write FLastURL;
  86. Public
  87. Constructor Create(APackage: TPasPackage; AEngine: TFPDocEngine); override;
  88. function InterpretOption(const Cmd, Arg: String): Boolean; override;
  89. class procedure Usage(List: TStrings); override;
  90. procedure WriteDoc; override;
  91. // Linear Documentation writing methods.
  92. Procedure ProcessPackage;
  93. Procedure ProcessTopics(DocNode : TDocNode; Alevel : Integer);
  94. procedure WriteResourceStrings(ASection: TPasSection);
  95. procedure WriteUnitOverview(ASection: TPasSection);
  96. procedure WriteVarsConstsTypes(ASection: TPasSection);
  97. procedure WriteConsts(ASection: TPasSection);
  98. procedure WriteTypes(ASection: TPasSection); virtual;
  99. procedure WriteEnumElements(TypeDecl : TPasEnumType);
  100. procedure WriteVars(ASection: TPasSection);
  101. procedure WriteFunctionsAndProcedures(ASection: TPasSection);
  102. procedure WriteProcedure(ProcDecl: TPasProcedureBase);
  103. procedure WriteClasses(ASection: TPasSection);
  104. procedure WriteClassDecl(ClassDecl: TPasClassType);
  105. procedure WriteClassMethodOverview(ClassDecl: TPasClassType);
  106. procedure WriteClassPropertyOverview(ClassDecl: TPasClassType);
  107. procedure WriteClassInterfacesOverView(ClassDecl: TPasClassType);
  108. procedure WriteProperty(PropDecl: TPasProperty);
  109. procedure WriteExample(ADocNode: TDocNode);
  110. procedure WriteSeeAlso(ADocNode: TDocNode);
  111. Procedure WriteTopicNode(Node : TDocNode; Level : Integer);
  112. // Overriden from fpdocwriter;
  113. procedure DescrWriteText(const AText: DOMString); override;
  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. Vis: TPasMemberVisibilities;
  325. Member: TPasElement;
  326. i: Integer;
  327. begin
  328. StartSection(ClassDecl.Name);
  329. WriteLabel(ClassDecl);
  330. WriteIndex(ClassDecl);
  331. DocNode := Engine.FindDocNode(ClassDecl);
  332. if Assigned(DocNode) and ((not IsDescrNodeEmpty(DocNode.Descr)) or
  333. (not IsDescrNodeEmpty(DocNode.ShortDescr))) then
  334. begin
  335. StartSubSection(SDocDescription);
  336. WriteDescr(ClassDecl,DocNode);
  337. If Assigned(DocNode.Version) then
  338. begin
  339. StartSubSection(SDocVersion);
  340. WriteDescr(ClassDecl,DocNode.Version);
  341. end;
  342. if Assigned(DocNode.SeeAlso) then
  343. begin
  344. WriteSeeAlso(DocNode);
  345. end;
  346. end;
  347. // Write Interfaces Overview;
  348. WriteClassInterfacesOverView(ClassDecl);
  349. // Write method overview
  350. WriteClassMethodOverView(ClassDecl);
  351. // Write Property Overview;
  352. WriteClassPropertyOverView(ClassDecl);
  353. // Write method & property descriptions
  354. // Determine visibilities
  355. Vis := AllVisibilities;
  356. if Engine.HidePrivate then
  357. Exclude(Vis,visPrivate);
  358. if Engine.HideProtected then
  359. Exclude(Vis,visProtected);
  360. for i := 0 to ClassDecl.Members.Count - 1 do
  361. begin
  362. Member := TPasElement(ClassDecl.Members[i]);
  363. if ((Member.InheritsFrom(TPasProcedureBase)) and
  364. (Member.Visibility in Vis)) then
  365. WriteProcedure(TPasProcedureBase(Member));
  366. end;
  367. // properties.
  368. for i := 0 to ClassDecl.Members.Count - 1 do
  369. begin
  370. Member := TPasElement(ClassDecl.Members[i]);
  371. if ((Member.InheritsFrom(TPasProperty)) and
  372. (Member.Visibility in Vis)) then
  373. WriteProperty(TPasProperty(Member));
  374. end;
  375. end;
  376. procedure TLinearWriter.WriteClassPropertyOverview(ClassDecl : TPasClassType);
  377. var
  378. Member: TPasElement;
  379. i: Integer;
  380. L,N,S,A: String;
  381. DocNode: TDocNode;
  382. List : TStringList;
  383. lNode: TDocNode;
  384. begin
  385. // Write property overview
  386. List:=TStringList.Create;
  387. Try
  388. List.Sorted:=True;
  389. for i := 0 to ClassDecl.Members.Count - 1 do
  390. begin
  391. Member := TPasElement(ClassDecl.Members[i]);
  392. With Member do
  393. if InheritsFrom(TPasProperty) and SHowMember(Member) then
  394. List.AddObject(Member.Name,Member)
  395. end;
  396. If (List.Count>0) then
  397. begin
  398. StartSubSection(SDocPropertyOverview);
  399. WriteLabel(GetLabel(ClassDecl) + ':Properties');
  400. StartOverView(True);
  401. For I:=0 to List.Count-1 do
  402. begin
  403. Member:=TPasElement(List.objects[i]);
  404. L:=StripText(GetLabel(Member));
  405. N:=EscapeText(Member.Name);
  406. DocNode := Engine.FindDocNode(Member);
  407. if Assigned(DocNode) then
  408. begin
  409. if FDupLinkedDoc and (DocNode.Link <> '') then
  410. begin
  411. lNode := Engine.FindLinkedNode(DocNode);
  412. if not Assigned(lNode) then
  413. lNode := DocNode;
  414. end
  415. else
  416. lNode := DocNode;
  417. S := GetDescrString(Member, lNode.ShortDescr);
  418. end
  419. else
  420. S := '';
  421. A:='';
  422. if Length(TPasProperty(Member).ReadAccessorName) > 0 then
  423. a := a + 'r';
  424. if Length(TPasProperty(Member).WriteAccessorName) > 0 then
  425. a := a + 'w';
  426. if Length(TPasProperty(Member).StoredAccessorName) > 0 then
  427. a := a + 's';
  428. WriteOverviewMember(L,N,A,S);
  429. S := '';
  430. end;
  431. EndOverview;
  432. end;
  433. Finally
  434. List.Free;
  435. end;
  436. end;
  437. procedure TLinearWriter.WriteClassInterfacesOverView(ClassDecl: TPasClassType);
  438. var
  439. lInterface: TPasElement;
  440. i: Integer;
  441. L,N,S,A: String;
  442. DocNode: TDocNode;
  443. List : TStringList;
  444. lNode: TDocNode;
  445. begin
  446. // Write Interfaces overview
  447. List:=TStringList.Create;
  448. try
  449. List.Sorted:=True;
  450. for i := 0 to ClassDecl.Interfaces.Count-1 do
  451. begin
  452. lInterface := TPasElement(ClassDecl.Interfaces[i]);
  453. List.AddObject(lInterface.Name,lInterface);
  454. end;
  455. if (List.Count>0) then
  456. begin
  457. StartSubSection(SDocInterfacesOverview);
  458. WriteLabel(GetLabel(ClassDecl) + ':Interfaces');
  459. StartOverView(False);
  460. for i := 0 to List.Count-1 do
  461. begin
  462. lInterface := TPasElement(List.Objects[i]);
  463. L := StripText(GetLabel(lInterface));
  464. N := EscapeText(lInterface.Name);
  465. DocNode := Engine.FindDocNode(lInterface);
  466. if Assigned(DocNode) then
  467. begin
  468. if FDupLinkedDoc and (DocNode.Link <> '') then
  469. begin
  470. lNode := Engine.FindLinkedNode(DocNode);
  471. if not Assigned(lNode) then
  472. lNode := DocNode;
  473. end
  474. else
  475. lNode := DocNode;
  476. S := GetDescrString(lInterface, lNode.ShortDescr);
  477. end
  478. else
  479. S := '';
  480. WriteOverviewMember(L,N,S);
  481. S := '';
  482. end;
  483. EndOverview;
  484. end;
  485. finally
  486. List.Free;
  487. end;
  488. end;
  489. function TLinearWriter.ConstValue(ConstDecl: TPasConst): String;
  490. begin
  491. if Assigned(ConstDecl) then
  492. Result := ConstDecl.ClassName
  493. else
  494. Result := '<nil>';
  495. end;
  496. procedure TLinearWriter.WriteDoc;
  497. var
  498. i : Integer;
  499. L : TstringList;
  500. begin
  501. PackageName := LowerCase(Copy(Package.Name, 2, 255));
  502. If (Engine.OutPut='') then
  503. Engine.Output:=PackageName+FileNameExtension;
  504. FStream:=TFileStream.Create(Engine.Output,fmCreate);
  505. try
  506. WriteBeginDocument;
  507. ProcessPackage;
  508. L:=TStringList.Create;
  509. Try
  510. L.Sorted:=True;
  511. // Sort modules.
  512. For I:=0 to Package.Modules.Count-1 do
  513. L.AddObject(TPasModule(Package.Modules[i]).Name,TPasModule(Package.Modules[i]));
  514. // Now create table.
  515. for i:=0 to L.Count - 1 do
  516. begin
  517. Module := TPasModule(L.Objects[i]);
  518. ModuleName := LowerCase(Module.Name);
  519. WriteCommentLine;
  520. StartChapter(Format(SDocUnitTitle, [Module.Name]));
  521. WriteLabel(Module);
  522. // extra Topics now get processed in ProcessSection()
  523. ProcessSection(Module.InterfaceSection);
  524. end;
  525. Finally
  526. L.Free;
  527. end;
  528. WriteEndDocument;
  529. finally
  530. FSTream.Free;
  531. end;
  532. end;
  533. procedure TLinearWriter.ProcessSection(ASection: TPasSection);
  534. var
  535. DocNode: TDocNode;
  536. begin
  537. With ASection do
  538. begin
  539. SortElementList(UsesList);
  540. SortElementList(Declarations);
  541. SortElementList(ResStrings);
  542. SortElementList(Types);
  543. SortElementList(Consts);
  544. SortElementList(Classes);
  545. SortElementList(Functions);
  546. SortElementList(Variables);
  547. end;
  548. WriteUnitOverView(ASection);
  549. // Now process unit (extra) Topics
  550. DocNode:=Engine.FindDocNode(Module);
  551. If Assigned(DocNode) then
  552. ProcessTopics(DocNode,1);
  553. WriteVarsConstsTypes(ASection);
  554. WriteFunctionsAndProcedures(ASection);
  555. WriteClasses(ASection);
  556. end;
  557. procedure TLinearWriter.WriteVarsConstsTypes(ASection: TPasSection);
  558. begin
  559. With Asection do
  560. if (Consts.Count>0) or (Types.Count>0) or
  561. (Variables.Count>0) or (ResStrings.Count>0) then
  562. begin
  563. StartSection(SDocConstsTypesVars, ModuleName+'ConstsTypesVars');
  564. WriteResourceStrings(ASection);
  565. WriteConsts(ASection);
  566. WriteTypes(ASection);
  567. WriteVars(ASection);
  568. end;
  569. end;
  570. procedure TLinearWriter.WriteResourceStrings(ASection: TPasSection);
  571. var
  572. ResStrDecl: TPasResString;
  573. i: Integer;
  574. DocNode : TDocNode;
  575. begin
  576. if ASection.ResStrings.Count > 0 then
  577. begin
  578. StartSubSection(SDocResStrings,ModuleName+'ResStrings');
  579. for i := 0 to ASection.ResStrings.Count - 1 do
  580. begin
  581. ResStrDecl := TPasResString(ASection.ResStrings[i]);
  582. StartListing(false, '');
  583. DescrWriteText(ResStrDecl.GetDeclaration(True)); // instead of WriteLn() so we can do further processing like manual line wrapping in descendants
  584. EndListing;
  585. WriteLabel(ResStrDecl);
  586. WriteIndex(ResStrDecl);
  587. DocNode:=WriteDescr(ResStrDecl);
  588. If Assigned(DocNode) and Assigned(DocNode.Version) then
  589. begin
  590. Writeln(Format('%s : ',[SDocVersion]));
  591. WriteDescr(ResStrDecl, DocNode.Version);
  592. end;
  593. end;
  594. end;
  595. end;
  596. procedure TLinearWriter.WriteUnitOverview(ASection: TPasSection);
  597. var
  598. i: Integer;
  599. UnitRef: TPasType;
  600. DocNode: TDocNode;
  601. begin
  602. if ASection.UsesList.Count > 0 then
  603. begin
  604. StartSection(SDocUsedUnits);
  605. StartUnitOverview(Module.Name,ModuleName);
  606. for i := 0 to ASection.UsesList.Count - 1 do
  607. begin
  608. UnitRef := TPasType(ASection.UsesList[i]);
  609. WriteUnitEntry(UnitRef);
  610. end;
  611. EndUnitOverview;
  612. end;
  613. DocNode := Engine.FindDocNode(ASection.Parent);
  614. if Assigned(DocNode) and not IsDescrNodeEmpty(DocNode.Descr) then
  615. begin
  616. StartSection(SDocOverview);
  617. WriteDescr(ASection.Parent, DocNode.Descr);
  618. end;
  619. end;
  620. Procedure TLinearWriter.ProcessPackage;
  621. var
  622. DocNode: TDocNode;
  623. begin
  624. DocNode:=Engine.FindDocNode(Package);
  625. if Assigned(DocNode) and not IsDescrNodeEmpty(DocNode.Descr) then
  626. begin
  627. StartSection(SDocOverview);
  628. WriteDescr(Package, DocNode.Descr);
  629. end;
  630. WriteSeeAlso(DocNode);
  631. ProcessTopics(DocNode,1);
  632. end;
  633. Procedure TLinearWriter.ProcessTopics(DocNode : TDocNode; Alevel : Integer);
  634. Var
  635. Node : TDocNode;
  636. begin
  637. If Not Assigned(DocNode) then
  638. Exit;
  639. Node:=DocNode.FirstChild;
  640. While Assigned(Node) do
  641. begin
  642. If Node.TopicNode then
  643. WriteTopicNode(Node,ALevel);
  644. Node:=Node.NextSibling;
  645. end;
  646. end;
  647. Procedure TLinearWriter.WriteTopicNode(Node : TDocNode; Level : Integer);
  648. Var
  649. Element : TTopicElement;
  650. SubNode : TDocNode;
  651. S : String;
  652. begin
  653. Element:=FindTopicElement(Node);
  654. If Not Assigned(Element) then
  655. Exit;
  656. S:=GetDescrString(Element,Node.ShortDescr);
  657. Case Level of
  658. 1 : StartSection(S);
  659. 2 : StartSubSection(S);
  660. 3 : StartSubSubSection(S);
  661. end;
  662. WriteLabel(Element);
  663. If Assigned(Node.Descr) then
  664. WriteDescr(Element,Node.Descr);
  665. WriteSeeAlso(Node);
  666. If Level<3 then
  667. begin
  668. SubNode:=Node.FirstChild;
  669. While Assigned(SubNode) do
  670. begin
  671. If SubNode.TopicNode then
  672. WriteTopicNode(SubNode,Level+1);
  673. SubNode:=SubNode.NextSibling;
  674. end;
  675. end;
  676. WriteExample(Node);
  677. end;
  678. procedure TLinearWriter.WriteConsts(ASection: TPasSection);
  679. var
  680. i: Integer;
  681. ConstDecl: TPasConst;
  682. begin
  683. if ASection.Consts.Count > 0 then
  684. begin
  685. StartSubSection(SDocConstants,EscapeText(ModuleName));
  686. for i := 0 to ASection.Consts.Count - 1 do
  687. begin
  688. DescrBeginParaGraph;
  689. ConstDecl := TPasConst(ASection.Consts[i]);
  690. WriteConstDecl(ConstDecl);
  691. StartListing(False,'');
  692. WriteLn(EscapeText(ConstDecl.GetDeclaration(True)));
  693. EndListing;
  694. WriteLabel(ConstDecl);
  695. WriteIndex(ConstDecl);
  696. WriteDescr(ConstDecl);
  697. DescrEndParaGraph;
  698. end;
  699. end;
  700. end;
  701. procedure TLinearWriter.WriteEnumElements(TypeDecl : TPasEnumType);
  702. Var
  703. EV : TPasEnumValue;
  704. I : Integer;
  705. DocNode : TDocNode;
  706. begin
  707. With TypeDecl do
  708. begin
  709. SortElementList(Values);
  710. DescrBeginTable(2,True);
  711. DescrBeginTableCaption;
  712. Writeln(EscapeText(Format(SDocValuesForEnum,[TypeDecl.Name])));
  713. DescrEndTableCaption;
  714. DescrBeginTableHeadRow;
  715. DescrBeginTableCell;
  716. Writeln(EscapeText(SDocValue));
  717. DescrEndTableCell;
  718. DescrBeginTableCell;
  719. Writeln(EscapeText(SDocExplanation));
  720. DescrEndTableCell;
  721. DescrEndTableHeadRow;
  722. For I:=0 to Values.Count-1 do
  723. begin
  724. EV:=TPasEnumValue(Values[i]);
  725. DescrBeginTableRow;
  726. DescrBeginTableCell;
  727. Writeln(EscapeText(EV.Name));
  728. DescrEndTableCell;
  729. DescrBeginTableCell;
  730. DocNode := Engine.FindDocNode(EV);
  731. if Assigned(DocNode) and (not IsDescrNodeEmpty(DocNode.ShortDescr)) then
  732. WriteDescr(EV,DocNode.ShortDescr);
  733. DescrEndTableCell;
  734. DescrEndTableRow;
  735. end;
  736. DescrEndTable;
  737. end;
  738. end;
  739. procedure TLinearWriter.WriteTypes(ASection: TPasSection);
  740. var
  741. i: Integer;
  742. TypeDecl: TPasType;
  743. DocNode : TDocNode;
  744. begin
  745. if ASection.Types.Count > 0 then
  746. begin
  747. StartSubSection(SDocTypes,ModuleName+'Types');
  748. for i := 0 to ASection.Types.Count - 1 do
  749. begin
  750. DescrBeginParagraph;
  751. TypeDecl := TPasType(ASection.Types[i]);
  752. WriteTypeDecl(TypeDecl);
  753. StartListing(False,'');
  754. DocNode := Engine.FindDocNode(TypeDecl);
  755. If Assigned(DocNode) and
  756. Assigned(DocNode.Node) and
  757. (Docnode.Node['opaque']='1') then
  758. Writeln(TypeDecl.Name+' = '+SDocOpaque)
  759. else
  760. begin
  761. Writeln(EscapeText(TypeDecl.GetDeclaration(True)));
  762. end;
  763. EndListing;
  764. WriteLabel(TypeDecl);
  765. WriteIndex(TypeDecl);
  766. If TypeDecl is TPasEnumType then
  767. WriteENumElements(TypeDecl as TPasEnumType)
  768. else If (TypeDecl is TPasSetType)
  769. and (TPasSetType(TypeDecl).EnumType is TPasEnumType)
  770. and (TPasSetType(TypeDecl).EnumType.Name='') then
  771. WriteENumElements(TPasSetType(TypeDecl).EnumType as TPasEnumType);
  772. WriteDescr(TypeDecl,DocNode);
  773. If Assigned(DocNode) and Assigned(DocNode.Version) then
  774. begin
  775. Writeln(Format('%s : ',[SDocVersion]));
  776. WriteDescr(TypeDecl, DocNode.Version);
  777. end;
  778. DescrEndParagraph;
  779. end;
  780. end;
  781. end;
  782. procedure TLinearWriter.WriteVars(ASection: TPasSection);
  783. var
  784. VarDecl: TPasVariable;
  785. i: Integer;
  786. DocNode : TDocNode;
  787. begin
  788. if ASection.Variables.Count > 0 then
  789. begin
  790. StartSubsection(SDocVariables,ModuleName+'Variables');
  791. for i := 0 to ASection.Variables.Count - 1 do
  792. begin
  793. DescrBeginParaGraph;
  794. VarDecl := TPasVariable(ASection.Variables[i]);
  795. WriteVariableDecl(VarDecl);
  796. StartListing(False,'');
  797. WriteLn(EscapeText(VarDecl.GetDeclaration(True)));
  798. EndListing;
  799. WriteLabel(VarDecl);
  800. WriteIndex(VarDecl);
  801. DocNode:=WriteDescr(VarDecl);
  802. If Assigned(DocNode) and Assigned(DocNode.Version) then
  803. begin
  804. Writeln(Format('%s : ',[SDocVersion]));
  805. WriteDescr(VarDecl, DocNode.Version);
  806. end;
  807. DescrEndParaGraph;
  808. end;
  809. end;
  810. end;
  811. procedure TLinearWriter.WriteProcedure(ProcDecl : TPasProcedureBase);
  812. var
  813. DocNode: TDocNode;
  814. OP : TPasOverloadedProc;
  815. i : integer;
  816. begin
  817. With ProcDecl do
  818. begin
  819. if Not (Assigned(Parent) and Parent.InheritsFrom(TPasClassType)) then
  820. begin
  821. StartSubSection(Name);
  822. WriteLabel(ProcDecl);
  823. WriteIndex(ProcDecl);
  824. end
  825. else
  826. begin // Parent assigned and hence method.
  827. StartSubSection(Parent.Name+'.'+Name);
  828. WriteLabel(ProcDecl);
  829. WriteIndex(Parent.Name+'.'+Name);
  830. end;
  831. StartProcedure;
  832. DocNode := Engine.FindDocNode(ProcDecl);
  833. if Assigned(DocNode) and Assigned(DocNode.ShortDescr) then
  834. begin
  835. StartSynopsis;
  836. WriteDescr(ProcDecl, DocNode.ShortDescr);
  837. end;
  838. StartDeclaration;
  839. StartListing(False);
  840. if ClassType = TPasOverloadedProc then
  841. begin
  842. OP:=TPasOverloadedProc(ProcDecl);
  843. for i := 0 to OP.Overloads.Count - 1 do
  844. begin
  845. WriteLn(TPasProcedure(OP.Overloads[i]).GetDeclaration(True));
  846. end;
  847. end
  848. else
  849. WriteLn(GetDeclaration(True));
  850. EndListing;
  851. If Assigned(Parent) then
  852. begin
  853. StartVisibility;
  854. Writeln(VisibilityNames[Visibility])
  855. end;
  856. if Assigned(DocNode) then
  857. begin
  858. If Assigned(DocNode.Descr) then
  859. begin
  860. StartDescription;
  861. WriteDescr(ProcDecl);
  862. end;
  863. if Assigned(DocNode.ErrorsDoc) and (DocNode.ErrorsDoc.HasChildNodes) then
  864. begin
  865. StartErrors;
  866. WriteDescr(ProcDecl, DocNode.ErrorsDoc);
  867. end;
  868. if Assigned(DocNode.Version) then
  869. begin
  870. StartVersion;
  871. WriteDescr(ProcDecl, DocNode.Version);
  872. end;
  873. WriteSeeAlso(DocNode);
  874. EndProcedure;
  875. WriteExample(DocNode);
  876. end
  877. else
  878. EndProcedure;
  879. end;
  880. end;
  881. procedure TLinearWriter.WriteFunctionsAndProcedures(ASection: TPasSection);
  882. var
  883. i: Integer;
  884. begin
  885. if ASection.Functions.Count > 0 then
  886. begin
  887. StartSection(SDocProceduresAndFunctions,ModuleName+'Functions');
  888. for i := 0 to ASection.Functions.Count - 1 do
  889. WriteProcedure(TPasProcedureBase(ASection.Functions[i]));
  890. end;
  891. end;
  892. procedure TLinearWriter.WriteExample(ADocNode: TDocNode);
  893. var
  894. Example: TDOMElement;
  895. S : string;
  896. begin
  897. S:='';
  898. if Assigned(ADocNode) then
  899. begin
  900. Example := ADocNode.FirstExample;
  901. while Assigned(Example) do
  902. begin
  903. if IsExampleNode(Example) then
  904. begin
  905. if (S<>'') then // not first example, start new paragraph
  906. DescrBeginParagraph;
  907. s:=Engine.GetExampleFileName(Example);
  908. if (S<>'') then
  909. WriteExampleFile(S);
  910. if Assigned(Example.NextSibling) then
  911. DescrEndParaGraph;
  912. end;
  913. Example := TDomElement(Example.NextSibling);
  914. end;
  915. end;
  916. end;
  917. procedure TLinearWriter.WriteProperty(PropDecl : TPasProperty);
  918. var
  919. DocNode: TDocNode;
  920. S: String;
  921. lNode: TDocNode;
  922. begin
  923. With PropDecl do
  924. begin
  925. StartSubSection(Parent.Name+'.'+Name);
  926. WriteLabel(PropDecl);
  927. WriteIndex(Parent.Name+'.'+Name);
  928. StartProperty;
  929. DocNode := Engine.FindDocNode(PropDecl);
  930. if Assigned(DocNode) then
  931. begin
  932. if FDupLinkedDoc and (DocNode.Link <> '') then
  933. begin
  934. lNode := Engine.FindLinkedNode(DocNode);
  935. if not Assigned(lNode) then
  936. lNode := DocNode;
  937. end
  938. else
  939. lNode := DocNode;
  940. if Assigned(lNode.ShortDescr) then
  941. begin
  942. StartSynopsis;
  943. WriteDescr(PropDecl, lNode.ShortDescr);
  944. end;
  945. end;
  946. StartDeclaration;
  947. StartListing(False);
  948. WriteLn('Property '+GetDeclaration(True));
  949. EndListing;
  950. If Assigned(Parent) then
  951. begin
  952. StartVisibility;
  953. Writeln(VisibilityNames[Visibility])
  954. end;
  955. StartAccess;
  956. Setlength(S,0);
  957. If Length(ReadAccessorName) > 0 then
  958. S:='Read';
  959. if Length(WriteAccessorName) > 0 then
  960. begin
  961. If S<>'' then
  962. S:=S+',';
  963. S:=S+'Write';
  964. end;
  965. Writeln(S);
  966. if Assigned(DocNode) then
  967. begin
  968. if Assigned(lNode.Descr) then // lNode will be assigned if DocNode exists
  969. begin
  970. StartDescription;
  971. WriteDescr(PropDecl, lNode);
  972. end;
  973. if Assigned(lNode.ErrorsDoc) and (lNode.ErrorsDoc.HasChildNodes) then
  974. begin
  975. StartErrors;
  976. WriteDescr(PropDecl, DocNode.ErrorsDoc);
  977. end;
  978. if Assigned(lNode.Version) then
  979. begin
  980. StartVersion;
  981. WriteDescr(PropDecl, lNode.Version);
  982. end;
  983. WriteSeeAlso(lNode);
  984. EndProperty;
  985. WriteExample(lNode);
  986. end
  987. else
  988. EndProperty;
  989. end;
  990. end;
  991. procedure TLinearWriter.WriteSeeAlso(ADocNode: TDocNode);
  992. var
  993. Node: TDOMNode;
  994. s: String;
  995. First : Boolean;
  996. begin
  997. if Not (Assigned(ADocNode) and Assigned(ADocNode.SeeAlso)) then
  998. Exit;
  999. Node := ADocNode.SeeAlso.FirstChild;
  1000. First:=True;
  1001. while Assigned(Node) do
  1002. begin
  1003. if IsLinkNode(Node) then
  1004. begin
  1005. If First then
  1006. begin
  1007. StartSeealso;
  1008. First:=False;
  1009. end
  1010. else
  1011. Writeln(',');
  1012. S:=TDomElement(Node)['id'];
  1013. DescrBeginLink(S);
  1014. if Node.FirstChild <> nil then
  1015. s := Node.FirstChild.NodeValue;
  1016. Write(EscapeText(S));
  1017. DescrEndLink();
  1018. end;
  1019. Node:=Node.NextSibling;
  1020. end;
  1021. If Not First then
  1022. EndSeeAlso
  1023. end;
  1024. Function CompareElements(P1,P2 : Pointer) : Integer;
  1025. begin
  1026. Result:=CompareText(TPasElement(P1).Name,TPasElement(P2).Name);
  1027. end;
  1028. procedure TLinearWriter.SortElementList(List : TFPList);
  1029. begin
  1030. List.Sort(@CompareElements);
  1031. end;
  1032. Function TLinearWriter.ShowMember(M : TPasElement) : boolean;
  1033. begin
  1034. Result:=not ((M.Visibility=visPrivate) and Engine.HidePrivate);
  1035. If Result then
  1036. Result:=Not ((M.Visibility=visProtected) and Engine.HideProtected)
  1037. end;
  1038. procedure TLinearWriter.WriteClasses(ASection: TPasSection);
  1039. var
  1040. i: Integer;
  1041. begin
  1042. if (ASection.Classes.Count > 0) then
  1043. for i := 0 to ASection.Classes.Count - 1 do
  1044. WriteClassDecl(TPasClassType(ASection.Classes[i]));
  1045. end;
  1046. procedure TLinearWriter.WriteClassMethodOverview(ClassDecl: TPasClassType);
  1047. var
  1048. Member : TPasElement;
  1049. i : Integer;
  1050. L,N,S : String;
  1051. DocNode : TDocNode;
  1052. List : TStringList;
  1053. begin
  1054. List:=TStringList.Create;
  1055. Try
  1056. List.Sorted:=True;
  1057. for i := 0 to ClassDecl.Members.Count - 1 do
  1058. begin
  1059. Member := TPasElement(ClassDecl.Members[i]);
  1060. With Member do
  1061. if InheritsFrom(TPasProcedureBase) and ShowMember(Member) then
  1062. List.AddObject(Member.Name,Member);
  1063. end;
  1064. If List.Count>0 then
  1065. begin
  1066. StartSubSection(SDocMethodOverview);
  1067. WriteLabel(GetLabel(ClassDecl) + ':Methods');
  1068. StartOverview(False);
  1069. For I:=0 to List.Count-1 do
  1070. begin
  1071. Member:=TPasElement(List.Objects[i]);
  1072. L:=StripText(GetLabel(Member));
  1073. N:=EscapeText(Member.Name);
  1074. DocNode := Engine.FindDocNode(Member);
  1075. If Assigned(DocNode) then
  1076. S:=GetDescrString(Member, DocNode.ShortDescr)
  1077. else
  1078. S:='';
  1079. WriteOverviewMember(L,N,S);
  1080. end;
  1081. EndOverview;
  1082. end;
  1083. Finally
  1084. List.Free;
  1085. end;
  1086. end;
  1087. constructor TLinearWriter.Create(APackage: TPasPackage; AEngine: TFPDocEngine);
  1088. procedure AddLabel(AElement: TPasElement);
  1089. begin
  1090. Engine.AddLink(AElement.PathName, GetLabel(AElement));
  1091. end;
  1092. procedure AddList(AElement: TPasElement; AList: TFPList);
  1093. var
  1094. i: Integer;
  1095. begin
  1096. for i := 0 to AList.Count - 1 do
  1097. AddLabel(TPasElement(AList[i]));
  1098. end;
  1099. procedure AddTopicPages(AElement: TPasElement);
  1100. var
  1101. PreviousTopic,
  1102. TopicElement : TTopicElement;
  1103. DocNode,
  1104. TopicNode : TDocNode;
  1105. begin
  1106. DocNode:=Engine.FindDocNode(AElement);
  1107. If not Assigned(DocNode) then
  1108. exit;
  1109. TopicNode:=DocNode.FirstChild;
  1110. PreviousTopic:=Nil;
  1111. While Assigned(TopicNode) do
  1112. begin
  1113. If TopicNode.TopicNode then
  1114. begin
  1115. TopicElement:=TTopicElement.Create(TopicNode.Name,AElement);
  1116. Topics.Add(TopicElement);
  1117. TopicElement.TopicNode:=TopicNode;
  1118. TopicElement.Previous:=PreviousTopic;
  1119. If Assigned(PreviousTopic) then
  1120. PreviousTopic.Next:=TopicElement;
  1121. PreviousTopic:=TopicElement;
  1122. if AElement is TTopicElement then
  1123. TTopicElement(AElement).SubTopics.Add(TopicElement);
  1124. Engine.AddLink(TopicElement.PathName, GetLabel(TopicElement));
  1125. if AElement is TTopicElement then
  1126. TTopicElement(AElement).SubTopics.Add(TopicElement)
  1127. else // Only one level of recursion.
  1128. AddTopicPages(TopicElement);
  1129. end;
  1130. TopicNode:=TopicNode.NextSibling;
  1131. end;
  1132. end;
  1133. procedure ScanModule(AModule: TPasModule);
  1134. var
  1135. i, j, k: Integer;
  1136. ClassEl: TPasClassType;
  1137. FPEl, AncestorMemberEl: TPasElement;
  1138. DocNode: TDocNode;
  1139. DidAutolink: Boolean;
  1140. begin
  1141. AddLabel(AModule);
  1142. AddTopicPages(AModule);
  1143. with AModule do
  1144. begin
  1145. AddList(AModule, InterfaceSection.ResStrings);
  1146. AddList(AModule, InterfaceSection.Consts);
  1147. AddList(AModule, InterfaceSection.Types);
  1148. if InterfaceSection.Classes.Count > 0 then
  1149. begin
  1150. for i := 0 to InterfaceSection.Classes.Count - 1 do
  1151. begin
  1152. ClassEl := TPasClassType(InterfaceSection.Classes[i]);
  1153. AddLabel(ClassEl);
  1154. for j := 0 to ClassEl.Members.Count - 1 do
  1155. begin
  1156. FPEl := TPasElement(ClassEl.Members[j]);
  1157. if ((FPEl.Visibility = visPrivate) and Engine.HidePrivate) or
  1158. ((FPEl.Visibility = visProtected) and Engine.HideProtected) then
  1159. continue;
  1160. DocNode := Engine.FindDocNode(FPEl);
  1161. if not Assigned(DocNode) then
  1162. begin
  1163. DidAutolink := False;
  1164. if Assigned(ClassEl.AncestorType) and
  1165. (ClassEl.AncestorType.ClassType = TPasClassType) then
  1166. begin
  1167. for k := 0 to TPasClassType(ClassEl.AncestorType).Members.Count - 1 do
  1168. begin
  1169. AncestorMemberEl :=
  1170. TPasElement(TPasClassType(ClassEl.AncestorType).Members[k]);
  1171. if AncestorMemberEl.Name = FPEl.Name then
  1172. begin
  1173. DocNode := Engine.FindDocNode(AncestorMemberEl);
  1174. if Assigned(DocNode) then
  1175. begin
  1176. DidAutolink := True;
  1177. Engine.AddLink(FPEl.PathName,
  1178. Engine.FindAbsoluteLink(AncestorMemberEl.PathName));
  1179. break;
  1180. end;
  1181. end;
  1182. end;
  1183. end;
  1184. if not DidAutolink then
  1185. AddLabel(FPEl);
  1186. end else
  1187. AddLabel(FPEl);
  1188. end;
  1189. end;
  1190. end;
  1191. AddList(AModule, InterfaceSection.Functions);
  1192. AddList(AModule, InterfaceSection.Variables);
  1193. end;
  1194. end;
  1195. var
  1196. i: Integer;
  1197. begin
  1198. inherited ;
  1199. FDupLinkedDoc := False; // by default we don't duplicate linked element documentation
  1200. { Allocate labels for all elements for which we are going to create
  1201. documentation. This is needed for links to work correctly. }
  1202. // Allocate label for the package itself, if a name is given (i.e. <> '#')
  1203. if Length(Package.Name) > 1 then
  1204. begin
  1205. AddLabel(Package);
  1206. AddTopicPages(Package);
  1207. end;
  1208. for i := 0 to Package.Modules.Count - 1 do
  1209. ScanModule(TPasModule(Package.Modules[i]));
  1210. end;
  1211. procedure TLinearWriter.WriteBeginDocument;
  1212. begin
  1213. WriteComment('This file has been created automatically by FPDoc.');
  1214. WriteComment('Linear output (c) 2005 Michael Van Canneyt');
  1215. end;
  1216. procedure TLinearWriter.WriteEndDocument;
  1217. begin
  1218. // do nothing
  1219. end;
  1220. function TLinearWriter.InterpretOption(const Cmd: String; const Arg: String): Boolean;
  1221. begin
  1222. Result := True;
  1223. if Cmd = cDupLinkedDocParam then
  1224. begin
  1225. FDupLinkedDoc := True;
  1226. end
  1227. else
  1228. Result := False;
  1229. end;
  1230. class procedure TLinearWriter.Usage(List: TStrings);
  1231. begin
  1232. List.Add(cDupLinkedDocParam);
  1233. List.Add(SLinearUsageDupLinkedDocsP1);
  1234. List.Add('');
  1235. List.Add(SLinearUsageDupLinkedDocsP2);
  1236. end;
  1237. end.