dwlinear.pp 36 KB

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