/[classpath]/gjdoc/src/gnu/classpath/tools/doclets/xmldoclet/Driver.java
ViewVC logotype

Diff of /gjdoc/src/gnu/classpath/tools/doclets/xmldoclet/Driver.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.30 by julian, Mon Nov 22 12:42:22 2004 UTC revision 1.31 by julian, Mon Nov 22 22:29:58 2004 UTC
# Line 41  import java.util.List; Line 41  import java.util.List;
41  import java.util.Map;  import java.util.Map;
42  import java.util.Set;  import java.util.Set;
43  import java.util.HashSet;  import java.util.HashSet;
44    import java.util.TreeMap;
45  import java.util.StringTokenizer;  import java.util.StringTokenizer;
46    
47  import gnu.classpath.tools.gjdoc.TemporaryStore;  import gnu.classpath.tools.gjdoc.TemporaryStore;
# Line 921  public class Driver { Line 922  public class Driver {
922                 else if ("-nocomment".equals(optionTag)) {                 else if ("-nocomment".equals(optionTag)) {
923                    docTransletOptions.nocomment = true;                    docTransletOptions.nocomment = true;
924                 }                 }
925                   else if ("-nohelp".equals(optionTag)) {
926                      docTransletOptions.nohelp = true;
927                   }
928                   else if ("-splitindex".equals(optionTag)) {
929                      docTransletOptions.splitindex = true;
930                   }
931              }              }
932    
933              // Use current directory if target directory hasn't been set.              // Use current directory if target directory hasn't been set.
# Line 1087  public class Driver { Line 1094  public class Driver {
1094    
1095              closeTargetFile();              closeTargetFile();
1096    
1097                createIndexByName();
1098    
1099    
1100    
1101              // Output information on all classes for which documentation              // Output information on all classes for which documentation
1102              // has been made available via the Doclet API              // has been made available via the Doclet API
# Line 1113  public class Driver { Line 1123  public class Driver {
1123                    
1124           // Copy DTD files to temporary directory           // Copy DTD files to temporary directory
1125                    
1126             // FIXME: try to solve this via jar: URLs. but this will
1127             // probably break libxmlj compatibility (?)
1128            
1129           String[] resources = new String[] {           String[] resources = new String[] {
1130              "gjdoc.dtd",              "gjdoc.dtd",
1131                "gjdoc-alphaindex.dtd",
1132              "dbcentx.mod",              "dbcentx.mod",
1133              "ent/iso-amsa.ent",              "ent/iso-amsa.ent",
1134              "ent/iso-amsb.ent",              "ent/iso-amsb.ent",
# Line 1383  public class Driver { Line 1397  public class Driver {
1397        else if ("-notree".equals(option)) return 1;        else if ("-notree".equals(option)) return 1;
1398        else if ("-nohelp".equals(option)) return 1;        else if ("-nohelp".equals(option)) return 1;
1399        else if ("-nonavbar".equals(option)) return 1;        else if ("-nonavbar".equals(option)) return 1;
1400          else if ("-splitindex".equals(option)) return 1;
1401    
1402        else return -1;        else return -1;
1403     }     }
# Line 1579  public class Driver { Line 1594  public class Driver {
1594        in.close();        in.close();
1595        out.close();        out.close();
1596     }     }
1597    
1598       private void createIndexByName() throws IOException {
1599          // Create index
1600    
1601          // Collect index
1602                
1603          Map indexMap = new TreeMap(new Comparator() {
1604                public int compare(Object o1, Object o2) {
1605                   return o1.toString().toLowerCase().compareTo(o2.toString().toLowerCase());
1606                }
1607             });
1608    
1609          // Add packages to index
1610    
1611          PackageDoc[] packages = rootDoc.specifiedPackages();
1612          for (int i=0, ilim=packages.length; i<ilim; ++i) {
1613             PackageDoc c = packages[i];
1614             indexMap.put(c.name(), c);
1615          }
1616    
1617          // Add classes, fields and methods to index
1618    
1619          ClassDoc[] sumclasses = rootDoc.classes();
1620          for (int i=0, ilim=sumclasses.length; i<ilim; ++i) {
1621             ClassDoc c = sumclasses[i];
1622             if (null == c.containingClass()) {
1623                indexMap.put(c.name(), c);
1624             }
1625             else {
1626                indexMap.put(c.name().substring(c.containingClass().name().length() + 1), c);
1627             }
1628             FieldDoc[] fields = c.fields();
1629             for (int j=0, jlim=fields.length; j<jlim; ++j) {
1630                indexMap.put(fields[j].name(), fields[j]);
1631             }
1632             MethodDoc[] methods = c.methods();
1633             for (int j=0, jlim=methods.length; j<jlim; ++j) {
1634                MethodDoc method = methods[j];
1635                StringBuffer signature = new StringBuffer();
1636                signature.append(method.name());
1637                signature.append('(');
1638                Parameter[] parameters = method.parameters();
1639                for (int k=0, klim=parameters.length; k<klim; ++k) {
1640                   if (k > 0) {
1641                      signature.append(", ");
1642                   }
1643                   signature.append(parameters[k].typeName());
1644                }
1645                signature.append(')');
1646                indexMap.put(signature.toString(), method);
1647             }
1648          }
1649    
1650          // Assign output stream
1651    
1652          setTargetFile("alphaindex.xml");
1653    
1654          // Output XML document header
1655    
1656          println(0, "<?xml version=\"1.0\"?>");
1657          println("<!DOCTYPE gjdoc SYSTEM \"dtd/gjdoc-alphaindex.dtd\">");
1658          println();
1659          printOpenTag(0, "alphaindex xmlns=\"http://www.w3.org/TR/REC-html40\" xmlns:gjdoc=\"http://www.gnu.org/software/cp-tools/gjdocxml\"");
1660          
1661          Iterator it = indexMap.keySet().iterator();
1662    
1663          char previousCategoryLetter = '\0';
1664          boolean categoryOpen = false;
1665    
1666          while (it.hasNext()) {
1667             String key = (String)it.next();
1668             Doc entry = (Doc)indexMap.get(key);
1669    
1670             char firstChar = Character.toUpperCase(key.charAt(0));
1671             if (firstChar != previousCategoryLetter) {
1672                if (categoryOpen) {
1673                   printCloseTag(1, "category");
1674                }
1675                printOpenTag(1, "category letter=\"" + firstChar + "\"");
1676                categoryOpen = true;
1677                previousCategoryLetter = firstChar;
1678             }
1679    
1680             printOpenTag(2, "entry name=\"" + key + "\"");
1681             if (entry instanceof PackageDoc) {
1682                printAtomTag(3, "isPackage");
1683             }
1684             else if (entry instanceof ClassDoc) {
1685                printAtomTag(3, "isClass");
1686                ClassDoc centry = (ClassDoc)entry;
1687                currentClass = centry;
1688                printAtomTag(3, "containingPackage name=\"" + centry.containingPackage().name() + "\"");
1689                if (null != centry.containingClass()) {
1690                   printAtomTag(3, "containingClass name=\"" + centry.containingClass().name() + "\"");
1691                }
1692                if (centry.isInterface()) {
1693                   printAtomTag(3, "isInterface");
1694                }
1695                if (centry.isException()) {
1696                   printAtomTag(3, "isException");
1697                }
1698                if (centry.isError()) {
1699                   printAtomTag(3, "isError");
1700                }
1701                if (centry.isOrdinaryClass()) {
1702                   printAtomTag(3, "isOrdinaryClass");
1703                }
1704             }
1705             else if (entry instanceof ProgramElementDoc) {
1706                ProgramElementDoc pentry = (ProgramElementDoc)entry;
1707                currentClass = pentry.containingClass();
1708                printAtomTag(3, "containingPackage name=\"" + pentry.containingPackage().name() + "\"");
1709                printAtomTag(3, "containingClass name=\"" + pentry.containingClass().name() + "\"");
1710                if (pentry.isMethod()) {
1711                   printAtomTag(3, "isMethod");
1712                   ExecutableMemberDoc mentry = (ExecutableMemberDoc)pentry;
1713                   printAtomTag(3, "signature full=\""+mentry.signature()+"\" flat=\""+mentry.flatSignature()+"\"");
1714                   printAtomTag(3, "method name=\"" + mentry.name() + "\"");
1715                }
1716                if (pentry.isField()) {
1717                   printAtomTag(3, "isField");
1718                }
1719             }
1720    
1721             Tag[] tags = entry.firstSentenceTags();
1722             for (int i=0, ilim=tags.length; i<ilim; ++i) {
1723                Tag tag = tags[i];
1724                if (tag.firstSentenceTags().length>0) {
1725                   printOpenTag(3, "firstSentenceTags", false);
1726                   outputTags(4, tag.firstSentenceTags(), false, CONTEXT_TYPE);
1727                   printCloseTag(3, "firstSentenceTags");
1728                }
1729             }
1730    
1731    
1732             printCloseTag(2, "entry");
1733          }
1734    
1735          if (categoryOpen) {
1736             printCloseTag(1, "category");
1737          }
1738    
1739          printCloseTag(0, "alphaindex");
1740    
1741          closeTargetFile();
1742       }
1743  }  }

Legend:
Removed from v.1.30  
changed lines
  Added in v.1.31

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26