java-gobject-introspection r175 - in trunk: . src src/org/gnome/gir/compiler
- From: walters svn gnome org
- To: svn-commits-list gnome org
- Subject: java-gobject-introspection r175 - in trunk: . src src/org/gnome/gir/compiler
- Date: Sat, 7 Feb 2009 03:57:01 +0000 (UTC)
Author: walters
Date: Sat Feb 7 03:57:01 2009
New Revision: 175
URL: http://svn.gnome.org/viewvc/java-gobject-introspection?rev=175&view=rev
Log:
More documentation generation
Clean up how we generate all .gir files. Fix logging.
Modified:
trunk/.classpath
trunk/src/jgir-docgen.in
trunk/src/org/gnome/gir/compiler/DocFactory.java
trunk/wscript
Modified: trunk/.classpath
==============================================================================
--- trunk/.classpath (original)
+++ trunk/.classpath Sat Feb 7 03:57:01 2009
@@ -12,5 +12,6 @@
<classpathentry kind="lib" path="/usr/share/java/gnu-getopt.jar"/>
<classpathentry kind="lib" path="/usr/share/java/stringtemplate.jar"/>
<classpathentry kind="lib" path="/usr/share/java/antlr.jar"/>
+ <classpathentry kind="lib" path="/usr/share/java/commons-io.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: trunk/src/jgir-docgen.in
==============================================================================
--- trunk/src/jgir-docgen.in (original)
+++ trunk/src/jgir-docgen.in Sat Feb 7 03:57:01 2009
@@ -14,4 +14,4 @@
args.extend(java_opts)
args.extend(['-cp', classpath, 'org.gnome.gir.compiler.DocFactory'])
args.extend(sys.argv[1:])
-os.execvp(args[0], args)
\ No newline at end of file
+os.execvp(args[0], args)
Modified: trunk/src/org/gnome/gir/compiler/DocFactory.java
==============================================================================
--- trunk/src/org/gnome/gir/compiler/DocFactory.java (original)
+++ trunk/src/org/gnome/gir/compiler/DocFactory.java Sat Feb 7 03:57:01 2009
@@ -1,7 +1,5 @@
package org.gnome.gir.compiler;
-import gobject.runtime.GErrorException;
-
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
@@ -14,7 +12,7 @@
import java.util.Collections;
import java.util.List;
import java.util.logging.Formatter;
-import java.util.logging.Level;
+import java.util.logging.Handler;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import java.util.logging.StreamHandler;
@@ -23,7 +21,7 @@
import org.antlr.stringtemplate.StringTemplate;
import org.antlr.stringtemplate.StringTemplateGroup;
-import org.gnome.gir.repository.Repository;
+import org.apache.commons.io.IOUtils;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Attribute;
import org.objectweb.asm.ClassReader;
@@ -37,7 +35,7 @@
static final Logger logger = Logger.getLogger("org.gnome.gir.Compiler");
static {
- logger.addHandler(new StreamHandler(System.err, new Formatter() {
+ logger.addHandler(new StreamHandler(System.out, new Formatter() {
@Override
public String format(LogRecord record) {
return String.format("%s%n", record.getMessage());
@@ -46,11 +44,9 @@
logger.setUseParentHandlers(false);
}
- private final Repository repo;
private final StringTemplateGroup templates;
- private DocFactory(Repository repo) {
- this.repo = repo;
+ private DocFactory() {
this.templates = new StringTemplateGroup("templates");
}
@@ -325,9 +321,8 @@
private static final String replaceInternals(String path) {
return path.replace('$', '.').replace('/', '.');
}
-
- private void generateOne(File jarpath, File girpath, File outpath) throws Exception {
- repo.hashCode();
+
+ private void generateJavaSource(File jarpath, File girpath, File outpath) throws Exception {
ZipFile zf = new ZipFile(jarpath);
List<? extends ZipEntry> entries = Collections.list(zf.entries());
@@ -355,7 +350,6 @@
for (ZipEntry subEntry : entries) {
if (!subEntry.getName().startsWith(innerPrefix))
continue;
- System.err.println("write " + subEntry);
String innerStripped = stripInternals(subEntry.getName().replace(".class", ""));
String innerStrippedSuffix = innerStripped.substring(name.length()+1);
if (innerStrippedSuffix.contains("$"))
@@ -373,34 +367,53 @@
javaOut.close();
logger.info("Wrote " + javaOutPath);
- }
+ }
+ }
+
+ private void runJavadoc(String namespace, File outpath) throws Exception {
+ logger.info("Creating javadoc for " + namespace);
+ Process proc = new ProcessBuilder("javadoc", "-classpath", System.getProperty("java.class.path") + ":.",
+ "-d", outpath.toString(), "gobject.introspection." + namespace).redirectErrorStream(true)
+ .directory(outpath).start();
+ proc.getOutputStream().close();
+ for (Handler h : logger.getHandlers())
+ h.flush();
+ System.out.flush();
+ IOUtils.copy(proc.getInputStream(), System.out);
+ int ecode = proc.waitFor();
+ if (ecode != 0)
+ throw new IOException("javadoc command failed with exit code " + ecode);
+ logger.info("Done creating javadoc for " + namespace);
+ }
+
+ private void generateOne(String namespace, File jarpath, File girpath, File outpath) throws Exception {
+ File subdir = new File(outpath, namespace);
+ subdir.mkdirs();
+ logger.info("Creating java source for " + namespace + " in " + subdir.toString());
+ generateJavaSource(jarpath, girpath, subdir);
+
+ runJavadoc(namespace, subdir);
+ }
+
+ private static File getJarPath(String namespace, String version) {
+ return new File(CodeFactory.getTypelibDir(), String.format("%s-%s.jar", namespace, version));
}
- public static void generate(File girpath, File outpath) throws Exception {
+ public static void generate(File girpath, File jarpath, File outpath) throws Exception {
String base = girpath.getName();
CodeFactory.NsVer nsver = CodeFactory.NsVer.parse(base);
if (CodeFactory.namespaceIsExcluded(nsver.namespace))
return;
- Repository repo = new Repository();
- try {
- repo.require(nsver.namespace, nsver.version);
- } catch (GErrorException e) {
- logger.log(Level.WARNING, "Failed to load namespace " + nsver.namespace, e);
- return;
- }
-
- File jarpath = CodeFactory.getJarPath(repo, nsver.namespace);
-
- DocFactory factory = new DocFactory(repo);
+ DocFactory factory = new DocFactory();
- factory.generateOne(jarpath, girpath, outpath);
+ factory.generateOne(nsver.namespace, jarpath, girpath, outpath);
}
private static File getGirDir() {
return new File(System.getenv("GIRDIR"));
- }
+ }
public static void generateAll(File outpath) throws Exception {
File[] girs = getGirDir().listFiles(new FilenameFilter() {
@@ -410,8 +423,13 @@
}
});
+ logger.info("Discovered " + girs.length + " gir files");
for (File gir : girs) {
- generate(gir, outpath);
+ logger.info("Generating for " + gir.toString());
+ String base = gir.getName();
+ CodeFactory.NsVer nsver = CodeFactory.NsVer.parse(base);
+ File jarpath = getJarPath(nsver.namespace, nsver.version);
+ generate(gir, jarpath, outpath);
}
}
@@ -420,7 +438,11 @@
generateAll(new File(args[1]));
else if (args[0].endsWith(".gir")) {
File gir = new File(args[0]);
- generate(gir, new File(args[1]));
+ File wd = gir.getParentFile();
+ if (wd == null)
+ wd = new File(System.getProperty("user.dir"));
+ File jar = new File(wd, gir.getName().replace(".gir", ".jar"));
+ generate(gir, jar, new File(args[1]));
}
}
}
Modified: trunk/wscript
==============================================================================
--- trunk/wscript (original)
+++ trunk/wscript Sat Feb 7 03:57:01 2009
@@ -74,6 +74,7 @@
conf.find_jpackage_jar('gnu.getopt')
conf.find_jpackage_jar('stringtemplate')
conf.find_jpackage_jar('antlr')
+ conf.find_jpackage_jar('commons-io')
print "Using CLASSPATH: %r" % (conf.env['CLASSPATH'],)
# feature('jar')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]