You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Standard.java 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2. *
  3. * This file is part of the debugger and core tools for the AspectJ(tm)
  4. * programming language; see http://aspectj.org
  5. *
  6. * The contents of this file are subject to the Mozilla Public License
  7. * Version 1.1 (the "License"); you may not use this file except in
  8. * compliance with the License. You may obtain a copy of the License at
  9. * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
  10. *
  11. * Software distributed under the License is distributed on an "AS IS" basis,
  12. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13. * for the specific language governing rights and limitations under the
  14. * License.
  15. *
  16. * The Original Code is AspectJ.
  17. *
  18. * The Initial Developer of the Original Code is Xerox Corporation. Portions
  19. * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
  20. * All Rights Reserved.
  21. */
  22. package org.aspectj.tools.doclets.standard;
  23. import org.aspectj.tools.ajdoc.Quietable;
  24. import com.sun.javadoc.RootDoc;
  25. import com.sun.tools.doclets.DocletAbortException;
  26. import com.sun.tools.doclets.standard.AllClassesFrameWriter;
  27. import com.sun.tools.doclets.standard.FrameOutputWriter;
  28. import com.sun.tools.doclets.standard.HelpWriter;
  29. import com.sun.tools.doclets.standard.PackageIndexFrameWriter;
  30. import com.sun.tools.doclets.standard.PackageIndexWriter;
  31. import com.sun.tools.doclets.standard.PackageListWriter;
  32. import com.sun.tools.doclets.standard.PackagesFileWriter;
  33. import com.sun.tools.doclets.standard.SerializedFormWriter;
  34. import com.sun.tools.doclets.standard.StylesheetWriter;
  35. import java.io.IOException;
  36. /**
  37. * Main doclet for ajdoc. It defines a number of
  38. * passes to use in generating the documentation.
  39. *
  40. * @author Jeff Palm
  41. */
  42. public class Standard extends AbstractStandard {
  43. private static Standard SINGLETON; // todo: prefer early/final?
  44. public static final Standard getSingleton() {
  45. if (null == SINGLETON) {
  46. SINGLETON = new Standard();
  47. }
  48. return SINGLETON;
  49. }
  50. private Standard() {}
  51. public static boolean start(RootDoc root) throws IOException {
  52. return start(getSingleton(), root);
  53. }
  54. public ConfigurationStandard getConfiguration() {
  55. return (ConfigurationStandard)configuration();
  56. }
  57. public static void quiet() {
  58. if (configuration().root instanceof Quietable) {
  59. ((Quietable)configuration().root).quiet();
  60. }
  61. }
  62. public static void speak() {
  63. if (configuration().root instanceof Quietable) {
  64. ((Quietable)configuration().root).speak();
  65. }
  66. }
  67. public static class ClassUseMapperPass extends Pass {
  68. protected boolean cond() {
  69. return cs.classuse;
  70. }
  71. protected void gen() throws DocletAbortException {
  72. ClassUseMapper.generate(root, std.classtree);
  73. }
  74. public String title() { return "class use mapper"; }
  75. }
  76. public static class TreeWriterPass extends Pass {
  77. protected boolean cond() {
  78. return cs.createtree;
  79. }
  80. protected void gen() throws DocletAbortException {
  81. TreeWriter.generate(std.classtree);
  82. }
  83. public String title() { return "tree writer"; }
  84. }
  85. public static class SplitIndexWriterPass extends Pass {
  86. protected boolean cond() {
  87. return cs.createindex && cs.splitindex;
  88. }
  89. protected void gen() throws DocletAbortException {
  90. SplitIndexWriter.generate(std.indexBuilder(root, false));
  91. }
  92. public String title() { return "split index"; }
  93. }
  94. public static class SingleIndexWriterPass extends Pass {
  95. protected boolean cond() {
  96. return cs.createindex && !cs.splitindex;
  97. }
  98. protected void gen() throws DocletAbortException {
  99. SingleIndexWriter.generate(std.indexBuilder(root, false));
  100. }
  101. public String title() { return "single index"; }
  102. }
  103. public static class DeprecatedListWriterPass extends Pass {
  104. protected boolean cond() {
  105. return !cs.nodeprecatedlist && !cs.nodeprecated;
  106. }
  107. protected void gen() throws DocletAbortException {
  108. DeprecatedListWriter.generate(root);
  109. }
  110. public String title() { return "deprecated list"; }
  111. }
  112. public static class AllClassesFrameWriterPass extends Pass {
  113. protected void gen() throws DocletAbortException {
  114. AllClassesFrameWriter.generate(std.indexBuilder(root, true));
  115. }
  116. public String title() { return "all classes frame"; }
  117. }
  118. public static class FrameOutputWriterPass extends Pass {
  119. protected void gen() throws DocletAbortException {
  120. FrameOutputWriter.generate();
  121. }
  122. public String title() { return "output frame"; }
  123. }
  124. public static class PackagesFileWriterPass extends Pass {
  125. protected void gen() throws DocletAbortException {
  126. PackagesFileWriter.generate();
  127. }
  128. public String title() { return "packages files"; }
  129. }
  130. public static class PackageIndexWriterPass extends Pass {
  131. protected boolean cond(ConfigurationStandard cs) {
  132. return cs.createoverview;
  133. }
  134. protected void gen() throws DocletAbortException {
  135. PackageIndexWriter.generate(root);
  136. }
  137. public String title() { return "package index"; }
  138. }
  139. public static class PackageIndexFrameWriterPass extends Pass {
  140. protected boolean cond() {
  141. return cs.packages.length > 1;
  142. }
  143. protected void gen() throws DocletAbortException {
  144. PackageIndexFrameWriter.generate();
  145. }
  146. public String title() { return "package index frame"; }
  147. }
  148. protected Class[] preGenerationClasses() {
  149. return new Class[] {
  150. ClassUseMapperPass.class,
  151. TreeWriterPass.class,
  152. SplitIndexWriterPass.class,
  153. SingleIndexWriterPass.class,
  154. DeprecatedListWriterPass.class,
  155. AllClassesFrameWriterPass.class,
  156. FrameOutputWriterPass.class,
  157. PackagesFileWriterPass.class,
  158. PackageIndexWriterPass.class,
  159. PackageIndexFrameWriterPass.class,
  160. };
  161. }
  162. public static class SerializedFormWriterPass extends Pass {
  163. protected void gen() throws DocletAbortException {
  164. SerializedFormWriter.generate(root);
  165. }
  166. public String title() { return "serialized form"; }
  167. }
  168. public static class PackageListWriterPass extends Pass {
  169. protected void gen() throws DocletAbortException {
  170. PackageListWriter.generate(root);
  171. }
  172. public String title() { return "package list"; }
  173. }
  174. public static class HelpWriterPass extends Pass {
  175. protected boolean cond() {
  176. return cs.helpfile.length() == 0 &&
  177. !cs.nohelp;
  178. }
  179. protected void gen() throws DocletAbortException {
  180. HelpWriter.generate();
  181. }
  182. public String title() { return "help"; }
  183. }
  184. public static class StylesheetWriterPass extends Pass {
  185. protected boolean cond() {
  186. return cs.stylesheetfile.length() == 0;
  187. }
  188. protected void gen() throws DocletAbortException {
  189. StylesheetWriter.generate();
  190. }
  191. public String title() { return "style sheet"; }
  192. }
  193. protected Class[] postGenerationClasses() {
  194. return new Class[] {
  195. SerializedFormWriterPass.class,
  196. PackageListWriterPass.class,
  197. HelpWriterPass.class,
  198. StylesheetWriterPass.class,
  199. };
  200. }
  201. public static class NoPublicClassesToDocumentCheck extends Check {
  202. protected boolean cond() {
  203. return root.classes().length == 0;
  204. }
  205. protected String message() {
  206. return "doclet.No_Public_Classes_To_Document";
  207. }
  208. }
  209. public static class NoNonDeprecatedClassToDocumentCheck extends Check {
  210. protected boolean cond() {
  211. return cs.topFile.length() == 0;
  212. }
  213. protected String message() {
  214. return "doclet.No_Non_Deprecated_Classes_To_Document";
  215. }
  216. }
  217. protected Class[] checkClasses() {
  218. return new Class[] {
  219. NoPublicClassesToDocumentCheck.class,
  220. NoNonDeprecatedClassToDocumentCheck.class,
  221. };
  222. }
  223. }