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. Public
  86. Constructor Create(APackage: TPasPackage; AEngine: TFPDocEngine); override;
  87. function InterpretOption(const Cmd, Arg: String): Boolean; override;
  88. class procedure Usage(List: TStrings); override;
  89. procedure WriteDoc; override;
  90. // Linear Documentation writing methods.
  91. Procedure ProcessPackage;
  92. Procedure ProcessTopics(DocNode : TDocNode; Alevel : Integer);
  93. procedure WriteResourceStrings(ASection: TPasSection);
  94. procedure WriteUnitOverview(ASection: TPasSection);
  95. procedure WriteVarsConstsTypes(ASection: TPasSection);
  96. procedure WriteConsts(ASection: TPasSection);
  97. procedure WriteTypes(ASection: TPasSection); virtual;
  98. procedure WriteEnumElements(TypeDecl : TPasEnumType);
  99. procedure WriteVars(ASection: TPasSection);
  100. procedure WriteFunctionsAndProcedures(ASection: TPasSection);
  101. procedure WriteProcedure(ProcDecl: TPasProcedureBase);
  102. procedure WriteClasses(ASection: TPasSection);
  103. procedure WriteClassDecl(ClassDecl: TPasClassType);
  104. procedure WriteClassMethodOverview(ClassDecl: TPasClassType);
  105. procedure WriteClassPropertyOverview(ClassDecl: TPasClassType);
  106. procedure WriteClassInterfacesOverView(ClassDecl: TPasClassType);
  107. procedure WriteProperty(PropDecl: TPasProperty);
  108. procedure WriteExample(ADocNode: TDocNode);
  109. procedure WriteSeeAlso(ADocNode: TDocNode);
  110. Procedure WriteTopicNode(Node : TDocNode; Level : Integer);
  111. // Overriden from fpdocwriter;
  112. procedure DescrWriteText(const AText: DOMString); override;
  113. end;
  114. implementation
  115. const
  116. cDupLinkedDocParam = '--duplinkeddoc';
  117. { TLinearWriter }
  118. { ---------------------------------------------------------------------
  119. Writing support
  120. ---------------------------------------------------------------------}
  121. Function TLinearWriter.PushWriteContext(S : TStream) : TStream;
  122. begin
  123. Result:=FStream;
  124. FStream:=S;
  125. end;
  126. Procedure TLinearWriter.PopWriteContext(S : TSTream);
  127. begin
  128. FStream:=S;
  129. end;
  130. procedure TLinearWriter.Write(const s: String);
  131. Var
  132. L : Integer;
  133. begin
  134. L:=Length(S);
  135. If (L>0) then
  136. FStream.Write(PChar(S)^,L);
  137. end;
  138. procedure TLinearWriter.WriteF(const s: String; const Args: array of const);
  139. begin
  140. Write(Format(S,Args));
  141. end;
  142. procedure TLinearWriter.WriteLn(const s: String);
  143. begin
  144. Write(S);
  145. Write(LineEnding);
  146. end;
  147. procedure TLinearWriter.WriteLnF(const s: String; const Args: array of const);
  148. begin
  149. Write(Format(S,Args));
  150. Write(LineEnding);
  151. end;
  152. procedure TLinearWriter.DescrWriteText(const AText: DOMString);
  153. begin
  154. Write(EscapeText(AText));
  155. end;
  156. Function TLinearWriter.GetDescrString(AContext: TPasElement; DescrNode: TDOMElement) : String;
  157. Var
  158. S : TStringStream;
  159. F : TStream;
  160. begin
  161. Result:='';
  162. if Assigned(DescrNode) then
  163. begin
  164. S:=TStringStream.Create('');
  165. Try
  166. F:=PushWriteContext(S);
  167. Try
  168. ConvertDescr(AContext, DescrNode, False);
  169. Result:=S.DataString;
  170. FInally
  171. PopWriteContext(F);
  172. end;
  173. finally
  174. S.FRee;
  175. end;
  176. end;
  177. end;
  178. { ---------------------------------------------------------------------
  179. Auxiliary routines
  180. ---------------------------------------------------------------------}
  181. procedure TLinearWriter.WriteLabel(El: TPasElement);
  182. begin
  183. WriteLabel(GetLabel(El));
  184. end;
  185. procedure TLinearWriter.WriteIndex(El: TPasElement);
  186. begin
  187. WriteIndex(EL.Name);
  188. end;
  189. procedure TLinearWriter.WriteTypeDecl(El: TPasElement);
  190. begin
  191. WriteType(El.Name);
  192. end;
  193. procedure TLinearWriter.WriteVariableDecl(El: TPasElement);
  194. begin
  195. WriteVariable(El.Name);
  196. end;
  197. procedure TLinearWriter.WriteConstDecl(El: TPasElement);
  198. begin
  199. WriteConstant(El.Name);
  200. end;
  201. procedure TLinearWriter.DescrBeginURL(const AURL: DOMString);
  202. begin
  203. FLastURL:=AURL;
  204. end;
  205. procedure TLinearWriter.DescrEndURL;
  206. begin
  207. If (FLastURL<>'') then
  208. Writeln(Format(SSeeURL,[EscapeText(FLastURL)]));
  209. FLastURL:='';
  210. end;
  211. procedure TLinearWriter.StartListing(Frames: Boolean);
  212. begin
  213. StartListing(Frames,'');
  214. end;
  215. procedure TLinearWriter.StartChapter(ChapterName: String; ChapterLabel: String);
  216. begin
  217. StartChapter(ChapterName);
  218. WriteLabel(ChapterLabel);
  219. end;
  220. procedure TLinearWriter.StartSection(SectionName: String; SectionLabel: String);
  221. begin
  222. StartSection(SectionName);
  223. WriteLabel(SectionLabel);
  224. end;
  225. procedure TLinearWriter.StartSubSection(SubSectionName: String; SubSectionLabel: String);
  226. begin
  227. StartSubSection(SubSectionName);
  228. WriteLabel(SubSectionLabel);
  229. end;
  230. procedure TLinearWriter.StartSubSubSection(SubSubSectionName: String;
  231. SubSubSectionLabel: String);
  232. begin
  233. StartSubSubSection(SubSubSectionName);
  234. WriteLabel(SubSubSectionLabel);
  235. end;
  236. { ---------------------------------------------------------------------
  237. Default implementations, may be overridden in descendents
  238. ---------------------------------------------------------------------}
  239. Function TLinearWriter.EscapeText(S : String) : String;
  240. begin
  241. Result:=S;
  242. end;
  243. Function TLinearWriter.StripText(S : String) : String;
  244. begin
  245. Result:=S;
  246. end;
  247. Procedure TLinearWriter.StartProcedure;
  248. begin
  249. Writeln(SDocProcedure+':');
  250. end;
  251. Procedure TLinearWriter.StartSynopsis;
  252. begin
  253. Writeln('');
  254. Writeln(SDocSynopsis+':');
  255. end;
  256. Procedure TLinearWriter.StartDeclaration;
  257. begin
  258. Writeln('');
  259. Writeln(SDocDeclaration+':');
  260. end;
  261. Procedure TLinearWriter.StartVisibility;
  262. begin
  263. Writeln('');
  264. Writeln(SDocVisibility+':');
  265. end;
  266. Procedure TLinearWriter.StartDescription;
  267. begin
  268. Writeln('');
  269. Writeln(SDocDescription+':');
  270. end;
  271. Procedure TLinearWriter.StartAccess;
  272. begin
  273. Writeln('');
  274. Writeln(SDocAccess+':');
  275. end;
  276. Procedure TLinearWriter.StartErrors;
  277. begin
  278. Writeln('');
  279. Writeln(SDocErrors+':');
  280. end;
  281. Procedure TLinearWriter.StartVersion;
  282. begin
  283. Writeln('');
  284. Writeln(SDocVersion+':');
  285. end;
  286. Procedure TLinearWriter.StartSeealso;
  287. begin
  288. Writeln('');
  289. Writeln(SDocSeeAlso+':');
  290. end;
  291. Procedure TLinearWriter.StartProperty;
  292. begin
  293. Writeln('');
  294. Writeln(SDocProperty+':');
  295. end;
  296. Procedure TLinearWriter.EndProcedure;
  297. begin
  298. Writeln('');
  299. end;
  300. Procedure TLinearWriter.EndProperty;
  301. begin
  302. Writeln('');
  303. end;
  304. procedure TLinearWriter.EndSeealso;
  305. begin
  306. Writeln('');
  307. end;
  308. procedure TLinearWriter.WriteType(const s: string);
  309. begin
  310. // do nothing
  311. end;
  312. procedure TLinearWriter.WriteVariable(const s: string);
  313. begin
  314. // do nothing
  315. end;
  316. procedure TLinearWriter.WriteConstant(const s: string);
  317. begin
  318. // do nothing
  319. end;
  320. procedure TLinearWriter.WriteClassDecl(ClassDecl: TPasClassType);
  321. var
  322. DocNode: TDocNode;
  323. Vis: TPasMemberVisibilities;
  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. // 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. else if (ExtractFileExt(Engine.output)='') and (FileNameExtension<>'') then
  505. Engine.Output:=ChangeFileExt(Engine.output,FileNameExtension);
  506. FStream:=TFileStream.Create(Engine.Output,fmCreate);
  507. try
  508. WriteBeginDocument;
  509. ProcessPackage;
  510. L:=TStringList.Create;
  511. Try
  512. L.Sorted:=True;
  513. // Sort modules.
  514. For I:=0 to Package.Modules.Count-1 do
  515. L.AddObject(TPasModule(Package.Modules[i]).Name,TPasModule(Package.Modules[i]));
  516. // Now create table.
  517. for i:=0 to L.Count - 1 do
  518. begin
  519. Module := TPasModule(L.Objects[i]);
  520. ModuleName := LowerCase(Module.Name);
  521. WriteCommentLine;
  522. StartChapter(Format(SDocUnitTitle, [Module.Name]));
  523. WriteLabel(Module);
  524. // extra Topics now get processed in ProcessSection()
  525. ProcessSection(Module.InterfaceSection);
  526. end;
  527. Finally
  528. L.Free;
  529. end;
  530. WriteEndDocument;
  531. finally
  532. FSTream.Free;
  533. end;
  534. end;
  535. procedure TLinearWriter.ProcessSection(ASection: TPasSection);
  536. var
  537. DocNode: TDocNode;
  538. begin
  539. With ASection do
  540. begin
  541. SortElementList(UsesList);
  542. SortElementList(Declarations);
  543. SortElementList(ResStrings);
  544. SortElementList(Types);
  545. SortElementList(Consts);
  546. SortElementList(Classes);
  547. SortElementList(Functions);
  548. SortElementList(Variables);
  549. end;
  550. WriteUnitOverView(ASection);
  551. // Now process unit (extra) Topics
  552. DocNode:=Engine.FindDocNode(Module);
  553. If Assigned(DocNode) then
  554. ProcessTopics(DocNode,1);
  555. WriteVarsConstsTypes(ASection);
  556. WriteFunctionsAndProcedures(ASection);
  557. WriteClasses(ASection);
  558. end;
  559. procedure TLinearWriter.WriteVarsConstsTypes(ASection: TPasSection);
  560. begin
  561. With Asection do
  562. if (Consts.Count>0) or (Types.Count>0) or
  563. (Variables.Count>0) or (ResStrings.Count>0) then
  564. begin
  565. StartSection(SDocConstsTypesVars, ModuleName+'ConstsTypesVars');
  566. WriteResourceStrings(ASection);
  567. WriteConsts(ASection);
  568. WriteTypes(ASection);
  569. WriteVars(ASection);
  570. end;
  571. end;
  572. procedure TLinearWriter.WriteResourceStrings(ASection: TPasSection);
  573. var
  574. ResStrDecl: TPasResString;
  575. i: Integer;
  576. DocNode : TDocNode;
  577. begin
  578. if ASection.ResStrings.Count > 0 then
  579. begin
  580. StartSubSection(SDocResStrings,ModuleName+'ResStrings');
  581. for i := 0 to ASection.ResStrings.Count - 1 do
  582. begin
  583. ResStrDecl := TPasResString(ASection.ResStrings[i]);
  584. StartListing(false, '');
  585. DescrWriteText(ResStrDecl.GetDeclaration(True)); // instead of WriteLn() so we can do further processing like manual line wrapping in descendants
  586. EndListing;
  587. WriteLabel(ResStrDecl);
  588. WriteIndex(ResStrDecl);
  589. DocNode:=WriteDescr(ResStrDecl);
  590. If Assigned(DocNode) and Assigned(DocNode.Version) then
  591. begin
  592. Writeln(Format('%s : ',[SDocVersion]));
  593. WriteDescr(ResStrDecl, DocNode.Version);
  594. end;
  595. end;
  596. end;
  597. end;
  598. procedure TLinearWriter.WriteUnitOverview(ASection: TPasSection);
  599. var
  600. i: Integer;
  601. UnitRef: TPasType;
  602. DocNode: TDocNode;
  603. begin
  604. if ASection.UsesList.Count > 0 then
  605. begin
  606. StartSection(SDocUsedUnits);
  607. StartUnitOverview(Module.Name,ModuleName);
  608. for i := 0 to ASection.UsesList.Count - 1 do
  609. begin
  610. UnitRef := TPasType(ASection.UsesList[i]);
  611. WriteUnitEntry(UnitRef);
  612. end;
  613. EndUnitOverview;
  614. end;
  615. DocNode := Engine.FindDocNode(ASection.Parent);
  616. if Assigned(DocNode) and not IsDescrNodeEmpty(DocNode.Descr) then
  617. begin
  618. StartSection(SDocOverview);
  619. WriteDescr(ASection.Parent, DocNode.Descr);
  620. ConvertNotes(ASection.Parent,DocNode.Notes);
  621. end;
  622. end;
  623. Procedure TLinearWriter.ProcessPackage;
  624. var
  625. DocNode: TDocNode;
  626. begin
  627. DocNode:=Engine.FindDocNode(Package);
  628. if Assigned(DocNode) and not IsDescrNodeEmpty(DocNode.Descr) then
  629. begin
  630. StartSection(SDocOverview);
  631. WriteDescr(Package, DocNode.Descr);
  632. end;
  633. WriteSeeAlso(DocNode);
  634. ConvertNotes(Nil,DocNode.Notes);
  635. ProcessTopics(DocNode,1);
  636. end;
  637. Procedure TLinearWriter.ProcessTopics(DocNode : TDocNode; Alevel : Integer);
  638. Var
  639. Node : TDocNode;
  640. begin
  641. If Not Assigned(DocNode) then
  642. Exit;
  643. Node:=DocNode.FirstChild;
  644. While Assigned(Node) do
  645. begin
  646. If Node.TopicNode then
  647. WriteTopicNode(Node,ALevel);
  648. Node:=Node.NextSibling;
  649. end;
  650. end;
  651. Procedure TLinearWriter.WriteTopicNode(Node : TDocNode; Level : Integer);
  652. Var
  653. Element : TTopicElement;
  654. SubNode : TDocNode;
  655. S : String;
  656. begin
  657. Element:=FindTopicElement(Node);
  658. If Not Assigned(Element) then
  659. Exit;
  660. S:=GetDescrString(Element,Node.ShortDescr);
  661. Case Level of
  662. 1 : StartSection(S);
  663. 2 : StartSubSection(S);
  664. 3 : StartSubSubSection(S);
  665. end;
  666. WriteLabel(Element);
  667. If Assigned(Node.Descr) then
  668. WriteDescr(Element,Node.Descr);
  669. WriteSeeAlso(Node);
  670. ConvertNotes(Element,Node.Notes);
  671. If Level<3 then
  672. begin
  673. SubNode:=Node.FirstChild;
  674. While Assigned(SubNode) do
  675. begin
  676. If SubNode.TopicNode then
  677. WriteTopicNode(SubNode,Level+1);
  678. SubNode:=SubNode.NextSibling;
  679. end;
  680. end;
  681. WriteExample(Node);
  682. end;
  683. procedure TLinearWriter.WriteConsts(ASection: TPasSection);
  684. var
  685. i: Integer;
  686. ConstDecl: TPasConst;
  687. begin
  688. if ASection.Consts.Count > 0 then
  689. begin
  690. StartSubSection(SDocConstants,EscapeText(ModuleName));
  691. for i := 0 to ASection.Consts.Count - 1 do
  692. begin
  693. DescrBeginParaGraph;
  694. ConstDecl := TPasConst(ASection.Consts[i]);
  695. WriteConstDecl(ConstDecl);
  696. StartListing(False,'');
  697. WriteLn(EscapeText(ConstDecl.GetDeclaration(True)));
  698. EndListing;
  699. WriteLabel(ConstDecl);
  700. WriteIndex(ConstDecl);
  701. WriteDescr(ConstDecl);
  702. DescrEndParaGraph;
  703. end;
  704. end;
  705. end;
  706. procedure TLinearWriter.WriteEnumElements(TypeDecl : TPasEnumType);
  707. Var
  708. EV : TPasEnumValue;
  709. I : Integer;
  710. DocNode : TDocNode;
  711. begin
  712. With TypeDecl do
  713. begin
  714. SortElementList(Values);
  715. DescrBeginTable(2,True);
  716. DescrBeginTableCaption;
  717. Writeln(EscapeText(Format(SDocValuesForEnum,[TypeDecl.Name])));
  718. DescrEndTableCaption;
  719. DescrBeginTableHeadRow;
  720. DescrBeginTableCell;
  721. Writeln(EscapeText(SDocValue));
  722. DescrEndTableCell;
  723. DescrBeginTableCell;
  724. Writeln(EscapeText(SDocExplanation));
  725. DescrEndTableCell;
  726. DescrEndTableHeadRow;
  727. For I:=0 to Values.Count-1 do
  728. begin
  729. EV:=TPasEnumValue(Values[i]);
  730. DescrBeginTableRow;
  731. DescrBeginTableCell;
  732. Writeln(EscapeText(EV.Name));
  733. DescrEndTableCell;
  734. DescrBeginTableCell;
  735. DocNode := Engine.FindDocNode(EV);
  736. if Assigned(DocNode) and (not IsDescrNodeEmpty(DocNode.ShortDescr)) then
  737. WriteDescr(EV,DocNode.ShortDescr);
  738. DescrEndTableCell;
  739. DescrEndTableRow;
  740. end;
  741. DescrEndTable;
  742. end;
  743. end;
  744. procedure TLinearWriter.WriteTypes(ASection: TPasSection);
  745. var
  746. i: Integer;
  747. TypeDecl: TPasType;
  748. DocNode : TDocNode;
  749. begin
  750. if ASection.Types.Count > 0 then
  751. begin
  752. StartSubSection(SDocTypes,ModuleName+'Types');
  753. for i := 0 to ASection.Types.Count - 1 do
  754. begin
  755. DescrBeginParagraph;
  756. TypeDecl := TPasType(ASection.Types[i]);
  757. WriteTypeDecl(TypeDecl);
  758. StartListing(False,'');
  759. DocNode := Engine.FindDocNode(TypeDecl);
  760. If Assigned(DocNode) and
  761. Assigned(DocNode.Node) and
  762. (Docnode.Node['opaque']='1') then
  763. Writeln(TypeDecl.Name+' = '+SDocOpaque)
  764. else
  765. begin
  766. Writeln(EscapeText(TypeDecl.GetDeclaration(True)));
  767. end;
  768. EndListing;
  769. WriteLabel(TypeDecl);
  770. WriteIndex(TypeDecl);
  771. If TypeDecl is TPasEnumType then
  772. WriteENumElements(TypeDecl as TPasEnumType)
  773. else If (TypeDecl is TPasSetType)
  774. and (TPasSetType(TypeDecl).EnumType is TPasEnumType)
  775. and (TPasSetType(TypeDecl).EnumType.Name='') then
  776. WriteENumElements(TPasSetType(TypeDecl).EnumType as TPasEnumType);
  777. WriteDescr(TypeDecl,DocNode);
  778. If Assigned(DocNode) and Assigned(DocNode.Version) then
  779. begin
  780. Writeln(Format('%s : ',[SDocVersion]));
  781. WriteDescr(TypeDecl, DocNode.Version);
  782. end;
  783. ConvertNotes(TypeDecl,DocNode.Notes);
  784. DescrEndParagraph;
  785. end;
  786. end;
  787. end;
  788. procedure TLinearWriter.WriteVars(ASection: TPasSection);
  789. var
  790. VarDecl: TPasVariable;
  791. i: Integer;
  792. DocNode : TDocNode;
  793. begin
  794. if ASection.Variables.Count > 0 then
  795. begin
  796. StartSubsection(SDocVariables,ModuleName+'Variables');
  797. for i := 0 to ASection.Variables.Count - 1 do
  798. begin
  799. DescrBeginParaGraph;
  800. VarDecl := TPasVariable(ASection.Variables[i]);
  801. WriteVariableDecl(VarDecl);
  802. StartListing(False,'');
  803. WriteLn(EscapeText(VarDecl.GetDeclaration(True)));
  804. EndListing;
  805. WriteLabel(VarDecl);
  806. WriteIndex(VarDecl);
  807. DocNode:=WriteDescr(VarDecl);
  808. If Assigned(DocNode) and Assigned(DocNode.Version) then
  809. begin
  810. Writeln(Format('%s : ',[SDocVersion]));
  811. WriteDescr(VarDecl, DocNode.Version);
  812. ConvertNotes(VarDecl,DocNode.Notes);
  813. end;
  814. DescrEndParaGraph;
  815. end;
  816. end;
  817. end;
  818. procedure TLinearWriter.WriteProcedure(ProcDecl : TPasProcedureBase);
  819. var
  820. DocNode: TDocNode;
  821. OP : TPasOverloadedProc;
  822. i : integer;
  823. begin
  824. With ProcDecl do
  825. begin
  826. if Not (Assigned(Parent) and Parent.InheritsFrom(TPasClassType)) then
  827. begin
  828. StartSubSection(Name);
  829. WriteLabel(ProcDecl);
  830. WriteIndex(ProcDecl);
  831. end
  832. else
  833. begin // Parent assigned and hence method.
  834. StartSubSection(Parent.Name+'.'+Name);
  835. WriteLabel(ProcDecl);
  836. WriteIndex(Parent.Name+'.'+Name);
  837. end;
  838. StartProcedure;
  839. DocNode := Engine.FindDocNode(ProcDecl);
  840. if Assigned(DocNode) and Assigned(DocNode.ShortDescr) then
  841. begin
  842. StartSynopsis;
  843. WriteDescr(ProcDecl, DocNode.ShortDescr);
  844. end;
  845. StartDeclaration;
  846. StartListing(False);
  847. if ClassType = TPasOverloadedProc then
  848. begin
  849. OP:=TPasOverloadedProc(ProcDecl);
  850. for i := 0 to OP.Overloads.Count - 1 do
  851. begin
  852. WriteLn(TPasProcedure(OP.Overloads[i]).GetDeclaration(True));
  853. end;
  854. end
  855. else
  856. WriteLn(GetDeclaration(True));
  857. EndListing;
  858. If Assigned(Parent) then
  859. begin
  860. StartVisibility;
  861. Writeln(VisibilityNames[Visibility])
  862. end;
  863. if Assigned(DocNode) then
  864. begin
  865. If Assigned(DocNode.Descr) then
  866. begin
  867. StartDescription;
  868. WriteDescr(ProcDecl);
  869. end;
  870. if Assigned(DocNode.ErrorsDoc) and (DocNode.ErrorsDoc.HasChildNodes) then
  871. begin
  872. StartErrors;
  873. WriteDescr(ProcDecl, DocNode.ErrorsDoc);
  874. end;
  875. if Assigned(DocNode.Version) then
  876. begin
  877. StartVersion;
  878. WriteDescr(ProcDecl, DocNode.Version);
  879. end;
  880. WriteSeeAlso(DocNode);
  881. EndProcedure;
  882. WriteExample(DocNode);
  883. ConvertNotes(ProcDecl,DocNode.Notes);
  884. end
  885. else
  886. EndProcedure;
  887. end;
  888. end;
  889. procedure TLinearWriter.WriteFunctionsAndProcedures(ASection: TPasSection);
  890. var
  891. i: Integer;
  892. begin
  893. if ASection.Functions.Count > 0 then
  894. begin
  895. StartSection(SDocProceduresAndFunctions,ModuleName+'Functions');
  896. for i := 0 to ASection.Functions.Count - 1 do
  897. WriteProcedure(TPasProcedureBase(ASection.Functions[i]));
  898. end;
  899. end;
  900. procedure TLinearWriter.WriteExample(ADocNode: TDocNode);
  901. var
  902. Example: TDOMElement;
  903. S : string;
  904. begin
  905. S:='';
  906. if Assigned(ADocNode) then
  907. begin
  908. Example := ADocNode.FirstExample;
  909. while Assigned(Example) do
  910. begin
  911. if IsExampleNode(Example) then
  912. begin
  913. if (S<>'') then // not first example, start new paragraph
  914. DescrBeginParagraph;
  915. s:=Engine.GetExampleFileName(Example);
  916. if (S<>'') then
  917. WriteExampleFile(S);
  918. if Assigned(Example.NextSibling) then
  919. DescrEndParaGraph;
  920. end;
  921. Example := TDomElement(Example.NextSibling);
  922. end;
  923. end;
  924. end;
  925. procedure TLinearWriter.WriteProperty(PropDecl : TPasProperty);
  926. var
  927. DocNode: TDocNode;
  928. S: String;
  929. lNode: TDocNode;
  930. begin
  931. With PropDecl do
  932. begin
  933. StartSubSection(Parent.Name+'.'+Name);
  934. WriteLabel(PropDecl);
  935. WriteIndex(Parent.Name+'.'+Name);
  936. StartProperty;
  937. DocNode := Engine.FindDocNode(PropDecl);
  938. if Assigned(DocNode) then
  939. begin
  940. if FDupLinkedDoc and (DocNode.Link <> '') then
  941. begin
  942. lNode := Engine.FindLinkedNode(DocNode);
  943. if not Assigned(lNode) then
  944. lNode := DocNode;
  945. end
  946. else
  947. lNode := DocNode;
  948. if Assigned(lNode.ShortDescr) then
  949. begin
  950. StartSynopsis;
  951. WriteDescr(PropDecl, lNode.ShortDescr);
  952. end;
  953. end;
  954. StartDeclaration;
  955. StartListing(False);
  956. WriteLn('Property '+GetDeclaration(True));
  957. EndListing;
  958. If Assigned(Parent) then
  959. begin
  960. StartVisibility;
  961. Writeln(VisibilityNames[Visibility])
  962. end;
  963. StartAccess;
  964. Setlength(S,0);
  965. If Length(ReadAccessorName) > 0 then
  966. S:='Read';
  967. if Length(WriteAccessorName) > 0 then
  968. begin
  969. If S<>'' then
  970. S:=S+',';
  971. S:=S+'Write';
  972. end;
  973. Writeln(S);
  974. if Assigned(DocNode) then
  975. begin
  976. if Assigned(lNode.Descr) then // lNode will be assigned if DocNode exists
  977. begin
  978. StartDescription;
  979. WriteDescr(PropDecl, lNode);
  980. end;
  981. if Assigned(lNode.ErrorsDoc) and (lNode.ErrorsDoc.HasChildNodes) then
  982. begin
  983. StartErrors;
  984. WriteDescr(PropDecl, DocNode.ErrorsDoc);
  985. end;
  986. if Assigned(lNode.Version) then
  987. begin
  988. StartVersion;
  989. WriteDescr(PropDecl, lNode.Version);
  990. end;
  991. WriteSeeAlso(lNode);
  992. ConvertNotes(PropDecl,lNode.Notes);
  993. EndProperty;
  994. WriteExample(lNode);
  995. end
  996. else
  997. EndProperty;
  998. end;
  999. end;
  1000. procedure TLinearWriter.WriteSeeAlso(ADocNode: TDocNode);
  1001. var
  1002. Node: TDOMNode;
  1003. s: String;
  1004. First : Boolean;
  1005. begin
  1006. if Not (Assigned(ADocNode) and Assigned(ADocNode.SeeAlso)) then
  1007. Exit;
  1008. Node := ADocNode.SeeAlso.FirstChild;
  1009. First:=True;
  1010. while Assigned(Node) do
  1011. begin
  1012. if IsLinkNode(Node) then
  1013. begin
  1014. If First then
  1015. begin
  1016. StartSeealso;
  1017. First:=False;
  1018. end
  1019. else
  1020. Writeln(',');
  1021. S:=TDomElement(Node)['id'];
  1022. DescrBeginLink(S);
  1023. if Node.FirstChild <> nil then
  1024. s := Node.FirstChild.NodeValue;
  1025. Write(EscapeText(S));
  1026. DescrEndLink();
  1027. end;
  1028. Node:=Node.NextSibling;
  1029. end;
  1030. If Not First then
  1031. EndSeeAlso
  1032. end;
  1033. Function CompareElements(P1,P2 : Pointer) : Integer;
  1034. begin
  1035. Result:=CompareText(TPasElement(P1).Name,TPasElement(P2).Name);
  1036. end;
  1037. procedure TLinearWriter.SortElementList(List : TFPList);
  1038. begin
  1039. List.Sort(@CompareElements);
  1040. end;
  1041. Function TLinearWriter.ShowMember(M : TPasElement) : boolean;
  1042. begin
  1043. Result:=not ((M.Visibility=visPrivate) and Engine.HidePrivate);
  1044. If Result then
  1045. Result:=Not ((M.Visibility=visProtected) and Engine.HideProtected)
  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 ((FPEl.Visibility = visPrivate) and Engine.HidePrivate) or
  1167. ((FPEl.Visibility = visProtected) and Engine.HideProtected) then
  1168. continue;
  1169. DocNode := Engine.FindDocNode(FPEl);
  1170. if not Assigned(DocNode) then
  1171. begin
  1172. DidAutolink := False;
  1173. if Assigned(ClassEl.AncestorType) and
  1174. (ClassEl.AncestorType.ClassType = TPasClassType) then
  1175. begin
  1176. for k := 0 to TPasClassType(ClassEl.AncestorType).Members.Count - 1 do
  1177. begin
  1178. AncestorMemberEl :=
  1179. TPasElement(TPasClassType(ClassEl.AncestorType).Members[k]);
  1180. if AncestorMemberEl.Name = FPEl.Name then
  1181. begin
  1182. DocNode := Engine.FindDocNode(AncestorMemberEl);
  1183. if Assigned(DocNode) then
  1184. begin
  1185. DidAutolink := True;
  1186. Engine.AddLink(FPEl.PathName,
  1187. Engine.FindAbsoluteLink(AncestorMemberEl.PathName));
  1188. break;
  1189. end;
  1190. end;
  1191. end;
  1192. end;
  1193. if not DidAutolink then
  1194. AddLabel(FPEl);
  1195. end else
  1196. AddLabel(FPEl);
  1197. end;
  1198. end;
  1199. end;
  1200. AddList(AModule, InterfaceSection.Functions);
  1201. AddList(AModule, InterfaceSection.Variables);
  1202. end;
  1203. end;
  1204. var
  1205. i: Integer;
  1206. begin
  1207. inherited ;
  1208. FDupLinkedDoc := False; // by default we don't duplicate linked element documentation
  1209. { Allocate labels for all elements for which we are going to create
  1210. documentation. This is needed for links to work correctly. }
  1211. // Allocate label for the package itself, if a name is given (i.e. <> '#')
  1212. if Length(Package.Name) > 1 then
  1213. begin
  1214. AddLabel(Package);
  1215. AddTopicPages(Package);
  1216. end;
  1217. for i := 0 to Package.Modules.Count - 1 do
  1218. ScanModule(TPasModule(Package.Modules[i]));
  1219. end;
  1220. procedure TLinearWriter.WriteBeginDocument;
  1221. begin
  1222. WriteComment('This file has been created automatically by FPDoc.');
  1223. WriteComment('Linear output (c) 2005 Michael Van Canneyt');
  1224. end;
  1225. procedure TLinearWriter.WriteEndDocument;
  1226. begin
  1227. // do nothing
  1228. end;
  1229. function TLinearWriter.InterpretOption(const Cmd: String; const Arg: String): Boolean;
  1230. begin
  1231. Result := True;
  1232. if Cmd = cDupLinkedDocParam then
  1233. begin
  1234. FDupLinkedDoc := True;
  1235. end
  1236. else
  1237. Result := False;
  1238. end;
  1239. class procedure TLinearWriter.Usage(List: TStrings);
  1240. begin
  1241. List.Add(cDupLinkedDocParam);
  1242. List.Add(SLinearUsageDupLinkedDocsP1);
  1243. List.Add('');
  1244. List.Add(SLinearUsageDupLinkedDocsP2);
  1245. end;
  1246. end.