dglobals.pp 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291
  1. {
  2. FPDoc - Free Pascal Documentation Tool
  3. Copyright (C) 2000 - 2002 by
  4. Areca Systems GmbH / Sebastian Guenther, [email protected]
  5. * Global declarations
  6. * Link list management
  7. * Document node tree
  8. * Main engine
  9. See the file COPYING, included in this distribution,
  10. for details about the copyright.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. }
  15. {$MODE objfpc}
  16. {$H+}
  17. unit dGlobals;
  18. interface
  19. uses Classes, DOM, PasTree, PParser;
  20. Var
  21. LEOL : Integer;
  22. modir : string;
  23. resourcestring
  24. // Output strings
  25. SDocPackageTitle = 'Reference for package ''%s''';
  26. SDocPrograms = 'Programs';
  27. SDocUnits = 'Units';
  28. SDocUnitTitle = 'Reference for unit ''%s''';
  29. SDocInterfaceSection = 'Interface section';
  30. SDocImplementationSection = 'Implementation section';
  31. SDocUsedUnits = 'Used units';
  32. SDocUsedUnitsByUnitXY = 'Used units by unit ''%s''';
  33. SDocConstsTypesVars = 'Constants, types and variables';
  34. SDocResStrings = 'Resource strings';
  35. SDocTypes = 'Types';
  36. SDocConstants = 'Constants';
  37. SDocClasses = 'Classes';
  38. SDocProceduresAndFunctions = 'Procedures and functions';
  39. SDocVariables = 'Variables';
  40. SDocUnitOverview = 'Overview of unit ''%s''';
  41. SDocOverview = 'Overview';
  42. SDocSearch = 'Search';
  43. SDocDeclaration = 'Declaration';
  44. SDocDescription = 'Description';
  45. SDocErrors = 'Errors';
  46. SDocSeeAlso = 'See also';
  47. SDocExample = 'Example';
  48. SDocArguments = 'Arguments';
  49. SDocFunctionResult = 'Function result';
  50. SDocRemark = 'Remark: ';
  51. SDocMethodOverview = 'Method overview';
  52. SDocPropertyOverview = 'Property overview';
  53. SDocPage = 'Page';
  54. SDocMethod = 'Method';
  55. SDocProperty = 'Property';
  56. SDocAccess = 'Access';
  57. SDocInheritance = 'Inheritance';
  58. SDocProperties = 'Properties';
  59. SDocMethods = 'Methods';
  60. SDocEvents = 'Events';
  61. SDocByName = 'by Name';
  62. SDocValue = 'Value';
  63. SDocExplanation = 'Explanation';
  64. SDocProcedure = 'Procedure';
  65. SDocValuesForEnum = 'Enumeration values for type %s';
  66. SDocSourcePosition = 'Source position: %s line %d';
  67. SDocSynopsis = 'Synopsis';
  68. SDocVisibility = 'Visibility';
  69. SDocOpaque = 'Opaque type';
  70. SDocDateGenerated = 'Documentation generated on: %s';
  71. // Topics
  72. SDocRelatedTopics = 'Related topics';
  73. SDocUp = 'Up';
  74. SDocNext = 'Next';
  75. SDocPrevious = 'Previous';
  76. // Various backend constants
  77. SDocChapter = 'Chapter';
  78. SDocSection = 'Section';
  79. SDocSubSection = 'Subsection';
  80. SDocTable = 'Table';
  81. SDocListing = 'Listing';
  82. // Man page usage
  83. SManUsageManSection = 'Use ASection as the man page section';
  84. SManUsageNoUnitPrefix = 'Do not prefix man pages with unit name.';
  85. SManUsageWriterDescr = 'UNIX man page output.';
  86. SManUsagePackageDescription = 'Use descr as the description of man pages';
  87. // HTML usage
  88. SHTMLUsageFooter = 'Append xhtml from file as footer to html page';
  89. SHTMLUsageFooterDate = 'Append footer with date. fmt is Optional format for FormatDateTime';
  90. // CHM usage
  91. SCHMUsageTOC = 'Use [File] as the table of contents. Usually a .hhc file.';
  92. SCHMUsageIndex = 'Use [File] as the index. Usually a .hhk file.';
  93. SCHMUsageDefPage = 'Set the "Home" page relative to where it lives in the chm. i.e. "/index.html"';
  94. SCHMUsageOtrFiles= 'A txt file containing a list of files to be added relative to the working directory.';
  95. SCHMUsageCSSFile = 'Filename of a .css file to be included in the chm.';
  96. SCHMUsageAutoTOC = 'Automatically generate a Table of Contents. Ignores --toc-file';
  97. SCHMUsageAutoIDX = 'Automatically generate an Index. Ignores --index-file';
  98. STitle = 'FPDoc - Free Pascal Documentation Tool';
  99. SVersion = 'Version %s [%s]';
  100. SCopyright = '(c) 2000 - 2003 Areca Systems GmbH / Sebastian Guenther, [email protected]';
  101. SCmdLineHelp = 'Usage: %s [options]';
  102. SUsageOption010 = '--content Create content file for package cross-references';
  103. SUsageOption020 = '--cputarget=value Set the target CPU for the scanner.';
  104. SUsageOption030 = '--descr=name use name as description file. ';
  105. SUsageOption040 = ' This option is allowed more than once';
  106. SUsageOption050 = '--format=fmt Select output format.';
  107. SUsageOption060 = '--help Show this help.';
  108. SUsageOption070 = '--hide-protected Do not show protected methods in overview';
  109. SUsageOption080 = '--import=file Import content file for package cross-references';
  110. SUsageOption090 = '--input=cmd use cmd as input for the parser.';
  111. SUsageOption100 = ' At least one input option is required.';
  112. SUsageOption110 = '--lang=lng Select output language.';
  113. SUsageOption120 = '--ostarget=value Set the target OS for the scanner.';
  114. SUsageOption130 = '--output=name use name as the output name.';
  115. SUsageOption140 = ' Each backend interpretes this as needed.';
  116. SUsageOption150 = '--package=name Set the package name for which to create output';
  117. SUsageOption160 = '--show-private Show private methods.';
  118. SUsageOption170 = '--warn-no-node Warn if no documentation node was found.';
  119. SUsageOption180 = '--mo-dir=dir Set directory where language files reside to dir';
  120. SUsageFormats = 'The following output formats are supported by this fpdoc:';
  121. SUsageBackendHelp = 'Specify an output format, combined with --help to get more help for this backend.';
  122. SUsageFormatSpecific = 'Output format "%s" supports the following options:';
  123. SCmdLineInvalidOption = 'Ignoring unknown option "%s"';
  124. SCmdLineInvalidFormat = 'Invalid format "%s" specified';
  125. SCmdLineOutputOptionMissing = 'Need an output filename, please specify one with --output=<filename>';
  126. SWritingPages = 'Writing %d pages...';
  127. SNeedPackageName = 'No package name specified. Please specify one using the --package option.';
  128. SDone = 'Done.';
  129. SErrCouldNotCreateOutputDir = 'Could not create output directory "%s"';
  130. SErrCouldNotCreateFile = 'Could not create file "%s": %s';
  131. Const
  132. SVisibility: array[TPasMemberVisibility] of string =
  133. ('Default', 'Private', 'Protected', 'Public',
  134. 'Published', 'Automated');
  135. type
  136. // Assumes a list of TObject instances and frees them on destruction
  137. TObjectList = class(TList)
  138. public
  139. destructor Destroy; override;
  140. end;
  141. { Link entry tree
  142. TFPDocEngine stores the root of the entry tree in its property
  143. "RootLinkNode". The root has one child node for each package, for which
  144. documentation links are available. The children of a package node
  145. are module nodes; and the children of a module node are the top-level
  146. declarations of this module; the next level in the tree stores e.g. record
  147. members, and so on...
  148. }
  149. TLinkNode = class
  150. private
  151. FFirstChild, FNextSibling: TLinkNode;
  152. FName: String;
  153. FLink: String;
  154. public
  155. constructor Create(const AName, ALink: String);
  156. destructor Destroy; override;
  157. function FindChild(const APathName: String): TLinkNode;
  158. function CreateChildren(const APathName, ALinkTo: String): TLinkNode;
  159. // Properties for tree structure
  160. property FirstChild: TLinkNode read FFirstChild;
  161. property NextSibling: TLinkNode read FNextSibling;
  162. // Link properties
  163. property Name: String read FName;
  164. property Link: String read FLink;
  165. end;
  166. { Documentation entry tree
  167. TFPDocEngine stores the root of the entry tree in its property
  168. "RootDocNode". The root has one child node for each package, for which
  169. documentation is being provided by the user. The children of a package node
  170. are module nodes; and the children of a module node are the top-level
  171. declarations of this module; the next level in the tree stores e.g. record
  172. members, and so on...
  173. }
  174. TDocNode = class
  175. private
  176. FFirstChild, FNextSibling: TDocNode;
  177. FName: String;
  178. FNode: TDOMElement;
  179. FIsSkipped: Boolean;
  180. FShortDescr: TDOMElement;
  181. FDescr: TDOMElement;
  182. FErrorsDoc: TDOMElement;
  183. FSeeAlso: TDOMElement;
  184. FFirstExample: TDOMElement;
  185. FLink: String;
  186. FTopicNode : Boolean;
  187. FRefCount : Integer;
  188. public
  189. constructor Create(const AName: String; ANode: TDOMElement);
  190. destructor Destroy; override;
  191. Function IncRefcount : Integer;
  192. function FindChild(const APathName: String): TDocNode;
  193. function CreateChildren(const APathName: String): TDocNode;
  194. // Properties for tree structure
  195. property FirstChild: TDocNode read FFirstChild;
  196. property NextSibling: TDocNode read FNextSibling;
  197. // Basic properties
  198. property Name: String read FName;
  199. property Node: TDOMElement read FNode;
  200. // Data fetched from the XML document
  201. property IsSkipped: Boolean read FIsSkipped;
  202. property ShortDescr: TDOMElement read FShortDescr;
  203. property Descr: TDOMElement read FDescr;
  204. property ErrorsDoc: TDOMElement read FErrorsDoc;
  205. property SeeAlso: TDOMElement read FSeeAlso;
  206. property FirstExample: TDOMElement read FFirstExample;
  207. property Link: String read FLink;
  208. Property TopicNode : Boolean Read FTopicNode;
  209. Property RefCount : Integer Read FRefCount;
  210. end;
  211. // The main FPDoc engine
  212. TFPDocEngine = class(TPasTreeContainer)
  213. protected
  214. DescrDocs: TObjectList; // List of XML documents
  215. DescrDocNames: TStringList; // Names of the XML documents
  216. FRootLinkNode: TLinkNode;
  217. FRootDocNode: TDocNode;
  218. FPackages: TList; // List of TFPPackage objects
  219. CurModule: TPasModule;
  220. CurPackageDocNode: TDocNode;
  221. public
  222. constructor Create;
  223. destructor Destroy; override;
  224. procedure SetPackageName(const APackageName: String);
  225. procedure ReadContentFile(const AFilename, ALinkPrefix: String);
  226. procedure WriteContentFile(const AFilename: String);
  227. function CreateElement(AClass: TPTreeElement; const AName: String;
  228. AParent: TPasElement; AVisibility: TPasMemberVisibility;
  229. const ASourceFilename: String; ASourceLinenumber: Integer): TPasElement;
  230. override;
  231. function FindElement(const AName: String): TPasElement; override;
  232. function FindModule(const AName: String): TPasModule; override;
  233. // Link tree support
  234. procedure AddLink(const APathName, ALinkTo: String);
  235. function FindAbsoluteLink(const AName: String): String;
  236. function ResolveLink(AModule: TPasModule; const ALinkDest: String): String;
  237. // Documentation file support
  238. procedure AddDocFile(const AFilename: String);
  239. // Documentation retrieval
  240. function FindDocNode(AElement: TPasElement): TDocNode;
  241. function FindDocNode(ARefModule: TPasModule; const AName: String): TDocNode;
  242. function FindShortDescr(AElement: TPasElement): TDOMElement;
  243. function FindShortDescr(ARefModule: TPasModule;
  244. const AName: String): TDOMElement;
  245. function GetExampleFilename(const ExElement: TDOMElement): String;
  246. property RootLinkNode: TLinkNode read FRootLinkNode;
  247. property RootDocNode: TDocNode read FRootDocNode;
  248. property Package: TPasPackage read FPackage;
  249. Output: String;
  250. HasContentFile: Boolean;
  251. HidePrivate: Boolean; // Hide private class members in output?
  252. HideProtected: Boolean; // Hide protected class members in output?
  253. WarnNoNode : Boolean; // Warn if no description node found for element.
  254. end;
  255. procedure TranslateDocStrings(const Lang: String);
  256. Function IsLinkNode(Node : TDomNode) : Boolean;
  257. Function IsExampleNode(Example : TDomNode) : Boolean;
  258. // returns true is link is an absolute URI
  259. Function IsLinkAbsolute(ALink: String): boolean;
  260. implementation
  261. uses SysUtils, Gettext, XMLRead;
  262. const
  263. AbsoluteLinkPrefixes : array[0..2] of string = ('/', 'http://', 'ms-its:');
  264. { TObjectList }
  265. destructor TObjectList.Destroy;
  266. var
  267. i: Integer;
  268. begin
  269. for i := 0 to Count - 1 do
  270. TObject(Items[i]).Free;
  271. inherited Destroy;
  272. end;
  273. { TLinkNode }
  274. constructor TLinkNode.Create(const AName, ALink: String);
  275. begin
  276. inherited Create;
  277. FName := AName;
  278. FLink := ALink;
  279. end;
  280. destructor TLinkNode.Destroy;
  281. begin
  282. if Assigned(FirstChild) then
  283. FirstChild.Free;
  284. if Assigned(NextSibling) then
  285. NextSibling.Free;
  286. inherited Destroy;
  287. end;
  288. function TLinkNode.FindChild(const APathName: String): TLinkNode;
  289. var
  290. DotPos: Integer;
  291. ChildName: String;
  292. Child: TLinkNode;
  293. begin
  294. if Length(APathName) = 0 then
  295. Result := Self
  296. else
  297. begin
  298. DotPos := Pos('.', APathName);
  299. if DotPos = 0 then
  300. ChildName := APathName
  301. else
  302. ChildName := Copy(APathName, 1, DotPos - 1);
  303. Child := FirstChild;
  304. while Assigned(Child) do
  305. begin
  306. if CompareText(Child.Name, ChildName) = 0 then
  307. begin
  308. if DotPos = 0 then
  309. Result := Child
  310. else
  311. Result := Child.FindChild(
  312. Copy(APathName, DotPos + 1, Length(APathName)));
  313. exit;
  314. end;
  315. Child := Child.NextSibling;
  316. end;
  317. Result := nil;
  318. end;
  319. end;
  320. function TLinkNode.CreateChildren(const APathName, ALinkTo: String): TLinkNode;
  321. var
  322. DotPos: Integer;
  323. ChildName: String;
  324. Child, LastChild: TLinkNode;
  325. begin
  326. if Length(APathName) = 0 then
  327. Result := Self
  328. else
  329. begin
  330. DotPos := Pos('.', APathName);
  331. if DotPos = 0 then
  332. ChildName := APathName
  333. else
  334. ChildName := Copy(APathName, 1, DotPos - 1);
  335. Child := FirstChild;
  336. LastChild := nil;
  337. while Assigned(Child) do
  338. begin
  339. if CompareText(Child.Name, ChildName) = 0 then
  340. begin
  341. if DotPos = 0 then
  342. Result := Child
  343. else
  344. Result := Child.CreateChildren(
  345. Copy(APathName, DotPos + 1, Length(APathName)), ALinkTo);
  346. exit;
  347. end;
  348. LastChild := Child;
  349. Child := Child.NextSibling;
  350. end;
  351. { No child found, let's create one if we are at the end of the path }
  352. if DotPos > 0 then
  353. // !!!: better throw an exception
  354. WriteLn('Link path does not exist: ', APathName);
  355. Result := TLinkNode.Create(ChildName, ALinkTo);
  356. if Assigned(LastChild) then
  357. LastChild.FNextSibling := Result
  358. else
  359. FFirstChild := Result;
  360. end;
  361. end;
  362. { TDocNode }
  363. constructor TDocNode.Create(const AName: String; ANode: TDOMElement);
  364. begin
  365. inherited Create;
  366. FName := AName;
  367. FNode := ANode;
  368. end;
  369. destructor TDocNode.Destroy;
  370. begin
  371. if Assigned(FirstChild) then
  372. FirstChild.Free;
  373. if Assigned(NextSibling) then
  374. NextSibling.Free;
  375. inherited Destroy;
  376. end;
  377. Function TDocNode.IncRefcount : Integer;
  378. begin
  379. Inc(FRefCount);
  380. Result:=FRefCount;
  381. end;
  382. function TDocNode.FindChild(const APathName: String): TDocNode;
  383. var
  384. DotPos: Integer;
  385. ChildName: String;
  386. Child: TDocNode;
  387. begin
  388. if Length(APathName) = 0 then
  389. Result := Self
  390. else
  391. begin
  392. DotPos := Pos('.', APathName);
  393. if DotPos = 0 then
  394. ChildName := APathName
  395. else
  396. ChildName := Copy(APathName, 1, DotPos - 1);
  397. Child := FirstChild;
  398. while Assigned(Child) do
  399. begin
  400. if CompareText(Child.Name, ChildName) = 0 then
  401. begin
  402. if DotPos = 0 then
  403. Result := Child
  404. else
  405. Result := Child.FindChild(
  406. Copy(APathName, DotPos + 1, Length(APathName)));
  407. exit;
  408. end;
  409. Child := Child.NextSibling;
  410. end;
  411. Result := nil;
  412. end;
  413. end;
  414. function TDocNode.CreateChildren(const APathName: String): TDocNode;
  415. var
  416. DotPos: Integer;
  417. ChildName: String;
  418. Child: TDocNode;
  419. begin
  420. if Length(APathName) = 0 then
  421. Result := Self
  422. else
  423. begin
  424. DotPos := Pos('.', APathName);
  425. if DotPos = 0 then
  426. ChildName := APathName
  427. else
  428. ChildName := Copy(APathName, 1, DotPos - 1);
  429. Child := FirstChild;
  430. while Assigned(Child) do
  431. begin
  432. if CompareText(Child.Name, ChildName) = 0 then
  433. begin
  434. if DotPos = 0 then
  435. Result := Child
  436. else
  437. Result := Child.CreateChildren(
  438. Copy(APathName, DotPos + 1, Length(APathName)));
  439. exit;
  440. end;
  441. Child := Child.NextSibling;
  442. end;
  443. // No child found, let's create one
  444. Result := TDocNode.Create(ChildName, nil);
  445. if Assigned(FirstChild) then
  446. begin
  447. Result.FNextSibling := FirstChild;
  448. FFirstChild := Result;
  449. end else
  450. FFirstChild := Result;
  451. if DotPos > 0 then
  452. Result := Result.CreateChildren(
  453. Copy(APathName, DotPos + 1, Length(APathName)));
  454. end;
  455. end;
  456. { TFPDocEngine }
  457. constructor TFPDocEngine.Create;
  458. begin
  459. inherited Create;
  460. DescrDocs := TObjectList.Create;
  461. DescrDocNames := TStringList.Create;
  462. FRootLinkNode := TLinkNode.Create('', '');
  463. FRootDocNode := TDocNode.Create('', nil);
  464. HidePrivate := True;
  465. FPackages := TList.Create;
  466. end;
  467. destructor TFPDocEngine.Destroy;
  468. var
  469. i: Integer;
  470. begin
  471. for i := 0 to FPackages.Count - 1 do
  472. TPasPackage(FPackages[i]).Release;
  473. FPackages.Free;
  474. FRootDocNode.Free;
  475. FRootLinkNode.Free;
  476. DescrDocNames.Free;
  477. DescrDocs.Free;
  478. inherited Destroy;
  479. end;
  480. procedure TFPDocEngine.SetPackageName(const APackageName: String);
  481. begin
  482. ASSERT(not Assigned(Package));
  483. FPackage := TPasPackage(inherited CreateElement(TPasPackage,
  484. '#' + APackageName, nil, '', 0));
  485. FPackages.Add(FPackage);
  486. CurPackageDocNode := RootDocNode.FindChild('#' + APackageName);
  487. If Assigned(CurPackageDocNode) then
  488. CurPackageDocNode.IncRefCount;
  489. end;
  490. procedure TFPDocEngine.ReadContentFile(const AFilename, ALinkPrefix: String);
  491. var
  492. f: Text;
  493. procedure ReadLinkTree;
  494. var
  495. s: String;
  496. PrevSpaces, ThisSpaces, i, StackIndex: Integer;
  497. CurParent, PrevSibling, NewNode: TLinkNode;
  498. ParentStack, SiblingStack: array[0..7] of TLinkNode;
  499. begin
  500. PrevSpaces := 0;
  501. CurParent := RootLinkNode;
  502. PrevSibling := CurParent.FirstChild;
  503. if assigned(PrevSibling) then
  504. while assigned(PrevSibling.NextSibling) do
  505. PrevSibling := PrevSibling.NextSibling;
  506. StackIndex := 0;
  507. while True do
  508. begin
  509. ReadLn(f, s);
  510. if Length(s) = 0 then
  511. break;
  512. ThisSpaces := 0;
  513. while s[ThisSpaces + 1] = ' ' do
  514. Inc(ThisSpaces);
  515. if ThisSpaces <> PrevSpaces then
  516. begin
  517. if ThisSpaces > PrevSpaces then
  518. begin
  519. { Dive down one level }
  520. ParentStack[StackIndex] := CurParent;
  521. SiblingStack[StackIndex] := PrevSibling;
  522. Inc(StackIndex);
  523. CurParent := PrevSibling;
  524. PrevSibling := nil;
  525. end else
  526. while PrevSpaces > ThisSpaces do
  527. begin
  528. Dec(StackIndex);
  529. CurParent := ParentStack[StackIndex];
  530. PrevSibling := SiblingStack[StackIndex];
  531. Dec(PrevSpaces);
  532. end;
  533. PrevSpaces := ThisSpaces;
  534. end;
  535. i := ThisSpaces + 1;
  536. while s[i] <> ' ' do
  537. Inc(i);
  538. NewNode := TLinkNode.Create(Copy(s, ThisSpaces + 1, i - ThisSpaces - 1),
  539. ALinkPrefix + Copy(s, i + 1, Length(s)));
  540. if Assigned(PrevSibling) then
  541. PrevSibling.FNextSibling := NewNode
  542. else
  543. CurParent.FFirstChild := NewNode;
  544. PrevSibling := NewNode;
  545. end;
  546. end;
  547. procedure ReadClasses;
  548. function CreateClass(const AName: String): TPasClassType;
  549. var
  550. DotPos, DotPos2, i: Integer;
  551. s: String;
  552. HPackage: TPasPackage;
  553. Module: TPasModule;
  554. begin
  555. // Find or create package
  556. DotPos := Pos('.', AName);
  557. s := Copy(AName, 1, DotPos - 1);
  558. HPackage := nil;
  559. for i := 0 to FPackages.Count - 1 do
  560. if CompareText(TPasPackage(FPackages[i]).Name, s) = 0 then
  561. begin
  562. HPackage := TPasPackage(FPackages[i]);
  563. break;
  564. end;
  565. if not Assigned(HPackage) then
  566. begin
  567. HPackage := TPasPackage(inherited CreateElement(TPasPackage, s, nil,
  568. '', 0));
  569. FPackages.Add(HPackage);
  570. end;
  571. // Find or create module
  572. DotPos2 := DotPos;
  573. repeat
  574. Inc(DotPos2);
  575. until AName[DotPos2] = '.';
  576. s := Copy(AName, DotPos + 1, DotPos2 - DotPos - 1);
  577. Module := nil;
  578. for i := 0 to HPackage.Modules.Count - 1 do
  579. if CompareText(TPasModule(HPackage.Modules[i]).Name, s) = 0 then
  580. begin
  581. Module := TPasModule(HPackage.Modules[i]);
  582. break;
  583. end;
  584. if not Assigned(Module) then
  585. begin
  586. Module := TPasModule.Create(s, HPackage);
  587. Module.InterfaceSection := TPasSection.Create('', Module);
  588. HPackage.Modules.Add(Module);
  589. end;
  590. // Create node for class
  591. Result := TPasClassType.Create(Copy(AName, DotPos2 + 1, Length(AName)),
  592. Module.InterfaceSection);
  593. Result.ObjKind := okClass;
  594. Module.InterfaceSection.Declarations.Add(Result);
  595. Module.InterfaceSection.Classes.Add(Result);
  596. end;
  597. var
  598. s, Name: String;
  599. CurClass: TPasClassType;
  600. i: Integer;
  601. Member: TPasElement;
  602. begin
  603. CurClass := nil;
  604. while True do
  605. begin
  606. ReadLn(f, s);
  607. if Length(s) = 0 then
  608. break;
  609. if s[1] = '#' then
  610. begin
  611. // New class
  612. i := Pos(' ', s);
  613. CurClass := CreateClass(Copy(s, 1, i - 1));
  614. end else
  615. begin
  616. i := Pos(' ', s);
  617. if i = 0 then
  618. Name := Copy(s, 3, Length(s))
  619. else
  620. Name := Copy(s, 3, i - 3);
  621. case s[2] of
  622. 'M':
  623. Member := TPasProcedure.Create(Name, CurClass);
  624. 'P':
  625. begin
  626. Member := TPasProperty.Create(Name, CurClass);
  627. if i > 0 then
  628. while i <= Length(s) do
  629. begin
  630. case s[i] of
  631. 'r':
  632. TPasProperty(Member).ReadAccessorName := '<dummy>';
  633. 'w':
  634. TPasProperty(Member).WriteAccessorName := '<dummy>';
  635. 's':
  636. TPasProperty(Member).StoredAccessorName := '<dummy>';
  637. end;
  638. Inc(i);
  639. end;
  640. end;
  641. 'V':
  642. Member := TPasVariable.Create(Name, CurClass);
  643. else
  644. raise Exception.Create('Invalid member type: ' + s[2]);
  645. end;
  646. CurClass.Members.Add(Member);
  647. end;
  648. end;
  649. end;
  650. var
  651. s: String;
  652. begin
  653. if not FileExists(AFileName) then
  654. raise EInOutError.Create('File not found: ' + AFileName);
  655. Assign(f, AFilename);
  656. Reset(f);
  657. while not EOF(f) do
  658. begin
  659. ReadLn(f, s);
  660. if (Length(s) = 0) or (s[1] = '#') then
  661. continue;
  662. if s = ':link tree' then
  663. ReadLinkTree
  664. else if s = ':classes' then
  665. ReadClasses
  666. else
  667. repeat
  668. ReadLn(f, s);
  669. until EOF(f) or (Length(s) = 0);
  670. end;
  671. Close(f);
  672. end;
  673. procedure TFPDocEngine.WriteContentFile(const AFilename: String);
  674. var
  675. ContentFile: Text;
  676. procedure ProcessLinkNode(ALinkNode: TLinkNode; const AIdent: String);
  677. var
  678. ChildNode: TLinkNode;
  679. begin
  680. WriteLn(ContentFile, AIdent, ALinkNode.Name, ' ', ALinkNode.Link);
  681. ChildNode := ALinkNode.FirstChild;
  682. while Assigned(ChildNode) do
  683. begin
  684. ProcessLinkNode(ChildNode, AIdent + ' ');
  685. ChildNode := ChildNode.NextSibling;
  686. end;
  687. end;
  688. var
  689. LinkNode: TLinkNode;
  690. i, j, k: Integer;
  691. Module: TPasModule;
  692. ClassDecl: TPasClassType;
  693. Member: TPasElement;
  694. s: String;
  695. begin
  696. Assign(ContentFile, AFilename);
  697. Rewrite(ContentFile);
  698. try
  699. WriteLn(ContentFile, '# FPDoc Content File');
  700. WriteLn(ContentFile, ':link tree');
  701. LinkNode := RootLinkNode.FirstChild;
  702. while Assigned(LinkNode) do
  703. begin
  704. if LinkNode.Name = Package.Name then
  705. begin
  706. ProcessLinkNode(LinkNode, '');
  707. end;
  708. LinkNode := LinkNode.NextSibling;
  709. end;
  710. if Assigned(Package) then
  711. begin
  712. WriteLn(ContentFile);
  713. WriteLn(ContentFile, ':classes');
  714. for i := 0 to Package.Modules.Count - 1 do
  715. begin
  716. Module := TPasModule(Package.Modules[i]);
  717. for j := 0 to Module.InterfaceSection.Classes.Count - 1 do
  718. begin
  719. ClassDecl := TPasClassType(Module.InterfaceSection.Classes[j]);
  720. Write(ContentFile, ClassDecl.PathName, ' ');
  721. if Assigned(ClassDecl.AncestorType) then
  722. WriteLn(ContentFile, ClassDecl.AncestorType.PathName)
  723. else if ClassDecl.ObjKind = okClass then
  724. WriteLn(ContentFile, '.TObject');
  725. for k := 0 to ClassDecl.Members.Count - 1 do
  726. begin
  727. Member := TPasElement(ClassDecl.Members[k]);
  728. Write(ContentFile, Chr(Ord(Member.Visibility) + Ord('0')));
  729. SetLength(s, 0);
  730. if Member.ClassType = TPasVariable then
  731. Write(ContentFile, 'V')
  732. else if Member.ClassType = TPasProperty then
  733. begin
  734. Write(ContentFile, 'P');
  735. if Length(TPasProperty(Member).ReadAccessorName) > 0 then
  736. s := s + 'r';
  737. if Length(TPasProperty(Member).WriteAccessorName) > 0 then
  738. s := s + 'w';
  739. if Length(TPasProperty(Member).StoredAccessorName) > 0 then
  740. s := s + 's';
  741. end else
  742. Write(ContentFile, 'M'); // Member must be a method
  743. Write(ContentFile, Member.Name);
  744. if Length(s) > 0 then
  745. WriteLn(ContentFile, ' ', s)
  746. else
  747. WriteLn(ContentFile);
  748. end;
  749. end;
  750. end;
  751. end;
  752. finally
  753. Close(ContentFile);
  754. end;
  755. end;
  756. function TFPDocEngine.CreateElement(AClass: TPTreeElement; const AName: String;
  757. AParent: TPasElement; AVisibility: TPasMemberVisibility;
  758. const ASourceFilename: String; ASourceLinenumber: Integer): TPasElement;
  759. begin
  760. Result := AClass.Create(AName, AParent);
  761. Result.Visibility := AVisibility;
  762. if AClass.InheritsFrom(TPasModule) then
  763. CurModule := TPasModule(Result);
  764. Result.SourceFilename := ASourceFilename;
  765. Result.SourceLinenumber := ASourceLinenumber;
  766. end;
  767. function TFPDocEngine.FindElement(const AName: String): TPasElement;
  768. function FindInModule(AModule: TPasModule; const LocalName: String): TPasElement;
  769. var
  770. l: TList;
  771. i: Integer;
  772. begin
  773. If assigned(AModule.InterfaceSection) and
  774. Assigned(AModule.InterfaceSection.Declarations) then
  775. begin
  776. l:=AModule.InterfaceSection.Declarations;
  777. for i := 0 to l.Count - 1 do
  778. begin
  779. Result := TPasElement(l[i]);
  780. if CompareText(Result.Name, LocalName) = 0 then
  781. exit;
  782. end;
  783. end;
  784. Result := nil;
  785. end;
  786. var
  787. i: Integer;
  788. //ModuleName, LocalName: String;
  789. Module: TPasElement;
  790. begin
  791. {!!!: Don't know if we ever will have to use the following:
  792. i := Pos('.', AName);
  793. if i <> 0 then
  794. begin
  795. WriteLn('Dot found in name: ', AName);
  796. Result := nil;
  797. end else
  798. begin}
  799. Result := FindInModule(CurModule, AName);
  800. if not Assigned(Result) then
  801. for i := CurModule.InterfaceSection.UsesList.Count - 1 downto 0 do
  802. begin
  803. Module := TPasElement(CurModule.InterfaceSection.UsesList[i]);
  804. if Module.ClassType = TPasModule then
  805. begin
  806. Result := FindInModule(TPasModule(Module), AName);
  807. if Assigned(Result) then
  808. exit;
  809. end;
  810. end;
  811. {end;}
  812. end;
  813. function TFPDocEngine.FindModule(const AName: String): TPasModule;
  814. function FindInPackage(APackage: TPasPackage): TPasModule;
  815. var
  816. i: Integer;
  817. begin
  818. for i := 0 to APackage.Modules.Count - 1 do
  819. begin
  820. Result := TPasModule(APackage.Modules[i]);
  821. if CompareText(Result.Name, AName) = 0 then
  822. exit;
  823. end;
  824. Result := nil;
  825. end;
  826. var
  827. i: Integer;
  828. begin
  829. Result := FindInPackage(Package);
  830. if not Assigned(Result) then
  831. for i := FPackages.Count - 1 downto 0 do
  832. begin
  833. if TPasPackage(FPackages[i]) = Package then
  834. continue;
  835. Result := FindInPackage(TPasPackage(FPackages[i]));
  836. if Assigned(Result) then
  837. exit;
  838. end;
  839. end;
  840. procedure TFPDocEngine.AddLink(const APathName, ALinkTo: String);
  841. begin
  842. RootLinkNode.CreateChildren(APathName, ALinkTo);
  843. end;
  844. function TFPDocEngine.FindAbsoluteLink(const AName: String): String;
  845. var
  846. LinkNode: TLinkNode;
  847. begin
  848. LinkNode := RootLinkNode.FindChild(AName);
  849. if Assigned(LinkNode) then
  850. Result := LinkNode.Link
  851. else
  852. SetLength(Result, 0);
  853. end;
  854. function TFPDocEngine.ResolveLink(AModule: TPasModule;
  855. const ALinkDest: String): String;
  856. var
  857. i: Integer;
  858. ThisPackage: TLinkNode;
  859. UnitList: TList;
  860. begin
  861. //WriteLn('ResolveLink(', ALinkDest, ')... ');
  862. if Length(ALinkDest) = 0 then
  863. begin
  864. SetLength(Result, 0);
  865. exit;
  866. end;
  867. if (ALinkDest[1] = '#') or (not assigned(AModule)) then
  868. Result := FindAbsoluteLink(ALinkDest)
  869. else
  870. begin
  871. Result := ResolveLink(AModule, AModule.PathName + '.' + ALinkDest);
  872. if Length(Result) > 0 then
  873. exit;
  874. { Try all packages }
  875. SetLength(Result, 0);
  876. ThisPackage := RootLinkNode.FirstChild;
  877. while Assigned(ThisPackage) do
  878. begin
  879. Result := ResolveLink(AModule, ThisPackage.Name + '.' + ALinkDest);
  880. if Length(Result) > 0 then
  881. exit;
  882. ThisPackage := ThisPackage.NextSibling;
  883. end;
  884. if Length(Result) = 0 then
  885. begin
  886. { Okay, then we have to try all imported units of the current module }
  887. UnitList := AModule.InterfaceSection.UsesList;
  888. for i := UnitList.Count - 1 downto 0 do
  889. begin
  890. { Try all packages }
  891. ThisPackage := RootLinkNode.FirstChild;
  892. while Assigned(ThisPackage) do
  893. begin
  894. Result := ResolveLink(AModule, ThisPackage.Name + '.' +
  895. TPasType(UnitList[i]).Name + '.' + ALinkDest);
  896. if Length(Result) > 0 then
  897. exit;
  898. ThisPackage := ThisPackage.NextSibling;
  899. end;
  900. end;
  901. end;
  902. end;
  903. if Length(Result) = 0 then
  904. for i := Length(ALinkDest) downto 1 do
  905. if ALinkDest[i] = '.' then
  906. begin
  907. Result := ResolveLink(AModule, Copy(ALinkDest, 1, i - 1));
  908. exit;
  909. end;
  910. end;
  911. procedure TFPDocEngine.AddDocFile(const AFilename: String);
  912. function ReadNode(OwnerDocNode: TDocNode; Element: TDOMElement): TDocNode;
  913. var
  914. Subnode: TDOMNode;
  915. begin
  916. if OwnerDocNode = RootDocNode then
  917. Result := OwnerDocNode.CreateChildren('#' + Element['name'])
  918. else
  919. Result := OwnerDocNode.CreateChildren(Element['name']);
  920. Result.FNode := Element;
  921. Result.FLink := Element['link'];
  922. Result.FIsSkipped := Element['skip'] = '1';
  923. Subnode := Element.FirstChild;
  924. while Assigned(Subnode) do
  925. begin
  926. if Subnode.NodeType = ELEMENT_NODE then
  927. begin
  928. if Subnode.NodeName = 'short' then
  929. Result.FShortDescr := TDOMElement(Subnode)
  930. else if Subnode.NodeName = 'descr' then
  931. Result.FDescr := TDOMElement(Subnode)
  932. else if Subnode.NodeName = 'errors' then
  933. Result.FErrorsDoc := TDOMElement(Subnode)
  934. else if Subnode.NodeName = 'seealso' then
  935. Result.FSeeAlso := TDOMElement(Subnode)
  936. else if (Subnode.NodeName = 'example') and
  937. not Assigned(Result.FirstExample) then
  938. Result.FFirstExample := TDOMElement(Subnode);
  939. end;
  940. Subnode := Subnode.NextSibling;
  941. end;
  942. end;
  943. Procedure ReadTopics(TopicNode : TDocNode);
  944. Var
  945. SubNode : TDOMNode;
  946. begin
  947. SubNode:=TopicNode.FNode.FirstChilD;
  948. While Assigned(SubNode) do
  949. begin
  950. If (SubNode.NodeType=ELEMENT_NODE) and (SubNode.NodeName='topic') then
  951. With ReadNode(TopicNode,TDomElement(SubNode)) do
  952. // We could allow recursion here, but we won't, because it doesn't work on paper.
  953. FTopicNode:=True;
  954. SubNode:=Subnode.NextSibling;
  955. end;
  956. end;
  957. var
  958. i: Integer;
  959. Node, Subnode, Subsubnode: TDOMNode;
  960. Element: TDOMElement;
  961. Doc: TXMLDocument;
  962. PackageDocNode, TopicNode,ModuleDocNode: TDocNode;
  963. begin
  964. ReadXMLFile(Doc, AFilename);
  965. DescrDocs.Add(Doc);
  966. DescrDocNames.Add(AFilename);
  967. Node := Doc.DocumentElement.FirstChild;
  968. while Assigned(Node) do
  969. begin
  970. if (Node.NodeType = ELEMENT_NODE) and (Node.NodeName = 'package') then
  971. begin
  972. PackageDocNode := ReadNode(RootDocNode, TDOMElement(Node));
  973. PackageDocNode.IncRefCount;
  974. // Scan all 'module' elements within this package element
  975. Subnode := Node.FirstChild;
  976. while Assigned(Subnode) do
  977. begin
  978. if (Subnode.NodeType = ELEMENT_NODE) then
  979. begin
  980. If (Subnode.NodeName = 'module') then
  981. begin
  982. ModuleDocNode := ReadNode(PackageDocNode, TDOMElement(Subnode));
  983. // Scan all 'element' elements within this module element
  984. Subsubnode := Subnode.FirstChild;
  985. while Assigned(Subsubnode) do
  986. begin
  987. if (Subsubnode.NodeType = ELEMENT_NODE) then
  988. begin
  989. if (Subsubnode.NodeName = 'element') then
  990. ReadNode(ModuleDocNode, TDOMElement(Subsubnode))
  991. else if (SubSubNode.NodeName='topic') then
  992. begin
  993. TopicNode:=ReadNode(ModuleDocNode,TDomElement(SubSubNode));
  994. TopicNode.FTopicNode:=True;
  995. ReadTopics(TopicNode);
  996. end;
  997. end;
  998. Subsubnode := Subsubnode.NextSibling;
  999. end;
  1000. end
  1001. else if (SubNode.NodeName='topic') then
  1002. begin
  1003. TopicNode:=ReadNode(PackageDocNode,TDomElement(SubNode));
  1004. TopicNode.FTopicNode:=True;
  1005. ReadTopics(TopicNode);
  1006. end;
  1007. end;
  1008. Subnode := Subnode.NextSibling;
  1009. end;
  1010. end;
  1011. Node := Node.NextSibling;
  1012. end;
  1013. end;
  1014. function TFPDocEngine.FindDocNode(AElement: TPasElement): TDocNode;
  1015. begin
  1016. Result:=Nil;
  1017. If Assigned(AElement) then
  1018. begin
  1019. if AElement.InheritsFrom(TPasUnresolvedTypeRef) then
  1020. Result := FindDocNode(AElement.GetModule, AElement.Name)
  1021. else
  1022. Result := RootDocNode.FindChild(AElement.PathName);
  1023. if (Result=Nil) and
  1024. WarnNoNode and
  1025. (Length(AElement.PathName)>0) and
  1026. (AElement.PathName[1]='#') then
  1027. Writeln('No documentation node found for identifier : ',AElement.PathName);
  1028. end;
  1029. end;
  1030. function TFPDocEngine.FindDocNode(ARefModule: TPasModule;
  1031. const AName: String): TDocNode;
  1032. var
  1033. CurPackage: TDocNode;
  1034. UnitList: TList;
  1035. i: Integer;
  1036. begin
  1037. if Length(AName) = 0 then
  1038. Result := nil
  1039. else
  1040. begin
  1041. if AName[1] = '#' then
  1042. Result := RootDocNode.FindChild(AName)
  1043. else
  1044. Result := RootDocNode.FindChild(Package.Name + '.' + AName);
  1045. if (not Assigned(Result)) and Assigned(ARefModule) then
  1046. Result := RootDocNode.FindChild(ARefModule.PathName + '.' + AName);
  1047. if (not Assigned(Result)) and (AName[1] <> '#') then
  1048. begin
  1049. CurPackage := RootDocNode.FirstChild;
  1050. while Assigned(CurPackage) do
  1051. begin
  1052. Result := RootDocNode.FindChild(CurPackage.Name + '.' + AName);
  1053. if Assigned(Result) then
  1054. break;
  1055. CurPackage := CurPackage.NextSibling;
  1056. end;
  1057. if not Assigned(Result) then
  1058. begin
  1059. { Okay, then we have to try all imported units of the current module }
  1060. UnitList := CurModule.InterfaceSection.UsesList;
  1061. for i := UnitList.Count - 1 downto 0 do
  1062. begin
  1063. { Try all packages }
  1064. CurPackage := RootDocNode.FirstChild;
  1065. while Assigned(CurPackage) do
  1066. begin
  1067. Result := RootDocNode.FindChild(CurPackage.Name + '.' +
  1068. TPasType(UnitList[i]).Name + '.' + AName);
  1069. if Assigned(Result) then
  1070. break;
  1071. CurPackage := CurPackage.NextSibling;
  1072. end;
  1073. end;
  1074. end;
  1075. end;
  1076. end;
  1077. end;
  1078. function TFPDocEngine.FindShortDescr(AElement: TPasElement): TDOMElement;
  1079. var
  1080. DocNode: TDocNode;
  1081. begin
  1082. DocNode := FindDocNode(AElement);
  1083. if Assigned(DocNode) then
  1084. Result := DocNode.ShortDescr
  1085. else
  1086. Result := nil;
  1087. end;
  1088. function TFPDocEngine.FindShortDescr(ARefModule: TPasModule;
  1089. const AName: String): TDOMElement;
  1090. var
  1091. DocNode: TDocNode;
  1092. begin
  1093. DocNode := FindDocNode(ARefModule, AName);
  1094. if Assigned(DocNode) then
  1095. Result := DocNode.ShortDescr
  1096. else
  1097. Result := nil;
  1098. end;
  1099. function TFPDocEngine.GetExampleFilename(const ExElement: TDOMElement): String;
  1100. var
  1101. i: Integer;
  1102. fn : String;
  1103. begin
  1104. Result:='';
  1105. for i := 0 to DescrDocs.Count - 1 do
  1106. begin
  1107. Fn:=ExElement['file'];
  1108. if (FN<>'') and (TDOMDocument(DescrDocs[i]) = ExElement.OwnerDocument) then
  1109. begin
  1110. Result := ExtractFilePath(DescrDocNames[i]) + FN;
  1111. if (ExtractFileExt(Result)='') then
  1112. Result:=Result+'.pp';
  1113. end;
  1114. end;
  1115. end;
  1116. { Global helpers }
  1117. procedure TranslateDocStrings(const Lang: String);
  1118. Const
  1119. {$ifdef unix}
  1120. DefDir = '/usr/local/share/locale';
  1121. {$else}
  1122. DefDir = 'intl';
  1123. {$endif}
  1124. var
  1125. mo: TMOFile;
  1126. dir : string;
  1127. begin
  1128. dir:=modir;
  1129. If Dir='' then
  1130. Dir:=DefDir;
  1131. Dir:=IncludeTrailingPathDelimiter(Dir);
  1132. {$IFDEF Unix}
  1133. mo := TMOFile.Create(Format(Dir+'%s/LC_MESSAGES/dglobals.mo', [Lang]));
  1134. {$ELSE}
  1135. mo := TMOFile.Create(Format(Dir+'dglobals.%s.mo', [Lang]));
  1136. {$ENDIF}
  1137. try
  1138. TranslateResourceStrings(mo);
  1139. finally
  1140. mo.Free;
  1141. end;
  1142. end;
  1143. Function IsLinkNode(Node : TDomNode) : Boolean;
  1144. begin
  1145. Result:=Assigned(Node) and (Node.NodeType = ELEMENT_NODE) and (Node.NodeName = 'link');
  1146. end;
  1147. Function IsExampleNode(Example : TDomNode) : Boolean;
  1148. begin
  1149. Result:=Assigned(Example) and (Example.NodeType = ELEMENT_NODE) and (Example.NodeName = 'example')
  1150. end;
  1151. function IsLinkAbsolute(ALink: String): boolean;
  1152. var
  1153. i: integer;
  1154. begin
  1155. Result := false;
  1156. for i := low(AbsoluteLinkPrefixes) to high(AbsoluteLinkPrefixes) do
  1157. if CompareText(AbsoluteLinkPrefixes[i], copy(ALink,1,length(AbsoluteLinkPrefixes[i])))=0 then begin
  1158. Result := true;
  1159. break;
  1160. end;
  1161. end;
  1162. initialization
  1163. LEOL:=Length(LineEnding);
  1164. end.