dwlinear.pp 36 KB

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