85 if (!getClass().getName().equals(TOOLKIT_DOCLET_NAME)) {
86 messages.error("doclet.Toolkit_Usage_Violation",
87 TOOLKIT_DOCLET_NAME);
88 return false;
89 }
90 return true;
91 }
92
93 /**
94 * The method that starts the execution of the doclet.
95 *
96 * @param docEnv the {@link DocletEnvironment}.
97 * @return true if the doclet executed without error. False otherwise.
98 */
99 @Override
100 public boolean run(DocletEnvironment docEnv) {
101 configuration = getConfiguration();
102 configuration.initConfiguration(docEnv);
103 utils = configuration.utils;
104 messages = configuration.getMessages();
105
106 if (!isValidDoclet()) {
107 return false;
108 }
109
110 try {
111 try {
112 startGeneration(docEnv);
113 return true;
114 } catch (UncheckedDocletException e) {
115 throw (DocletException) e.getCause();
116 }
117
118 } catch (DocFileIOException e) {
119 switch (e.mode) {
120 case READ:
121 messages.error("doclet.exception.read.file",
122 e.fileName.getPath(), e.getCause());
123 break;
124 case WRITE:
125 messages.error("doclet.exception.write.file",
126 e.fileName.getPath(), e.getCause());
127 }
128 dumpStack(configuration.dumpOnError, e);
129
130 } catch (ResourceIOException e) {
131 messages.error("doclet.exception.read.resource",
132 e.resource.getPath(), e.getCause());
133 dumpStack(configuration.dumpOnError, e);
134
135 } catch (SimpleDocletException e) {
136 configuration.reporter.print(ERROR, e.getMessage());
137 dumpStack(configuration.dumpOnError, e);
138
139 } catch (InternalException e) {
140 configuration.reporter.print(ERROR, e.getMessage());
141 reportInternalError(e.getCause());
142
143 } catch (DocletException | RuntimeException | Error e) {
144 messages.error("doclet.internal.exception", e);
145 reportInternalError(e);
146 }
147
148 return false;
149 }
150
151 private void reportInternalError(Throwable t) {
152 if (getClass().equals(StandardDoclet.class) || getClass().equals(HtmlDoclet.class)) {
153 System.err.println(configuration.getResources().getText("doclet.internal.report.bug"));
154 }
155 dumpStack(true, t);
156 }
157
183 * writers, which will in turn generate the documentation files. Call the
184 * TreeWriter generation first to ensure the Class Hierarchy is built
185 * first and then can be used in the later generation.
186 *
187 * @throws DocletException if there is a problem while generating the documentation
188 */
189 private void startGeneration(DocletEnvironment docEnv) throws DocletException {
190
191 // Modules with no documented classes may be specified on the
192 // command line to specify a service provider, allow these.
193 if (configuration.getSpecifiedModuleElements().isEmpty() &&
194 configuration.getIncludedTypeElements().isEmpty()) {
195 messages.error("doclet.No_Public_Classes_To_Document");
196 return;
197 }
198 if (!configuration.setOptions()) {
199 return;
200 }
201 messages.notice("doclet.build_version",
202 configuration.getDocletVersion());
203 ClassTree classtree = new ClassTree(configuration, configuration.nodeprecated);
204
205 generateClassFiles(docEnv, classtree);
206
207 ElementListWriter.generate(configuration);
208 generatePackageFiles(classtree);
209 generateModuleFiles();
210
211 generateOtherFiles(docEnv, classtree);
212 configuration.tagletManager.printReport();
213 }
214
215 /**
216 * Generate additional documentation that is added to the API documentation.
217 *
218 * @param docEnv the DocletEnvironment
219 * @param classtree the data structure representing the class tree
220 * @throws DocletException if there is a problem while generating the documentation
221 */
222 protected void generateOtherFiles(DocletEnvironment docEnv, ClassTree classtree)
223 throws DocletException {
|
85 if (!getClass().getName().equals(TOOLKIT_DOCLET_NAME)) {
86 messages.error("doclet.Toolkit_Usage_Violation",
87 TOOLKIT_DOCLET_NAME);
88 return false;
89 }
90 return true;
91 }
92
93 /**
94 * The method that starts the execution of the doclet.
95 *
96 * @param docEnv the {@link DocletEnvironment}.
97 * @return true if the doclet executed without error. False otherwise.
98 */
99 @Override
100 public boolean run(DocletEnvironment docEnv) {
101 configuration = getConfiguration();
102 configuration.initConfiguration(docEnv);
103 utils = configuration.utils;
104 messages = configuration.getMessages();
105 BaseOptions options = configuration.getOptions();
106
107 if (!isValidDoclet()) {
108 return false;
109 }
110
111 try {
112 try {
113 startGeneration(docEnv);
114 return true;
115 } catch (UncheckedDocletException e) {
116 throw (DocletException) e.getCause();
117 }
118
119 } catch (DocFileIOException e) {
120 switch (e.mode) {
121 case READ:
122 messages.error("doclet.exception.read.file",
123 e.fileName.getPath(), e.getCause());
124 break;
125 case WRITE:
126 messages.error("doclet.exception.write.file",
127 e.fileName.getPath(), e.getCause());
128 }
129 dumpStack(options.dumpOnError, e);
130
131 } catch (ResourceIOException e) {
132 messages.error("doclet.exception.read.resource",
133 e.resource.getPath(), e.getCause());
134 dumpStack(options.dumpOnError, e);
135
136 } catch (SimpleDocletException e) {
137 configuration.reporter.print(ERROR, e.getMessage());
138 dumpStack(options.dumpOnError, e);
139
140 } catch (InternalException e) {
141 configuration.reporter.print(ERROR, e.getMessage());
142 reportInternalError(e.getCause());
143
144 } catch (DocletException | RuntimeException | Error e) {
145 messages.error("doclet.internal.exception", e);
146 reportInternalError(e);
147 }
148
149 return false;
150 }
151
152 private void reportInternalError(Throwable t) {
153 if (getClass().equals(StandardDoclet.class) || getClass().equals(HtmlDoclet.class)) {
154 System.err.println(configuration.getResources().getText("doclet.internal.report.bug"));
155 }
156 dumpStack(true, t);
157 }
158
184 * writers, which will in turn generate the documentation files. Call the
185 * TreeWriter generation first to ensure the Class Hierarchy is built
186 * first and then can be used in the later generation.
187 *
188 * @throws DocletException if there is a problem while generating the documentation
189 */
190 private void startGeneration(DocletEnvironment docEnv) throws DocletException {
191
192 // Modules with no documented classes may be specified on the
193 // command line to specify a service provider, allow these.
194 if (configuration.getSpecifiedModuleElements().isEmpty() &&
195 configuration.getIncludedTypeElements().isEmpty()) {
196 messages.error("doclet.No_Public_Classes_To_Document");
197 return;
198 }
199 if (!configuration.setOptions()) {
200 return;
201 }
202 messages.notice("doclet.build_version",
203 configuration.getDocletVersion());
204 ClassTree classtree = new ClassTree(configuration, configuration.getOptions().noDeprecated);
205
206 generateClassFiles(docEnv, classtree);
207
208 ElementListWriter.generate(configuration);
209 generatePackageFiles(classtree);
210 generateModuleFiles();
211
212 generateOtherFiles(docEnv, classtree);
213 configuration.tagletManager.printReport();
214 }
215
216 /**
217 * Generate additional documentation that is added to the API documentation.
218 *
219 * @param docEnv the DocletEnvironment
220 * @param classtree the data structure representing the class tree
221 * @throws DocletException if there is a problem while generating the documentation
222 */
223 protected void generateOtherFiles(DocletEnvironment docEnv, ClassTree classtree)
224 throws DocletException {
|