PageRenderTime 49ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-3-pre5/doclet/GenerateTocXML.java

#
Java | 116 lines | 82 code | 16 blank | 18 comment | 4 complexity | 623c4abc53c8cf2fe8fcb4413c7d403b 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 com.sun.tools.doclets.standard.Standard;
  22. import java.io.*;
  23. import java.util.Arrays;
  24. public class GenerateTocXML
  25. {
  26. public static final String OUT = "toc.xml";
  27. public static final String HEADER = "<?xml version='1.0'?>\n<TOC>\n"
  28. + "<ENTRY HREF='overview-summary.html'><TITLE>jEdit API Reference</TITLE>";
  29. public static final String FOOTER = "</ENTRY></TOC>\n";
  30. public static boolean start(RootDoc root)
  31. {
  32. if (!Standard.start(root))
  33. {
  34. return false;
  35. }
  36. try
  37. {
  38. FileWriter out = new FileWriter(Standard.htmlDoclet.configuration().destDirName + OUT);
  39. out.write(HEADER);
  40. PackageDoc[] packages = root.specifiedPackages();
  41. for(int i = 0; i < packages.length; ++i)
  42. {
  43. processPackage(out,packages[i]);
  44. }
  45. out.write(FOOTER);
  46. out.close();
  47. return true;
  48. }
  49. catch(IOException e)
  50. {
  51. e.printStackTrace();
  52. return false;
  53. }
  54. }
  55. public static int optionLength(String option)
  56. {
  57. return Standard.optionLength(option);
  58. }
  59. public static boolean validOptions(String[][] options, DocErrorReporter reporter)
  60. {
  61. return Standard.validOptions(options,reporter);
  62. }
  63. public static LanguageVersion languageVersion()
  64. {
  65. return Standard.languageVersion();
  66. }
  67. private static void processPackage(Writer out, PackageDoc pkg)
  68. throws IOException
  69. {
  70. out.write("<ENTRY HREF='");
  71. String pkgPath = pkg.name().replace('.','/') + "/";
  72. out.write(pkgPath);
  73. out.write("package-summary.html'><TITLE>");
  74. out.write(pkg.name());
  75. out.write("</TITLE>\n");
  76. ClassDoc[] classes = pkg.allClasses();
  77. String[] classNames = new String[classes.length];
  78. for(int i = 0; i < classes.length; i++)
  79. {
  80. classNames[i] = classes[i].name();
  81. }
  82. Arrays.sort(classNames);
  83. for(int i = 0; i < classes.length; i++)
  84. {
  85. processClass(out,pkgPath,classNames[i]);
  86. }
  87. out.write("</ENTRY>");
  88. }
  89. private static void processClass(Writer out, String pkgPath, String clazz)
  90. throws IOException
  91. {
  92. out.write("<ENTRY HREF='");
  93. out.write(pkgPath);
  94. out.write(clazz);
  95. out.write(".html'><TITLE>");
  96. out.write(clazz);
  97. out.write("</TITLE>\n");
  98. out.write("</ENTRY>");
  99. }
  100. }