PageRenderTime 37ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-2-pre14/doclet/GenerateTocXML.java

#
Java | 101 lines | 66 code | 14 blank | 21 comment | 3 complexity | c5432b7d402d32621c13f478e2b172b2 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. /*
  2. * GenerateTocXML.java
  3. * Copyright (C) 1999, 2003 Slava Pestov
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. package doclet;
  20. import com.sun.javadoc.*;
  21. import java.io.*;
  22. import java.util.Arrays;
  23. /**
  24. * This is very much of a hack.
  25. */
  26. public class GenerateTocXML
  27. {
  28. public static final String PATH = "doc/api/";
  29. public static final String OUT = PATH + "toc.xml";
  30. public static final String HEADER = "<?xml version='1.0'?>\n<TOC>\n"
  31. + "<ENTRY HREF='overview-summary.html'><TITLE>jEdit API Reference</TITLE>";
  32. public static final String FOOTER = "</ENTRY></TOC>\n";
  33. public static boolean start(RootDoc root)
  34. {
  35. try
  36. {
  37. FileWriter out = new FileWriter(OUT);
  38. out.write(HEADER);
  39. PackageDoc[] packages = root.specifiedPackages();
  40. for(int i = 0; i < packages.length; ++i)
  41. {
  42. processPackage(out,packages[i]);
  43. }
  44. out.write(FOOTER);
  45. out.close();
  46. return true;
  47. }
  48. catch(IOException e)
  49. {
  50. e.printStackTrace();
  51. return false;
  52. }
  53. }
  54. private static void processPackage(Writer out, PackageDoc pkg)
  55. throws IOException
  56. {
  57. out.write("<ENTRY HREF='");
  58. String pkgPath = pkg.name().replace('.','/') + "/";
  59. out.write(pkgPath);
  60. out.write("package-summary.html'><TITLE>");
  61. out.write(pkg.name());
  62. out.write("</TITLE>\n");
  63. ClassDoc[] classes = pkg.allClasses();
  64. String[] classNames = new String[classes.length];
  65. for(int i = 0; i < classes.length; i++)
  66. {
  67. classNames[i] = classes[i].name();
  68. }
  69. Arrays.sort(classNames);
  70. for(int i = 0; i < classes.length; i++)
  71. {
  72. processClass(out,pkgPath,classNames[i]);
  73. }
  74. out.write("</ENTRY>");
  75. }
  76. private static void processClass(Writer out, String pkgPath, String clazz)
  77. throws IOException
  78. {
  79. out.write("<ENTRY HREF='");
  80. out.write(pkgPath);
  81. out.write(clazz);
  82. out.write(".html'><TITLE>");
  83. out.write(clazz);
  84. out.write("</TITLE>\n");
  85. out.write("</ENTRY>");
  86. }
  87. }