📄 documentationgenerator.java
字号:
/* * YALE - Yet Another Learning Environment * Copyright (C) 2002, 2003 * Simon Fischer, Ralf Klinkenberg, Ingo Mierswa, * Katharina Morik, Oliver Ritthoff * Artificial Intelligence Unit * Computer Science Department * University of Dortmund * 44221 Dortmund, Germany * email: yale@ls8.cs.uni-dortmund.de * web: http://yale.cs.uni-dortmund.de/ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA. */package edu.udo.cs.yale.doc;import edu.udo.cs.yale.tools.ParameterService;import edu.udo.cs.yale.tools.LogService;import edu.udo.cs.yale.tools.param.OperatorParams;import edu.udo.cs.yale.tools.param.GroupTree;import edu.udo.cs.yale.tools.OperatorService;import edu.udo.cs.yale.operator.Operator;import com.sun.javadoc.RootDoc;import java.io.File;import java.io.FileWriter;import java.io.FileReader;import java.io.PrintWriter;import java.io.IOException;import java.util.List;import java.util.LinkedList;import java.util.Iterator;import java.util.Collections;import java.util.Collection;import java.util.Set;public class DocumentationGenerator { private OperatorDocGenerator generator; private static RootDoc rootDoc = null; public DocumentationGenerator(OperatorDocGenerator generator) { this.generator = generator; } private void getRootDoc() { getRootDoc(new File(ParameterService.getYaleHome(), "src"+File.separator), "edu"); } private void getRootDoc(File srcDir, String subpackages) { LogService.logMessage("Starting javadoc!", LogService.TASK); String[] javadocargs = { "-sourcepath", srcDir.getAbsolutePath(), "-doclet", this.getClass().getName(), "-breakiterator", "-subpackages", subpackages }; com.sun.tools.javadoc.Main.execute(javadocargs); if (rootDoc == null) LogService.logMessage("RootDoc not set!", LogService.ERROR); } public static boolean start(RootDoc rootDoc) { LogService.logMessage("RootDoc generated!", LogService.TASK); DocumentationGenerator.rootDoc = rootDoc; return true; } public void generateAll(PrintWriter out) { Collection groups = OperatorParams.getGroups().getSubGroups(); Iterator i = groups.iterator(); while (i.hasNext()) { GroupTree group = (GroupTree)i.next(); generator.beginGroup(group.getName(), out); Set operators = group.getAllOperators(); Iterator ops = operators.iterator(); while (ops.hasNext()) { String name = (String)ops.next(); try { Class operatorClass = OperatorParams.getOperatorClass(name); Operator operator = (Operator)operatorClass.newInstance(); generator.generateDoc(operator, rootDoc, out); } catch (Exception e) { e.printStackTrace(out); } } out.println(); generator.endGroup(group.getName(), out); } out.println(); out.flush(); } public static void main(String[] argv) throws IOException { OperatorDocGenerator opDocGen = new LatexOperatorDocGenerator(); if (argv.length == 0) { ParameterService.init(); File file = new File(ParameterService.getYaleHome(), "tutorial"+File.separator+"OperatorsGenerated.tex"); LogService.logMessage("Generating class documentation to '"+file+"'.", LogService.TASK); PrintWriter out = new PrintWriter(new FileWriter(file)); DocumentationGenerator docGen = new DocumentationGenerator(opDocGen); docGen.getRootDoc(); docGen.generateAll(new PrintWriter(new FileWriter(file))); } else if (argv.length == 4) { try { OperatorService.registerOperators(argv[0], new FileReader(argv[0]), null); } catch (IOException e) { LogService.logMessage("Cannot read 'operators.xml'.", LogService.ERROR); } File file = new File(argv[3]); LogService.logMessage("Generating class documentation to '"+file+"'.", LogService.TASK); PrintWriter out = new PrintWriter(new FileWriter(file)); DocumentationGenerator docGen = new DocumentationGenerator(opDocGen); docGen.getRootDoc(new File(argv[1]), argv[2]); docGen.generateAll(new PrintWriter(new FileWriter(file))); out.close(); } else { LogService.logMessage("usage: java edu.udo.cs.yale.doc.DocumentationGenerator or\n"+ " java edu.udo.cs.yale.doc.DocumentationGenerator operatordesc srcdir subpackages outputfile", LogService.WARNING); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -