dw_xml.pp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. {$mode objfpc}
  14. {$H+}
  15. unit dw_XML;
  16. interface
  17. uses DOM, PasTree;
  18. function ModuleToXMLStruct(AModule: TPasModule): TXMLDocument;
  19. implementation
  20. function ModuleToXMLStruct(AModule: TPasModule): TXMLDocument;
  21. var
  22. ModuleElement: TDOMElement;
  23. procedure ProcessProcedure(Proc: TPasProcedure; Element: TDOMElement);
  24. var
  25. ProcEl: TDOMElement;
  26. begin
  27. ProcEl := Result.CreateElement(Proc.TypeName);
  28. Element.AppendChild(ProcEl);
  29. ProcEl['name'] := Proc.Name;
  30. end;
  31. procedure ProcessVariable(AVar: TPasVariable; Element: TDOMElement);
  32. var
  33. VarEl: TDOMElement;
  34. begin
  35. VarEl := Result.CreateElement('var');
  36. Element.AppendChild(VarEl);
  37. VarEl['name'] := AVar.Name;
  38. end;
  39. procedure ProcessSection(ASection: TPasSection; const Name: DOMString);
  40. var
  41. Element, UsesElement, UnitElement: TDOMElement;
  42. i: Integer;
  43. Decl: TPasElement;
  44. begin
  45. Element := Result.CreateElement(Name);
  46. ModuleElement.AppendChild(Element);
  47. if ASection.UsesList.Count > 0 then
  48. begin
  49. UsesElement := Result.CreateElement('uses');
  50. Element.AppendChild(UsesElement);
  51. for i := 0 to ASection.UsesList.Count - 1 do
  52. begin
  53. UnitElement := Result.CreateElement('unit-ref');
  54. UnitElement['name'] := TPasType(ASection.UsesList[i]).Name;
  55. UsesElement.AppendChild(UnitElement);
  56. end;
  57. end;
  58. for i := 0 to ASection.Declarations.Count - 1 do
  59. begin
  60. Decl := TPasElement(ASection.Declarations[i]);
  61. if Decl.InheritsFrom(TPasProcedure) then
  62. ProcessProcedure(TPasProcedure(Decl), Element)
  63. else if Decl.ClassType = TPasVariable then
  64. ProcessVariable(TPasVariable(Decl), Element);
  65. end;
  66. end;
  67. begin
  68. Result := TXMLDocument.Create;
  69. Result.AppendChild(Result.CreateComment(' Generated using FPDoc - (c) 2000-2003 Sebastian Guenther, [email protected] '));
  70. Result.AppendChild(Result.CreateElement('fp-refdoc'));
  71. ModuleElement := Result.CreateElement('unit');
  72. ModuleElement['name'] := AModule.Name;
  73. Result.DocumentElement.AppendChild(ModuleElement);
  74. ProcessSection(AModule.InterfaceSection, 'interface');
  75. end;
  76. end.
  77. {
  78. $Log$
  79. Revision 1.2 2005-01-09 15:59:50 michael
  80. + Split out latex writer to linear and latex writer
  81. Revision 1.1 2003/03/17 23:03:20 michael
  82. + Initial import in CVS
  83. Revision 1.5 2003/03/13 22:02:13 sg
  84. * New version with many bugfixes and our own parser (now independent of the
  85. compiler source)
  86. Revision 1.4 2002/05/24 00:13:22 sg
  87. * much improved new version, including many linking and output fixes
  88. Revision 1.3 2002/03/12 10:58:36 sg
  89. * reworked linking engine and internal structure
  90. Revision 1.2 2001/07/27 10:21:42 sg
  91. * Just a new, improved version ;)
  92. (detailed changelogs will be provided again with the next commits)
  93. Revision 1.1 2000/10/04 09:17:37 sg
  94. * First public version
  95. }