Thread: [Nice-commit] Nice/src/nice/tools/doc htmlwriter.nice,1.6,1.7
Brought to you by:
bonniot
From: Francis B. <fb...@us...> - 2004-03-22 15:27:46
|
Update of /cvsroot/nice/Nice/src/nice/tools/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9894/src/nice/tools/doc Modified Files: htmlwriter.nice Log Message: nicedoc now documents global variables as well. a couple of minor clean-ups also done. Index: htmlwriter.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/doc/htmlwriter.nice,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** htmlwriter.nice 21 Mar 2004 01:40:59 -0000 1.6 --- htmlwriter.nice 22 Mar 2004 15:17:22 -0000 1.7 *************** *** 96,99 **** --- 96,125 ---- } + write(gv@GlobalVarDeclaration, packageName) { + //Handle global variables + + //Initialise a FileWriter + File dir = new File(outdir, packageName.replace('.',java.io.File.separator)); + if(!dir.exists() && !dir.mkdirs()) { + System.err.println("Error creating directory structure"); + } + + BufferedWriter writer = new BufferedWriter + (new FileWriter(new File(dir, "gv_" gv.getName() ".html"))); + + writer.write(getHeader(gv.getName().toString())); + + writer.write("<h1>Global Variable " + gv.getName() + "</h1>"); + + writer.write(htmlSafe(gv.toString())); + + writer.write("<p>"); + writer.write("nicedoc comments would go here..."); + writer.write("</p>"); + + writer.write(getFooter()); + writer.close(); + } + write(m@MethodDeclaration, packageName) { //Handle methods *************** *** 105,115 **** } - /*String fileName = m.getName().toString(); - //we only want information after the last . - //that is, nice.lang.Maybe -> Maybe - //System.out.println("Raw filename: " + fileName); - fileName = fileName.replace('/', "@slash"); - fileName = fileName.replace('.', "@dot");*/ - BufferedWriter writer = new BufferedWriter (new FileWriter(new File(dir, calculateMethodFilename(m)))); --- 131,134 ---- *************** *** 143,149 **** writer.write(getHeader("Package " + p.getName())); ! //we need to separate class and methods ArrayList<ClassDefinition.Class> classes = new ArrayList(); ArrayList<MethodDeclaration> methods = new ArrayList(); for(Definition d : p.getDefinitions().definitions()) { if(d instanceof ClassDefinition.Class) { --- 162,169 ---- writer.write(getHeader("Package " + p.getName())); ! //we need to separate class, methods, and global variables ArrayList<ClassDefinition.Class> classes = new ArrayList(); ArrayList<MethodDeclaration> methods = new ArrayList(); + ArrayList<GlobalVarDeclaration> globalVars = new ArrayList(); for(Definition d : p.getDefinitions().definitions()) { if(d instanceof ClassDefinition.Class) { *************** *** 156,161 **** methods.add(d.getDeclaration()); } else { ! System.err.println("Ignoring " + d); } } --- 176,184 ---- methods.add(d.getDeclaration()); } + else if(d instanceof GlobalVarDeclaration) { + globalVars.add(d); + } else { ! System.err.println("Ignoring " d "\n (type " d.getClass() ")"); } } *************** *** 181,186 **** } writer.write("</ul>\n"); ! ! writer.write(getFooter()); writer.close(); --- 204,216 ---- } writer.write("</ul>\n"); ! ! //Write global vars ! writer.write("<b>Global Variables:</b>\n"); ! writer.write("<ul>\n"); ! for(GlobalVarDeclaration gv : globalVars) { ! writer.write("<li><a href='gv_" gv.getName() ".html'>" gv.getName() "</a></li>\n"); ! } ! writer.write("</ul>\n"); ! writer.write(getFooter()); writer.close(); *************** *** 213,217 **** /** Converts a String that may contain characters such as '<' to one that will display ! * properly in html. Submitted by S. Bayer to http://www.rgagnon.com/javadetails/java-0306.html. */ String htmlSafe(String s) { --- 243,248 ---- /** Converts a String that may contain characters such as '<' to one that will display ! * properly in html. Submitted by S. Bayer to http://www.rgagnon.com/javadetails/java-0306.html, ! * although I've made some changes. */ String htmlSafe(String s) { *************** *** 251,258 **** sb.append("<br/>"); else { ! //char and int or not related in nice, so we can't do a direct cast //hence, we use int(c) instead of (int)c ! int ci = 0xffff & int(c); ! if(ci < 160) // nothing special only 7 Bit sb.append(c); --- 282,292 ---- sb.append("<br/>"); else { ! //char and int are not related in nice, so we can't do a direct cast //hence, we use int(c) instead of (int)c ! int ci = int(c); ! /*This was originally 160 in S. Bayer version, but I couldn't see the sense of that ! *so I changed it to 128, as 127 is the maximum value of an ascii character ! */ ! if(ci < 128) // nothing special only 7 Bit sb.append(c); |