dw_xml.pp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. {
  2. $Id$
  3. FPDoc - Free Pascal Documentation Tool
  4. Copyright (C) 2000 - 2003 by
  5. Areca Systems GmbH / Sebastian Guenther, [email protected]
  6. * 'XML struct' output generator
  7. See the file COPYING, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. }
  13. unit dw_XML;
  14. interface
  15. uses DOM, PasTree;
  16. function ModuleToXMLStruct(AModule: TPasModule): TXMLDocument;
  17. implementation
  18. function ModuleToXMLStruct(AModule: TPasModule): TXMLDocument;
  19. var
  20. ModuleElement: TDOMElement;
  21. procedure ProcessProcedure(Proc: TPasProcedure; Element: TDOMElement);
  22. var
  23. ProcEl: TDOMElement;
  24. begin
  25. ProcEl := Result.CreateElement(Proc.TypeName);
  26. Element.AppendChild(ProcEl);
  27. ProcEl['name'] := Proc.Name;
  28. end;
  29. procedure ProcessVariable(AVar: TPasVariable; Element: TDOMElement);
  30. var
  31. VarEl: TDOMElement;
  32. begin
  33. VarEl := Result.CreateElement('var');
  34. Element.AppendChild(VarEl);
  35. VarEl['name'] := AVar.Name;
  36. end;
  37. procedure ProcessSection(ASection: TPasSection; const Name: DOMString);
  38. var
  39. Element, UsesElement, UnitElement: TDOMElement;
  40. i: Integer;
  41. Decl: TPasElement;
  42. begin
  43. Element := Result.CreateElement(Name);
  44. ModuleElement.AppendChild(Element);
  45. if ASection.UsesList.Count > 0 then
  46. begin
  47. UsesElement := Result.CreateElement('uses');
  48. Element.AppendChild(UsesElement);
  49. for i := 0 to ASection.UsesList.Count - 1 do
  50. begin
  51. UnitElement := Result.CreateElement('unit-ref');
  52. UnitElement['name'] := TPasType(ASection.UsesList[i]).Name;
  53. UsesElement.AppendChild(UnitElement);
  54. end;
  55. end;
  56. for i := 0 to ASection.Declarations.Count - 1 do
  57. begin
  58. Decl := TPasElement(ASection.Declarations[i]);
  59. if Decl.InheritsFrom(TPasProcedure) then
  60. ProcessProcedure(TPasProcedure(Decl), Element)
  61. else if Decl.ClassType = TPasVariable then
  62. ProcessVariable(TPasVariable(Decl), Element);
  63. end;
  64. end;
  65. begin
  66. Result := TXMLDocument.Create;
  67. Result.AppendChild(Result.CreateComment(' Generated using FPDoc - (c) 2000-2003 Sebastian Guenther, [email protected] '));
  68. Result.AppendChild(Result.CreateElement('fp-refdoc'));
  69. ModuleElement := Result.CreateElement('unit');
  70. ModuleElement['name'] := AModule.Name;
  71. Result.DocumentElement.AppendChild(ModuleElement);
  72. ProcessSection(AModule.InterfaceSection, 'interface');
  73. end;
  74. end.
  75. {
  76. $Log$
  77. Revision 1.1 2003-03-17 23:03:20 michael
  78. + Initial import in CVS
  79. Revision 1.5 2003/03/13 22:02:13 sg
  80. * New version with many bugfixes and our own parser (now independent of the
  81. compiler source)
  82. Revision 1.4 2002/05/24 00:13:22 sg
  83. * much improved new version, including many linking and output fixes
  84. Revision 1.3 2002/03/12 10:58:36 sg
  85. * reworked linking engine and internal structure
  86. Revision 1.2 2001/07/27 10:21:42 sg
  87. * Just a new, improved version ;)
  88. (detailed changelogs will be provided again with the next commits)
  89. Revision 1.1 2000/10/04 09:17:37 sg
  90. * First public version
  91. }