Hello everybody!

        Lately, I've been learning to use Javadoc, and I noticed that
Ant does't handle multiple link parameters, which can come quite
handy if you want your API documetation to have links to Java API
and Xerces and Xalan and everything else you use. This makes the
documentation look much cooler :)
        Adding this functionality was quite simple, and it works for
me now. My patch is enclosed at the end of the message. There are
two long lines that probably got wrapped, sorry...

Rafal Krzewski

-cut----------------------------------------------------------------------------------------------------
diff -u -r1.8 Javadoc.java
--- Javadoc.java        2000/06/14 12:42:14     1.8
+++ Javadoc.java        2000/06/28 00:28:32
@@ -358,13 +358,42 @@
                 argList.addElement("-bottom");
                 argList.addElement(bottom);
             }
+
+            // JavaDoc documentation from JDK 1.3:
+            //   Multiple Links - You can supply multiple -link options to 
link to any number of external generated documents.
+            //   Known Bug - Javadoc 1.2 has a known bug which prevents you 
from supplying more than one -link command. This is
fixed in 1.2.2.
+
+            // Ant javadoc task rules for list attribute:
+            //   Args are comma-delimited.
             if (link != null) {
-                argList.addElement("-link");
-                argList.addElement(link);
+                StringTokenizer tok = new StringTokenizer(link, ",", false);
+                while (tok.hasMoreTokens()) {
+                    String lnk = tok.nextToken().trim();
+                    argList.addElement("-link");
+                    argList.addElement(lnk);
+                }
             }
+
+            // JavaDoc documentation from JDK 1.3:
+            //   Include -linkoffline once for each generated document you 
want to refer to.
+
+            // Ant javadoc task rules for list attribute:
+            //   Args are comma-delimited.
+            //   Each arg is 2 space-delimited strings.
+            //   E.g., linkoffline="http://xml.apache.org/apiDocs/
${src.dir}/javadoc/xerces-packages,http://xml.apache.org/xalan/apidocs 
${src.dir}/javadoc/xalan-packages"
             if (linkoffline != null) {
-                argList.addElement("-linkoffline");
-                argList.addElement(linkoffline);
+                StringTokenizer tok = new StringTokenizer(linkoffline, ",", 
false);
+                while (tok.hasMoreTokens()) {
+                    String lnk = tok.nextToken().trim();
+                    int space = lnk.indexOf(" ");
+                    if (space > 0) {
+                        String remote = lnk.substring(0, space);
+                        String local = lnk.substring(space + 1);
+                        argList.addElement("-linkoffline");
+                        argList.addElement(remote);
+                        argList.addElement(local);
+                    }
+                }
             }

             // Javadoc 1.2 rules:
-cut----------------------------------------------------------------------------------------------------

Reply via email to