dwlinear.pp 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404
  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. if Assigned(DocNode) and assigned(DocNode.Notes) then
  784. ConvertNotes(TypeDecl,DocNode.Notes);
  785. DescrEndParagraph;
  786. end;
  787. end;
  788. end;
  789. procedure TLinearWriter.WriteVars(ASection: TPasSection);
  790. var
  791. VarDecl: TPasVariable;
  792. i: Integer;
  793. DocNode : TDocNode;
  794. begin
  795. if ASection.Variables.Count > 0 then
  796. begin
  797. StartSubsection(SDocVariables,ModuleName+'Variables');
  798. for i := 0 to ASection.Variables.Count - 1 do
  799. begin
  800. DescrBeginParaGraph;
  801. VarDecl := TPasVariable(ASection.Variables[i]);
  802. WriteVariableDecl(VarDecl);
  803. StartListing(False,'');
  804. WriteLn(EscapeText(VarDecl.GetDeclaration(True)));
  805. EndListing;
  806. WriteLabel(VarDecl);
  807. WriteIndex(VarDecl);
  808. DocNode:=WriteDescr(VarDecl);
  809. If Assigned(DocNode) and Assigned(DocNode.Version) then
  810. begin
  811. Writeln(Format('%s : ',[SDocVersion]));
  812. WriteDescr(VarDecl, DocNode.Version);
  813. ConvertNotes(VarDecl,DocNode.Notes);
  814. end;
  815. DescrEndParaGraph;
  816. end;
  817. end;
  818. end;
  819. procedure TLinearWriter.WriteProcedure(ProcDecl : TPasProcedureBase);
  820. var
  821. DocNode: TDocNode;
  822. OP : TPasOverloadedProc;
  823. i : integer;
  824. begin
  825. With ProcDecl do
  826. begin
  827. if Not (Assigned(Parent) and Parent.InheritsFrom(TPasClassType)) then
  828. begin
  829. StartSubSection(Name);
  830. WriteLabel(ProcDecl);
  831. WriteIndex(ProcDecl);
  832. end
  833. else
  834. begin // Parent assigned and hence method.
  835. StartSubSection(Parent.Name+'.'+Name);
  836. WriteLabel(ProcDecl);
  837. WriteIndex(Parent.Name+'.'+Name);
  838. end;
  839. StartProcedure;
  840. DocNode := Engine.FindDocNode(ProcDecl);
  841. if Assigned(DocNode) and Assigned(DocNode.ShortDescr) then
  842. begin
  843. StartSynopsis;
  844. WriteDescr(ProcDecl, DocNode.ShortDescr);
  845. end;
  846. StartDeclaration;
  847. StartListing(False);
  848. if ClassType = TPasOverloadedProc then
  849. begin
  850. OP:=TPasOverloadedProc(ProcDecl);
  851. for i := 0 to OP.Overloads.Count - 1 do
  852. begin
  853. WriteLn(TPasProcedure(OP.Overloads[i]).GetDeclaration(True));
  854. end;
  855. end
  856. else
  857. WriteLn(GetDeclaration(True));
  858. EndListing;
  859. If Assigned(Parent) then
  860. begin
  861. StartVisibility;
  862. Writeln(VisibilityNames[Visibility])
  863. end;
  864. if Assigned(DocNode) then
  865. begin
  866. If Assigned(DocNode.Descr) then
  867. begin
  868. StartDescription;
  869. WriteDescr(ProcDecl);
  870. end;
  871. if Assigned(DocNode.ErrorsDoc) and (DocNode.ErrorsDoc.HasChildNodes) then
  872. begin
  873. StartErrors;
  874. WriteDescr(ProcDecl, DocNode.ErrorsDoc);
  875. end;
  876. if Assigned(DocNode.Version) then
  877. begin
  878. StartVersion;
  879. WriteDescr(ProcDecl, DocNode.Version);
  880. end;
  881. WriteSeeAlso(DocNode);
  882. EndProcedure;
  883. WriteExample(DocNode);
  884. ConvertNotes(ProcDecl,DocNode.Notes);
  885. end
  886. else
  887. EndProcedure;
  888. end;
  889. end;
  890. procedure TLinearWriter.WriteFunctionsAndProcedures(ASection: TPasSection);
  891. var
  892. i: Integer;
  893. begin
  894. if ASection.Functions.Count > 0 then
  895. begin
  896. StartSection(SDocProceduresAndFunctions,ModuleName+'Functions');
  897. for i := 0 to ASection.Functions.Count - 1 do
  898. WriteProcedure(TPasProcedureBase(ASection.Functions[i]));
  899. end;
  900. end;
  901. procedure TLinearWriter.WriteExample(ADocNode: TDocNode);
  902. var
  903. Example: TDOMElement;
  904. S : string;
  905. begin
  906. S:='';
  907. if Assigned(ADocNode) then
  908. begin
  909. Example := ADocNode.FirstExample;
  910. while Assigned(Example) do
  911. begin
  912. if IsExampleNode(Example) then
  913. begin
  914. if (S<>'') then // not first example, start new paragraph
  915. DescrBeginParagraph;
  916. s:=Engine.GetExampleFileName(Example);
  917. if (S<>'') then
  918. WriteExampleFile(S);
  919. if Assigned(Example.NextSibling) then
  920. DescrEndParaGraph;
  921. end;
  922. Example := TDomElement(Example.NextSibling);
  923. end;
  924. end;
  925. end;
  926. procedure TLinearWriter.WriteProperty(PropDecl : TPasProperty);
  927. var
  928. DocNode: TDocNode;
  929. S: String;
  930. lNode: TDocNode;
  931. begin
  932. With PropDecl do
  933. begin
  934. StartSubSection(Parent.Name+'.'+Name);
  935. WriteLabel(PropDecl);
  936. WriteIndex(Parent.Name+'.'+Name);
  937. StartProperty;
  938. DocNode := Engine.FindDocNode(PropDecl);
  939. if Assigned(DocNode) then
  940. begin
  941. if FDupLinkedDoc and (DocNode.Link <> '') then
  942. begin
  943. lNode := Engine.FindLinkedNode(DocNode);
  944. if not Assigned(lNode) then
  945. lNode := DocNode;
  946. end
  947. else
  948. lNode := DocNode;
  949. if Assigned(lNode.ShortDescr) then
  950. begin
  951. StartSynopsis;
  952. WriteDescr(PropDecl, lNode.ShortDescr);
  953. end;
  954. end;
  955. StartDeclaration;
  956. StartListing(False);
  957. WriteLn('Property '+GetDeclaration(True));
  958. EndListing;
  959. If Assigned(Parent) then
  960. begin
  961. StartVisibility;
  962. Writeln(VisibilityNames[Visibility])
  963. end;
  964. StartAccess;
  965. Setlength(S,0);
  966. If Length(ReadAccessorName) > 0 then
  967. S:='Read';
  968. if Length(WriteAccessorName) > 0 then
  969. begin
  970. If S<>'' then
  971. S:=S+',';
  972. S:=S+'Write';
  973. end;
  974. Writeln(S);
  975. if Assigned(DocNode) then
  976. begin
  977. if Assigned(lNode.Descr) then // lNode will be assigned if DocNode exists
  978. begin
  979. StartDescription;
  980. WriteDescr(PropDecl, lNode);
  981. end;
  982. if Assigned(lNode.ErrorsDoc) and (lNode.ErrorsDoc.HasChildNodes) then
  983. begin
  984. StartErrors;
  985. WriteDescr(PropDecl, DocNode.ErrorsDoc);
  986. end;
  987. if Assigned(lNode.Version) then
  988. begin
  989. StartVersion;
  990. WriteDescr(PropDecl, lNode.Version);
  991. end;
  992. WriteSeeAlso(lNode);
  993. ConvertNotes(PropDecl,lNode.Notes);
  994. EndProperty;
  995. WriteExample(lNode);
  996. end
  997. else
  998. EndProperty;
  999. end;
  1000. end;
  1001. procedure TLinearWriter.WriteSeeAlso(ADocNode: TDocNode);
  1002. var
  1003. Node: TDOMNode;
  1004. s: String;
  1005. First : Boolean;
  1006. begin
  1007. if Not (Assigned(ADocNode) and Assigned(ADocNode.SeeAlso)) then
  1008. Exit;
  1009. Node := ADocNode.SeeAlso.FirstChild;
  1010. First:=True;
  1011. while Assigned(Node) do
  1012. begin
  1013. if IsLinkNode(Node) then
  1014. begin
  1015. If First then
  1016. begin
  1017. StartSeealso;
  1018. First:=False;
  1019. end
  1020. else
  1021. Writeln(',');
  1022. S:=TDomElement(Node)['id'];
  1023. DescrBeginLink(S);
  1024. if Node.FirstChild <> nil then
  1025. s := Node.FirstChild.NodeValue;
  1026. Write(EscapeText(S));
  1027. DescrEndLink();
  1028. end;
  1029. Node:=Node.NextSibling;
  1030. end;
  1031. If Not First then
  1032. EndSeeAlso
  1033. end;
  1034. Function CompareElements(P1,P2 : Pointer) : Integer;
  1035. begin
  1036. Result:=CompareText(TPasElement(P1).Name,TPasElement(P2).Name);
  1037. end;
  1038. procedure TLinearWriter.SortElementList(List : TFPList);
  1039. begin
  1040. List.Sort(@CompareElements);
  1041. end;
  1042. Function TLinearWriter.ShowMember(M : TPasElement) : boolean;
  1043. begin
  1044. Result:=not ((M.Visibility=visPrivate) and Engine.HidePrivate);
  1045. If Result then
  1046. Result:=Not ((M.Visibility=visProtected) and Engine.HideProtected)
  1047. end;
  1048. procedure TLinearWriter.WriteClasses(ASection: TPasSection);
  1049. var
  1050. i: Integer;
  1051. begin
  1052. if (ASection.Classes.Count > 0) then
  1053. for i := 0 to ASection.Classes.Count - 1 do
  1054. WriteClassDecl(TPasClassType(ASection.Classes[i]));
  1055. end;
  1056. procedure TLinearWriter.WriteClassMethodOverview(ClassDecl: TPasClassType);
  1057. var
  1058. Member : TPasElement;
  1059. i : Integer;
  1060. L,N,S : String;
  1061. DocNode : TDocNode;
  1062. List : TStringList;
  1063. begin
  1064. List:=TStringList.Create;
  1065. Try
  1066. List.Sorted:=True;
  1067. for i := 0 to ClassDecl.Members.Count - 1 do
  1068. begin
  1069. Member := TPasElement(ClassDecl.Members[i]);
  1070. With Member do
  1071. if InheritsFrom(TPasProcedureBase) and ShowMember(Member) then
  1072. List.AddObject(Member.Name,Member);
  1073. end;
  1074. If List.Count>0 then
  1075. begin
  1076. StartSubSection(SDocMethodOverview);
  1077. WriteLabel(GetLabel(ClassDecl) + ':Methods');
  1078. StartOverview(False);
  1079. For I:=0 to List.Count-1 do
  1080. begin
  1081. Member:=TPasElement(List.Objects[i]);
  1082. L:=StripText(GetLabel(Member));
  1083. N:=EscapeText(Member.Name);
  1084. DocNode := Engine.FindDocNode(Member);
  1085. If Assigned(DocNode) then
  1086. S:=GetDescrString(Member, DocNode.ShortDescr)
  1087. else
  1088. S:='';
  1089. WriteOverviewMember(L,N,S);
  1090. end;
  1091. EndOverview;
  1092. end;
  1093. Finally
  1094. List.Free;
  1095. end;
  1096. end;
  1097. constructor TLinearWriter.Create(APackage: TPasPackage; AEngine: TFPDocEngine);
  1098. procedure AddLabel(AElement: TPasElement);
  1099. begin
  1100. Engine.AddLink(AElement.PathName, GetLabel(AElement));
  1101. end;
  1102. procedure AddList(AElement: TPasElement; AList: TFPList);
  1103. var
  1104. i: Integer;
  1105. begin
  1106. for i := 0 to AList.Count - 1 do
  1107. AddLabel(TPasElement(AList[i]));
  1108. end;
  1109. procedure AddTopicPages(AElement: TPasElement);
  1110. var
  1111. PreviousTopic,
  1112. TopicElement : TTopicElement;
  1113. DocNode,
  1114. TopicNode : TDocNode;
  1115. begin
  1116. DocNode:=Engine.FindDocNode(AElement);
  1117. If not Assigned(DocNode) then
  1118. exit;
  1119. TopicNode:=DocNode.FirstChild;
  1120. PreviousTopic:=Nil;
  1121. While Assigned(TopicNode) do
  1122. begin
  1123. If TopicNode.TopicNode then
  1124. begin
  1125. TopicElement:=TTopicElement.Create(TopicNode.Name,AElement);
  1126. Topics.Add(TopicElement);
  1127. TopicElement.TopicNode:=TopicNode;
  1128. TopicElement.Previous:=PreviousTopic;
  1129. If Assigned(PreviousTopic) then
  1130. PreviousTopic.Next:=TopicElement;
  1131. PreviousTopic:=TopicElement;
  1132. if AElement is TTopicElement then
  1133. TTopicElement(AElement).SubTopics.Add(TopicElement);
  1134. Engine.AddLink(TopicElement.PathName, GetLabel(TopicElement));
  1135. if AElement is TTopicElement then
  1136. TTopicElement(AElement).SubTopics.Add(TopicElement)
  1137. else // Only one level of recursion.
  1138. AddTopicPages(TopicElement);
  1139. end;
  1140. TopicNode:=TopicNode.NextSibling;
  1141. end;
  1142. end;
  1143. procedure ScanModule(AModule: TPasModule);
  1144. var
  1145. i, j, k: Integer;
  1146. ClassEl: TPasClassType;
  1147. FPEl, AncestorMemberEl: TPasElement;
  1148. DocNode: TDocNode;
  1149. DidAutolink: Boolean;
  1150. begin
  1151. AddLabel(AModule);
  1152. AddTopicPages(AModule);
  1153. with AModule do
  1154. begin
  1155. AddList(AModule, InterfaceSection.ResStrings);
  1156. AddList(AModule, InterfaceSection.Consts);
  1157. AddList(AModule, InterfaceSection.Types);
  1158. if InterfaceSection.Classes.Count > 0 then
  1159. begin
  1160. for i := 0 to InterfaceSection.Classes.Count - 1 do
  1161. begin
  1162. ClassEl := TPasClassType(InterfaceSection.Classes[i]);
  1163. AddLabel(ClassEl);
  1164. for j := 0 to ClassEl.Members.Count - 1 do
  1165. begin
  1166. FPEl := TPasElement(ClassEl.Members[j]);
  1167. if ((FPEl.Visibility = visPrivate) and Engine.HidePrivate) or
  1168. ((FPEl.Visibility = visProtected) and Engine.HideProtected) then
  1169. continue;
  1170. DocNode := Engine.FindDocNode(FPEl);
  1171. if not Assigned(DocNode) then
  1172. begin
  1173. DidAutolink := False;
  1174. if Assigned(ClassEl.AncestorType) and
  1175. (ClassEl.AncestorType.ClassType = TPasClassType) then
  1176. begin
  1177. for k := 0 to TPasClassType(ClassEl.AncestorType).Members.Count - 1 do
  1178. begin
  1179. AncestorMemberEl :=
  1180. TPasElement(TPasClassType(ClassEl.AncestorType).Members[k]);
  1181. if AncestorMemberEl.Name = FPEl.Name then
  1182. begin
  1183. DocNode := Engine.FindDocNode(AncestorMemberEl);
  1184. if Assigned(DocNode) then
  1185. begin
  1186. DidAutolink := True;
  1187. Engine.AddLink(FPEl.PathName,
  1188. Engine.FindAbsoluteLink(AncestorMemberEl.PathName));
  1189. break;
  1190. end;
  1191. end;
  1192. end;
  1193. end;
  1194. if not DidAutolink then
  1195. AddLabel(FPEl);
  1196. end else
  1197. AddLabel(FPEl);
  1198. end;
  1199. end;
  1200. end;
  1201. AddList(AModule, InterfaceSection.Functions);
  1202. AddList(AModule, InterfaceSection.Variables);
  1203. end;
  1204. end;
  1205. var
  1206. i: Integer;
  1207. begin
  1208. inherited ;
  1209. FDupLinkedDoc := False; // by default we don't duplicate linked element documentation
  1210. { Allocate labels for all elements for which we are going to create
  1211. documentation. This is needed for links to work correctly. }
  1212. // Allocate label for the package itself, if a name is given (i.e. <> '#')
  1213. if Length(Package.Name) > 1 then
  1214. begin
  1215. AddLabel(Package);
  1216. AddTopicPages(Package);
  1217. end;
  1218. for i := 0 to Package.Modules.Count - 1 do
  1219. ScanModule(TPasModule(Package.Modules[i]));
  1220. end;
  1221. procedure TLinearWriter.WriteBeginDocument;
  1222. begin
  1223. WriteComment('This file has been created automatically by FPDoc.');
  1224. WriteComment('Linear output (c) 2005 Michael Van Canneyt');
  1225. end;
  1226. procedure TLinearWriter.WriteEndDocument;
  1227. begin
  1228. // do nothing
  1229. end;
  1230. function TLinearWriter.InterpretOption(const Cmd: String; const Arg: String): Boolean;
  1231. begin
  1232. Result := True;
  1233. if Cmd = cDupLinkedDocParam then
  1234. begin
  1235. FDupLinkedDoc := True;
  1236. end
  1237. else
  1238. Result := False;
  1239. end;
  1240. class procedure TLinearWriter.Usage(List: TStrings);
  1241. begin
  1242. List.Add(cDupLinkedDocParam);
  1243. List.Add(SLinearUsageDupLinkedDocsP1);
  1244. List.Add('');
  1245. List.Add(SLinearUsageDupLinkedDocsP2);
  1246. end;
  1247. end.