From ddf2d89e8a6b6b5b175b52b52a8d72e16bea3856 Mon Sep 17 00:00:00 2001 From: David Habib Date: Thu, 22 Jan 2015 18:07:36 -0800 Subject: [PATCH] ran the java formatter over all the source to cleanup tabs/spaces and indentation. --- src/org/salesforce/apexdoc/ApexDoc.css | 404 +++---- src/org/salesforce/apexdoc/ApexDoc.java | 1034 +++++++++-------- src/org/salesforce/apexdoc/ApexModel.java | 48 +- src/org/salesforce/apexdoc/ClassGroup.java | 12 +- src/org/salesforce/apexdoc/ClassModel.java | 220 ++-- src/org/salesforce/apexdoc/Constants.java | 76 +- src/org/salesforce/apexdoc/FileManager.java | 762 ++++++------ src/org/salesforce/apexdoc/MethodModel.java | 81 +- src/org/salesforce/apexdoc/PropertyModel.java | 45 +- 9 files changed, 1372 insertions(+), 1310 deletions(-) diff --git a/src/org/salesforce/apexdoc/ApexDoc.css b/src/org/salesforce/apexdoc/ApexDoc.css index 869b4bb..400e279 100644 --- a/src/org/salesforce/apexdoc/ApexDoc.css +++ b/src/org/salesforce/apexdoc/ApexDoc.css @@ -1,277 +1,293 @@ body { - font-family: "ProximaNovaSoft-Regular", Calibri, "Gill Sans", "Gill Sans MT", Candara, Segoe, "Segoe UI", Arial, sans-serif; - font-size:100%; - margin:0px; - padding:0px; + font-family: "ProximaNovaSoft-Regular", Calibri, "Gill Sans", + "Gill Sans MT", Candara, Segoe, "Segoe UI", Arial, sans-serif; + font-size: 100%; + margin: 0px; + padding: 0px; } /* the top page banner */ .topsection { - background-color: #003672; - width:100%; - height:110px; - color:white; + background-color: #003672; + width: 100%; + height: 110px; + color: white; } + .topsection td { - color:white; - padding:8px; + color: white; + padding: 8px; } + .topsection a { - color: white; + color: white; } /* the area that holds the documentation on the right of the page */ .contentTD { - font-size: 100%; - width: 80%; - padding-left: 12px; - vertical-align: top; + font-size: 100%; + width: 80%; + padding-left: 12px; + vertical-align: top; } /* the horizontal section headers that declares the Class name */ .section-title { background-color: #003672; /* rgb(155,203,236); */ - color:white; - font-size: 100%; - font-weight:bold; - padding:5px 5px 5px 14px; - margin: 0 0 2px -12px; + color: white; + font-size: 100%; + font-weight: bold; + padding: 5px 5px 5px 14px; + margin: 0 0 2px -12px; } + .section-title a { - color:white; + color: white; } /* the horizontal section headers that declares the Methods & Properties subsections */ .subsection-title { - color: #51638A; - border-top: 1px solid #51638A; - font-size: 100%; - padding:2px; - margin: 0 0 12px 0; + color: #51638A; + border-top: 1px solid #51638A; + font-size: 100%; + padding: 2px; + margin: 0 0 12px 0; } + .subsection-container { - padding: 0 0 0 14px; + padding: 0 0 0 14px; } /* the horizontal header for each Method */ .methodHeader { - font-size: 1em; - color: #51638A; - border-top: 1px solid #51638A; - margin: 20px 0 0 0; - padding: 4px 0 2px 0; + font-size: 1em; + color: #51638A; + border-top: 1px solid #51638A; + margin: 20px 0 0 0; + padding: 4px 0 2px 0; } /* properties is used to display the table of class properties */ .properties { + } + .properties td { - vertical-align: top; - padding-right: 10px; + vertical-align: top; + padding-right: 10px; } + .clsPropertyName { - font-size:.9em; - font-weight: bold; + font-size: .9em; + font-weight: bold; } + .clsPropertyDeclaration a { - font-family:Courier; - font-size:.8em; - font-weight:normal; - color:MediumBlue; + font-family: Courier; + font-size: .8em; + font-weight: normal; + color: MediumBlue; } + .clsPropertyDescription { - font-size:.9em; - font-weight:normal; -} + font-size: .9em; + font-weight: normal; +} /* the class's signature line */ .classSignature { - font-family:Courier; - font-size:.9em; - font-weight:normal; - text-indent: -15px; - padding: 6px 0 4px 15px; + font-family: Courier; + font-size: .9em; + font-weight: normal; + text-indent: -15px; + padding: 6px 0 4px 15px; } + .classSignature a { - color: mediumblue; + color: mediumblue; } /* the description, author, date for the class */ .classDetails { - font-size: .9em; - padding-left: 2px; + font-size: .9em; + padding-left: 2px; } /* signatures of methods and properties */ .hostedSourceLink { text-decoration: initial; - color: mediumblue; + color: mediumblue; } + .hostedSourceLink:hover { - text-decoration: underline; + text-decoration: underline; } /* method table of contents related classes */ .methodTOCEntry { - font-size: .9em; - color: mediumblue; + font-size: .9em; + color: mediumblue; } + .methodTOCEntry:visited { - font-size: .9em; - color: purple; + font-size: .9em; + color: purple; } + .methodTOCDescription { - font-size: .9em; - text-overflow: ellipsis; - overflow: hidden; - line-height: .9em; - height: .9em; + font-size: .9em; + text-overflow: ellipsis; + overflow: hidden; + line-height: .9em; + height: .9em; } /* method listing related classes */ .methodSignature { - font-family: Courier; - font-size: .8em; - font-weight: normal; - color: MediumBlue; - text-indent: -15px; - padding-left: 15px; + font-family: Courier; + font-size: .8em; + font-weight: normal; + color: MediumBlue; + text-indent: -15px; + padding-left: 15px; } + .methodDescription { - font-size: .9em; - margin: .5em 0 0 0; + font-size: .9em; + margin: .5em 0 0 0; } + .methodSubTitle { - font-size: .9em; - color: #51638A; - font-weight: bold; - margin: .7em 0 0 0; + font-size: .9em; + color: #51638A; + font-weight: bold; + margin: .7em 0 0 0; } + .paramName { - font-size: .9em; - font-weight: bold; - font-style: italic; - margin: 0 0 0 .5em; + font-size: .9em; + font-weight: bold; + font-style: italic; + margin: 0 0 0 .5em; } + .paramDescription { - font-size: .9em; - margin: 0 0 0 1em; + font-size: .9em; + margin: 0 0 0 1em; } + .methodReturns { - font-size: .9em; - margin: 0 0 0 1em; -} - - - - /* SIDEBAR CSS */ - div.navbar { - font-size:.9em; - font-weight: normal; - } - - div.navbar a:hover { - text-decoration: underline; - } - - - .sidebar ul { - margin: 0; - padding: 0; - list-style: none; - background: lightgray; - } - - div.navbar ul li { - margin-bottom: 0px; - margin-left: 0px; - padding: 2px; - background: #f2f5f6; - border: 1px solid #dce4e7; - border-top-color: #fff; - } - - div.navbar ul li:hover { - background: gray; - } - - div.navbar ul li.subitem:hover { - background: gray; - } - - div.navbar ul li.subitem { - background: #eaeef0; - border-bottom: 0; - border-top: 0; - } - - div.navbar { - border-top: 1px solid #dce4e7; - } - - div.navbar ul li a { - display: block; - text-decoration: none; - padding: 5px 5px 5px 10px; - color: black; - } - - div.navbar ul li a:hover { - color: #fff; - background: none; - } - - div.navbar ul li.nav-selected { - background: LightGray; - } - - .nav-section-title { - display: block; - text-decoration: none; - padding: 5px 5px 5px 10px; - color: black; - } - - li.collapsed .caret { - float: right; - width: 0; - height: 0; - display: inline-block; - vertical-align: top; - content: ""; - margin-top: 8px; - margin-left: 2px; - border-top: 4px solid #000; - border-bottom: 0px; - border-right: 4px solid transparent; - border-left: 4px solid transparent; - } - - li .caret { - float: right; - width: 0; - height: 0; - display: inline-block; - vertical-align: top; - content: ""; - margin-top: 8px; - margin-left: 2px; - border-top: none; - border-bottom: 4px solid #000; - border-right: 4px solid transparent; - border-left: 4px solid transparent; - } - - .sub-nav-item { - margin-left: 20px; - } - - div.navbar ul li a.scopeglobal { - } - - div.navbar ul li a.scopeprivate { - } + font-size: .9em; + margin: 0 0 0 1em; +} + +/* SIDEBAR CSS */ +div.navbar { + font-size: .9em; + font-weight: normal; +} + +div.navbar a:hover { + text-decoration: underline; +} + +.sidebar ul { + margin: 0; + padding: 0; + list-style: none; + background: lightgray; +} + +div.navbar ul li { + margin-bottom: 0px; + margin-left: 0px; + padding: 2px; + background: #f2f5f6; + border: 1px solid #dce4e7; + border-top-color: #fff; +} + +div.navbar ul li:hover { + background: gray; +} + +div.navbar ul li.subitem:hover { + background: gray; +} + +div.navbar ul li.subitem { + background: #eaeef0; + border-bottom: 0; + border-top: 0; +} + +div.navbar { + border-top: 1px solid #dce4e7; +} + +div.navbar ul li a { + display: block; + text-decoration: none; + padding: 5px 5px 5px 10px; + color: black; +} + +div.navbar ul li a:hover { + color: #fff; + background: none; +} + +div.navbar ul li.nav-selected { + background: LightGray; +} + +.nav-section-title { + display: block; + text-decoration: none; + padding: 5px 5px 5px 10px; + color: black; +} + +li.collapsed .caret { + float: right; + width: 0; + height: 0; + display: inline-block; + vertical-align: top; + content: ""; + margin-top: 8px; + margin-left: 2px; + border-top: 4px solid #000; + border-bottom: 0px; + border-right: 4px solid transparent; + border-left: 4px solid transparent; +} + +li .caret { + float: right; + width: 0; + height: 0; + display: inline-block; + vertical-align: top; + content: ""; + margin-top: 8px; + margin-left: 2px; + border-top: none; + border-bottom: 4px solid #000; + border-right: 4px solid transparent; + border-left: 4px solid transparent; +} + +.sub-nav-item { + margin-left: 20px; +} + +div.navbar ul li a.scopeglobal { +} - /* END - SIDEBAR STYLES */ +div.navbar ul li a.scopeprivate { + +} +/* END - SIDEBAR STYLES */ \ No newline at end of file diff --git a/src/org/salesforce/apexdoc/ApexDoc.java b/src/org/salesforce/apexdoc/ApexDoc.java index 1e86b74..985ef55 100644 --- a/src/org/salesforce/apexdoc/ApexDoc.java +++ b/src/org/salesforce/apexdoc/ApexDoc.java @@ -9,551 +9,557 @@ import java.io.PrintStream; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; -import java.util.TreeMap; import java.util.Stack; +import java.util.TreeMap; public class ApexDoc { - public static FileManager fm; - public static String[] rgstrScope; - public static String[] rgstrArgs; - - public ApexDoc(){ - try{ - File file = new File("apex_doc_log.txt"); - FileOutputStream fos = new FileOutputStream(file); - PrintStream ps = new PrintStream(fos); - System.setOut(ps); - }catch(Exception ex){} + public static FileManager fm; + public static String[] rgstrScope; + public static String[] rgstrArgs; + + public ApexDoc() { + try { + File file = new File("apex_doc_log.txt"); + FileOutputStream fos = new FileOutputStream(file); + PrintStream ps = new PrintStream(fos); + System.setOut(ps); + } catch (Exception ex) { + } + } + + // public entry point when called from the command line. + public static void main(String[] args) { + try { + RunApexDoc(args, null); + } catch (Exception ex) { + ex.printStackTrace(); + System.out.println(ex.getMessage()); + printHelp(); + System.exit(-1); + } + } + + // public entry point when called from the Eclipse PlugIn. + // assumes PlugIn previously sets rgstrArgs before calling run. + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + RunApexDoc(rgstrArgs, monitor); + } + + // public main routine which is used by both command line invocation and + // Eclipse PlugIn invocation + public static void RunApexDoc(String[] args, IProgressMonitor monitor) { + String sourceDirectory = ""; + String targetDirectory = ""; + String homefilepath = ""; + String authorfilepath = ""; + String hostedSourceURL = ""; + + // parse command line parameters + for (int i = 0; i < args.length; i++) { + + if (args[i] == null) { + continue; + } else if (args[i].equalsIgnoreCase("-s")) { + sourceDirectory = args[++i]; + } else if (args[i].equalsIgnoreCase("-g")) { + hostedSourceURL = args[++i]; + } else if (args[i].equalsIgnoreCase("-t")) { + targetDirectory = args[++i]; + } else if (args[i].equalsIgnoreCase("-h")) { + homefilepath = args[++i]; + } else if (args[i].equalsIgnoreCase("-a")) { + authorfilepath = args[++i]; + } else if (args[i].equalsIgnoreCase("-p")) { + String strScope = args[++i]; + rgstrScope = strScope.split(";"); + } else { + printHelp(); + System.exit(-1); + } + } + + // default scope to global and public if not specified + if (rgstrScope == null || rgstrScope.length == 0) { + rgstrScope = new String[3]; + rgstrScope[0] = "global"; + rgstrScope[1] = "public"; + rgstrScope[3] = "webService"; } - - - // public entry point when called from the command line. - public static void main(String[] args) { - try { - RunApexDoc(args, null); - } catch(Exception ex) { - ex.printStackTrace(); - System.out.println(ex.getMessage()); - printHelp(); - System.exit(-1); + + // find all the files to parse + fm = new FileManager(targetDirectory); + ArrayList files = fm.getFiles(sourceDirectory); + ArrayList cModels = new ArrayList(); + + if (monitor != null) { + // each file is parsed, html created, written to disk. + // but for each class file, there is an xml file we'll ignore. + // plus we add 2 for the author file and home file loading. + monitor.beginTask("ApexDoc - documenting your Apex Class files.", (files.size() / 2) * 3 + 2); + } + // parse each file, creating a class model for it + for (File fromFile : files) { + String fromFileName = fromFile.getAbsolutePath(); + if (fromFileName.endsWith(".cls")) { + ClassModel cModel = parseFileContents(fromFileName); + if (cModel != null) { + cModels.add(cModel); } + } + if (monitor != null) + monitor.worked(1); } - - - // public entry point when called from the Eclipse PlugIn. - // assumes PlugIn previously sets rgstrArgs before calling run. - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - RunApexDoc(rgstrArgs, monitor); - } - - // public main routine which is used by both command line invocation and Eclipse PlugIn invocation - public static void RunApexDoc(String[] args, IProgressMonitor monitor) { - String sourceDirectory = ""; - String targetDirectory = ""; - String homefilepath = ""; - String authorfilepath = ""; - String hostedSourceURL = ""; - - // parse command line parameters - for (int i = 0; i < args.length; i++) { - - if (args[i] == null) { - continue; - } else if (args[i].equalsIgnoreCase("-s")) { - sourceDirectory = args[++i]; - } else if (args[i].equalsIgnoreCase("-g")) { - hostedSourceURL = args[++i]; - } else if (args[i].equalsIgnoreCase("-t")) { - targetDirectory = args[++i]; - } else if (args[i].equalsIgnoreCase("-h")) { - homefilepath = args[++i]; - } else if (args[i].equalsIgnoreCase("-a")) { - authorfilepath = args[++i]; - } else if (args[i].equalsIgnoreCase("-p")) { - String strScope = args[++i]; - rgstrScope = strScope.split(";"); - } else { - printHelp(); - System.exit(-1); - } + + // create our Groups + TreeMap mapClassNameToClassGroup = createMapClassNameToClassGroup(cModels, sourceDirectory); + + // load up optional specified file templates + String projectDetail = fm.parseHTMLFile(authorfilepath); + if (monitor != null) + monitor.worked(1); + String homeContents = fm.parseHTMLFile(homefilepath); + if (monitor != null) + monitor.worked(1); + + // create our set of HTML files + fm.createDoc(mapClassNameToClassGroup, cModels, projectDetail, homeContents, hostedSourceURL, monitor); + if (monitor != null) + monitor.done(); + + // we are done! + System.out.println("ApexDoc has completed!"); + } + + private static void printHelp() { + System.out.println("ApexDoc - a tool for generating documentation from Salesforce Apex code class files.\n"); + System.out.println(" Invalid Arguments detected. The correct syntax is:\n"); + System.out.println("apexdoc -s [-t ] [-g ] [-h ] [-a ] [-p ]\n"); + System.out.println(" - The folder location which contains your apex .cls classes"); + System.out.println(" - Optional. Specifies your target folder where documentation will be generated."); + System.out.println(" - Optional. Specifies a URL where the source is hosted (so ApexDoc can provide links to your source)."); + System.out.println(" - Optional. Specifies the html file that contains the contents for the home page\'s content area."); + System.out.println(" - Optional. Specifies the text file that contains project information for the documentation header."); + System.out.println(" - Optional. Semicolon seperated list of scopes to document. Defaults to 'global;public'. "); + } + + private static TreeMap createMapClassNameToClassGroup(ArrayList cModels, + String sourceDirectory) { + TreeMap map = new TreeMap(); + for (ClassModel cmodel : cModels) { + String strGroup = cmodel.getClassGroup(); + String strGroupContent = cmodel.getClassGroupContent(); + if (strGroupContent != null) + strGroupContent = sourceDirectory + "/" + strGroupContent; + ClassGroup cg; + if (strGroup != null) { + cg = map.get(strGroup); + if (cg == null) + cg = new ClassGroup(strGroup, strGroupContent); + else if (cg.getContentSource() == null) + cg.setContentSource(strGroupContent); + // put the new or potentially modified ClassGroup back in the map + map.put(strGroup, cg); + } + } + return map; + } + + public static ClassModel parseFileContents(String filePath) { + try { + FileInputStream fstream = new FileInputStream(filePath); + // Get the object of DataInputStream + DataInputStream in = new DataInputStream(fstream); + BufferedReader br = new BufferedReader(new InputStreamReader(in)); + String strLine; + boolean commentsStarted = false; + int nestedCurlyBraceDepth = 0; + ArrayList lstComments = new ArrayList(); + ClassModel cModel = null; + ClassModel cModelParent = null; + Stack cModels = new Stack(); + + // DH: Consider using java.io.StreamTokenizer to read the file a + // token at a time? + // + // new strategy notes: + // any line with " class " is a class definition + // any line with scope (global, public, private) is a class, method, + // or property definition. + // you can detect a method vs. a property by the presence of ( )'s + // you can also detect properties by get; or set;, though they may + // not be on the first line. + // in apex, methods that start with get and take no params, or set + // with 1 param, are actually properties. + // + + int iLine = 0; + while ((strLine = br.readLine()) != null) { + iLine++; + + strLine = strLine.trim(); + if (strLine.length() == 0) + continue; + + // ignore anything after // style comments. this allows hiding of tokens from ApexDoc. + int ich = strLine.indexOf("//"); + if (ich > -1) { + strLine = strLine.substring(0, ich); } - - // default scope to global and public if not specified - if (rgstrScope == null || rgstrScope.length == 0) { - rgstrScope = new String[3]; - rgstrScope[0] = "global"; - rgstrScope[1] = "public"; - rgstrScope[3] = "webService"; + + // gather up our comments + if (strLine.startsWith("/*")) { + commentsStarted = true; + if (strLine.endsWith("*/")) { + strLine = strLine.replace("*/", ""); + commentsStarted = false; + } + lstComments.add(strLine); + continue; } - - // find all the files to parse - fm = new FileManager(targetDirectory); - ArrayList files = fm.getFiles(sourceDirectory); - ArrayList cModels = new ArrayList(); - - if (monitor != null) { - // each file is parsed, html created, written to disk. - // but for each class file, there is an xml file we'll ignore. - // plus we add 2 for the author file and home file loading. - monitor.beginTask("ApexDoc - documenting your Apex Class files.", (files.size()/2) * 3 + 2); + + if (commentsStarted && strLine.endsWith("*/")) { + strLine = strLine.replace("*/", ""); + lstComments.add(strLine); + commentsStarted = false; + continue; } - // parse each file, creating a class model for it - for (File fromFile : files) { - String fromFileName = fromFile.getAbsolutePath(); - if (fromFileName.endsWith(".cls")) { - ClassModel cModel = parseFileContents(fromFileName); - if (cModel != null) { - cModels.add(cModel); - } - } - if (monitor != null) monitor.worked(1); + + if (commentsStarted) { + lstComments.add(strLine); + continue; } - - // create our Groups - TreeMap mapClassNameToClassGroup = createMapClassNameToClassGroup(cModels, sourceDirectory); - - // load up optional specified file templates - String projectDetail = fm.parseHTMLFile(authorfilepath); - if (monitor != null) monitor.worked(1); - String homeContents = fm.parseHTMLFile(homefilepath); - if (monitor != null) monitor.worked(1); - - // create our set of HTML files - fm.createDoc(mapClassNameToClassGroup, cModels, projectDetail, homeContents, hostedSourceURL, monitor); - if (monitor != null) monitor.done(); - - // we are done! - System.out.println("ApexDoc has completed!"); - } - - private static void printHelp(){ - System.out.println("ApexDoc - a tool for generating documentation from Salesforce Apex code class files.\n"); - System.out.println(" Invalid Arguments detected. The correct syntax is:\n"); - System.out.println("apexdoc -s [-t ] [-g ] [-h ] [-a ] [-p ]\n"); - System.out.println(" - The folder location which contains your apex .cls classes"); - System.out.println(" - Optional. Specifies your target folder where documentation will be generated."); - System.out.println(" - Optional. Specifies a URL where the source is hosted (so ApexDoc can provide links to your source)."); - System.out.println(" - Optional. Specifies the html file that contains the contents for the home page\'s content area.");; - System.out.println(" - Optional. Specifies the text file that contains project information for the documentation header."); - System.out.println(" - Optional. Semicolon seperated list of scopes to document. Defaults to 'global;public'. "); - } - - private static TreeMap createMapClassNameToClassGroup(ArrayList cModels, String sourceDirectory) { - TreeMap map = new TreeMap(); - for (ClassModel cmodel : cModels) { - String strGroup = cmodel.getClassGroup(); - String strGroupContent = cmodel.getClassGroupContent(); - if (strGroupContent != null) - strGroupContent = sourceDirectory + "/" + strGroupContent; - ClassGroup cg; - if (strGroup != null) { - cg = map.get(strGroup); - if (cg == null) - cg = new ClassGroup(strGroup, strGroupContent); - else if (cg.getContentSource() == null) - cg.setContentSource(strGroupContent); - // put the new or potentially modified ClassGroup back in the map - map.put(strGroup, cg); + + // keep track of our nesting so we know which class we are in + int openCurlies = countChars(strLine, '{'); + int closeCurlies = countChars(strLine, '}'); + nestedCurlyBraceDepth += openCurlies; + nestedCurlyBraceDepth -= closeCurlies; + + // if we are in a nested class, and we just got back to nesting level 1, + // then we are done with the nested class, and should set its props and methods. + if (nestedCurlyBraceDepth == 1 && cModels.size() > 1 && cModel != null) { + cModels.pop(); + cModel = cModels.peek(); + continue; } - } - return map; - } - - public static ClassModel parseFileContents(String filePath){ - try{ - FileInputStream fstream = new FileInputStream(filePath); - // Get the object of DataInputStream - DataInputStream in = new DataInputStream(fstream); - BufferedReader br = new BufferedReader(new InputStreamReader(in)); - String strLine; - boolean commentsStarted = false; - int nestedCurlyBraceDepth = 0; - ArrayList lstComments = new ArrayList(); - ClassModel cModel = null; - ClassModel cModelParent = null; - Stack cModels = new Stack(); - - // DH: Consider using java.io.StreamTokenizer to read the file a token at a time? - // - // new strategy notes: - // any line with " class " is a class definition - // any line with scope (global, public, private) is a class, method, or property definition. - // you can detect a method vs. a property by the presence of ( )'s - // you can also detect properties by get; or set;, though they may not be on the first line. - // in apex, methods that start with get and take no params, or set with 1 param, are actually properties. - // - - int iLine = 0; - while ((strLine = br.readLine()) != null) { + + // ignore anything after an =. this avoids confusing properties with methods. + ich = strLine.indexOf("="); + if (ich > -1) { + strLine = strLine.substring(0, ich); + } + + // ignore anything after an {. this avoids confusing properties with methods. + ich = strLine.indexOf("{"); + if (ich > -1) { + strLine = strLine.substring(0, ich); + } + + // ignore lines not dealing with scope + if (strContainsScope(strLine) == null && + // interface methods don't have scope + !(cModel != null && cModel.getIsInterface() && strLine.contains("("))) { + continue; + } + + // look for a class + if ((strLine.toLowerCase().contains(" class ") || strLine.toLowerCase().contains(" interface "))) { + + // create the new class + ClassModel cModelNew = new ClassModel(cModelParent); + fillClassModel(cModelParent, cModelNew, strLine, lstComments, iLine); + lstComments.clear(); + + // keep track of the new class, as long as it wasn't a single liner {} + // but handle not having any curlies on the class line! + if (openCurlies == 0 || openCurlies != closeCurlies) { + cModels.push(cModelNew); + cModel = cModelNew; + } + + // add it to its parent (or track the parent) + if (cModelParent != null) + cModelParent.addChildClass(cModelNew); + else + cModelParent = cModelNew; + continue; + } + + // look for a method + if (strLine.contains("(")) { + // deal with a method over multiple lines. + while (!strLine.contains(")")) { + strLine += br.readLine(); iLine++; - - strLine = strLine.trim(); - if (strLine.length() == 0) - continue; - - // ignore anything after // style comments. this allows hiding of tokens from ApexDoc. - int ich = strLine.indexOf("//"); - if (ich > -1) { - strLine = strLine.substring(0, ich); - } - - // gather up our comments - if (strLine.startsWith("/*")) { - commentsStarted = true; - if (strLine.endsWith("*/")) { - strLine = strLine.replace("*/", ""); - commentsStarted = false; - } - lstComments.add(strLine); - continue; - } - - if (commentsStarted && strLine.endsWith("*/")) { - strLine = strLine.replace("*/", ""); - lstComments.add(strLine); - commentsStarted = false; - continue; - } - - if (commentsStarted) { - lstComments.add(strLine); - continue; - } - - // keep track of our nesting so we know which class we are in - int openCurlies = countChars(strLine, '{'); - int closeCurlies = countChars(strLine, '}'); - nestedCurlyBraceDepth += openCurlies; - nestedCurlyBraceDepth -= closeCurlies; - - // if we are in a nested class, and we just got back to nesting level 1, - // then we are done with the nested class, and should set its props and methods. - if (nestedCurlyBraceDepth == 1 && cModels.size() > 1 && cModel != null) { - cModels.pop(); - cModel = cModels.peek(); - continue; - } - - // ignore anything after an =. this avoids confusing properties with methods. - ich = strLine.indexOf("="); - if (ich > -1) { - strLine = strLine.substring(0, ich); - } - - // ignore anything after an {. this avoids confusing properties with methods. - ich = strLine.indexOf("{"); - if (ich > -1) { - strLine = strLine.substring(0, ich); - } - - // ignore lines not dealing with scope - if (strContainsScope(strLine) == null && - // interface methods don't have scope - !(cModel != null && cModel.getIsInterface() && strLine.contains("("))) { - continue; - } - - // look for a class - if ((strLine.toLowerCase().contains(" class ") || strLine.toLowerCase().contains(" interface "))) { - - // create the new class - ClassModel cModelNew = new ClassModel(cModelParent); - fillClassModel(cModelParent, cModelNew, strLine, lstComments, iLine); - lstComments.clear(); - - // keep track of the new class, as long as it wasn't a single liner {} - // but handle not having any curlies on the class line! - if (openCurlies == 0 || openCurlies != closeCurlies) { - cModels.push(cModelNew); - cModel = cModelNew; - } - - // add it to its parent (or track the parent) - if (cModelParent != null) - cModelParent.addChildClass(cModelNew); - else - cModelParent = cModelNew; - continue; - } - - // look for a method - if (strLine.contains("(")) { - // deal with a method over multiple lines. - while (!strLine.contains(")")) { - strLine += br.readLine(); - iLine++; - } - MethodModel mModel = new MethodModel(); - fillMethodModel(mModel, strLine, lstComments, iLine); - cModel.getMethods().add(mModel); - lstComments.clear(); - continue; - } - - // handle set & get within the property - if (strLine.contains(" get ") || - strLine.contains(" set ") || - strLine.contains(" get;") || - strLine.contains(" set;") || - strLine.contains(" get{") || - strLine.contains(" set{")) - continue; - - // must be a property - PropertyModel propertyModel = new PropertyModel(); - fillPropertyModel(propertyModel, strLine, lstComments, iLine); - cModel.getProperties().add(propertyModel); - lstComments.clear(); - continue; - } + MethodModel mModel = new MethodModel(); + fillMethodModel(mModel, strLine, lstComments, iLine); + cModel.getMethods().add(mModel); + lstComments.clear(); + continue; + } + + // handle set & get within the property + if (strLine.contains(" get ") || + strLine.contains(" set ") || + strLine.contains(" get;") || + strLine.contains(" set;") || + strLine.contains(" get{") || + strLine.contains(" set{")) + continue; + + // must be a property + PropertyModel propertyModel = new PropertyModel(); + fillPropertyModel(propertyModel, strLine, lstComments, iLine); + cModel.getProperties().add(propertyModel); + lstComments.clear(); + continue; - - // Close the input stream - in.close(); - // we only want to return the parent class - return cModelParent; - }catch (Exception e) { //Catch exception if any - System.err.println("Error: " + e.getMessage()); } - - return null; + + // Close the input stream + in.close(); + // we only want to return the parent class + return cModelParent; + } catch (Exception e) { // Catch exception if any + System.err.println("Error: " + e.getMessage()); } - public static String strContainsScope(String str) { - str = str.toLowerCase(); - for (int i = 0; i < rgstrScope.length; i++) { - if (str.toLowerCase().contains(rgstrScope[i].toLowerCase() + " ")) { - return rgstrScope[i]; - } + return null; + } + + public static String strContainsScope(String str) { + str = str.toLowerCase(); + for (int i = 0; i < rgstrScope.length; i++) { + if (str.toLowerCase().contains(rgstrScope[i].toLowerCase() + " ")) { + return rgstrScope[i]; } - return null; } - - private static void fillPropertyModel(PropertyModel propertyModel, String name, ArrayList lstComments, int iLine) { - propertyModel.setNameLine(name, iLine); - boolean inDescription = false; - for (String comment : lstComments) { - comment = comment.trim(); - int idxStart = comment.toLowerCase().indexOf("@description"); - if (idxStart != -1) { - propertyModel.setDescription(comment.substring(idxStart + 13).trim()); - inDescription = true; - continue; - } - - // handle multiple lines for description. - if (inDescription) { - int i; - for (i = 0; i < comment.length(); i++) { - char ch = comment.charAt(i); - if (ch != '*' && ch != ' ') - break; - } - if (i < comment.length()) { - propertyModel.setDescription(propertyModel.getDescription() + ' ' + comment.substring(i)); - } - continue; - } + return null; + } + + private static void fillPropertyModel(PropertyModel propertyModel, String name, ArrayList lstComments, + int iLine) { + propertyModel.setNameLine(name, iLine); + boolean inDescription = false; + for (String comment : lstComments) { + comment = comment.trim(); + int idxStart = comment.toLowerCase().indexOf("@description"); + if (idxStart != -1) { + propertyModel.setDescription(comment.substring(idxStart + 13).trim()); + inDescription = true; + continue; + } + + // handle multiple lines for description. + if (inDescription) { + int i; + for (i = 0; i < comment.length(); i++) { + char ch = comment.charAt(i); + if (ch != '*' && ch != ' ') + break; } - } - - private static void fillMethodModel(MethodModel mModel, String name, ArrayList lstComments, int iLine){ - mModel.setNameLine(name, iLine); - boolean inDescription = false; - for (String comment : lstComments) { - comment = comment.trim(); - int idxStart = comment.toLowerCase().indexOf("@description"); - if(idxStart != -1){ - if (comment.length() > idxStart + 13) - mModel.setDescription(comment.substring(idxStart + 13).trim()); - inDescription = true; - continue; - } - - idxStart = comment.toLowerCase().indexOf("@author"); - if(idxStart != -1){ - mModel.setAuthor(comment.substring(idxStart + 8).trim()); - inDescription = false; - continue; - } - - idxStart = comment.toLowerCase().indexOf("@date"); - if(idxStart != -1){ - mModel.setDate(comment.substring(idxStart + 5).trim()); - inDescription = false; - continue; - } - - idxStart = comment.toLowerCase().indexOf("@return"); - if(idxStart != -1){ - mModel.setReturns(comment.substring(idxStart + 8).trim()); - inDescription = false; - continue; - } - - idxStart = comment.toLowerCase().indexOf("@param"); - if(idxStart != -1){ - mModel.getParams().add(comment.substring(idxStart + 6).trim()); - inDescription = false; - continue; - } - - // handle multiple lines for description. - if (inDescription) { - int i; - for (i = 0; i < comment.length(); i++) { - char ch = comment.charAt(i); - if (ch != '*' && ch != ' ') - break; - } - if (i < comment.length()) { - mModel.setDescription(mModel.getDescription() + ' ' + comment.substring(i)); - } - continue; - } + if (i < comment.length()) { + propertyModel.setDescription(propertyModel.getDescription() + ' ' + comment.substring(i)); } + continue; + } } + } + + private static void fillMethodModel(MethodModel mModel, String name, ArrayList lstComments, int iLine) { + mModel.setNameLine(name, iLine); + boolean inDescription = false; + for (String comment : lstComments) { + comment = comment.trim(); + int idxStart = comment.toLowerCase().indexOf("@description"); + if (idxStart != -1) { + if (comment.length() > idxStart + 13) + mModel.setDescription(comment.substring(idxStart + 13).trim()); + inDescription = true; + continue; + } + + idxStart = comment.toLowerCase().indexOf("@author"); + if (idxStart != -1) { + mModel.setAuthor(comment.substring(idxStart + 8).trim()); + inDescription = false; + continue; + } + + idxStart = comment.toLowerCase().indexOf("@date"); + if (idxStart != -1) { + mModel.setDate(comment.substring(idxStart + 5).trim()); + inDescription = false; + continue; + } + + idxStart = comment.toLowerCase().indexOf("@return"); + if (idxStart != -1) { + mModel.setReturns(comment.substring(idxStart + 8).trim()); + inDescription = false; + continue; + } + + idxStart = comment.toLowerCase().indexOf("@param"); + if (idxStart != -1) { + mModel.getParams().add(comment.substring(idxStart + 6).trim()); + inDescription = false; + continue; + } - private static void fillClassModel(ClassModel cModelParent, ClassModel cModel, String name, ArrayList lstComments, int iLine){ - cModel.setNameLine(name, iLine); - if (name.toLowerCase().contains(" interface ")) - cModel.setIsInterface(true); - boolean inDescription = false; - for (String comment : lstComments) { - comment = comment.trim(); - int idxStart = comment.toLowerCase().indexOf("@description"); - if(idxStart != -1){ - cModel.setDescription(comment.substring(idxStart + 12).trim()); - inDescription = true; - continue; - } - - idxStart = comment.toLowerCase().indexOf("@author"); - if(idxStart != -1){ - cModel.setAuthor(comment.substring(idxStart + 7).trim()); - inDescription = false; - continue; - } - - idxStart = comment.toLowerCase().indexOf("@date"); - if(idxStart != -1){ - cModel.setDate(comment.substring(idxStart + 5).trim()); - inDescription = false; - continue; - } - - idxStart = comment.toLowerCase().indexOf("@group "); // needed to include space to not match group-content. - if(idxStart != -1){ - cModel.setClassGroup(comment.substring(idxStart + 6).trim()); - inDescription = false; - continue; - } - - idxStart = comment.toLowerCase().indexOf("@group-content"); - if(idxStart != -1){ - cModel.setClassGroupContent(comment.substring(idxStart + 14).trim()); - inDescription = false; - continue; - } - - // handle multiple lines for description. - if (inDescription) { - int i; - for (i = 0; i < comment.length(); i++) { - char ch = comment.charAt(i); - if (ch != '*' && ch != ' ') - break; - } - if (i < comment.length()) { - cModel.setDescription(cModel.getDescription() + ' ' + comment.substring(i)); - } - continue; - } + // handle multiple lines for description. + if (inDescription) { + int i; + for (i = 0; i < comment.length(); i++) { + char ch = comment.charAt(i); + if (ch != '*' && ch != ' ') + break; } + if (i < comment.length()) { + mModel.setDescription(mModel.getDescription() + ' ' + comment.substring(i)); + } + continue; + } } + } + + private static void fillClassModel(ClassModel cModelParent, ClassModel cModel, String name, + ArrayList lstComments, int iLine) { + cModel.setNameLine(name, iLine); + if (name.toLowerCase().contains(" interface ")) + cModel.setIsInterface(true); + boolean inDescription = false; + for (String comment : lstComments) { + comment = comment.trim(); + int idxStart = comment.toLowerCase().indexOf("@description"); + if (idxStart != -1) { + cModel.setDescription(comment.substring(idxStart + 12).trim()); + inDescription = true; + continue; + } - - /************************************************************************* - * strPrevWord - * @param str - string to search - * @param iSearch - where to start searching backwards from - * @return - the previous word, or null if none found. - */ - public static String strPrevWord (String str, int iSearch) { - if (str == null) - return null; - if (iSearch >= str.length()) - return null; - - int iStart; - int iEnd; - for (iStart = iSearch-1, iEnd = 0; iStart >= 0; iStart--) { - if (iEnd == 0) { - if (str.charAt(iStart) == ' ') - continue; - iEnd = iStart+1; - } else if (str.charAt(iStart) == ' ') { - iStart++; - break; - } + idxStart = comment.toLowerCase().indexOf("@author"); + if (idxStart != -1) { + cModel.setAuthor(comment.substring(idxStart + 7).trim()); + inDescription = false; + continue; + } + + idxStart = comment.toLowerCase().indexOf("@date"); + if (idxStart != -1) { + cModel.setDate(comment.substring(idxStart + 5).trim()); + inDescription = false; + continue; + } + + idxStart = comment.toLowerCase().indexOf("@group "); // needed to include space to not match group-content. + if (idxStart != -1) { + cModel.setClassGroup(comment.substring(idxStart + 6).trim()); + inDescription = false; + continue; + } + + idxStart = comment.toLowerCase().indexOf("@group-content"); + if (idxStart != -1) { + cModel.setClassGroupContent(comment.substring(idxStart + 14).trim()); + inDescription = false; + continue; + } + + // handle multiple lines for description. + if (inDescription) { + int i; + for (i = 0; i < comment.length(); i++) { + char ch = comment.charAt(i); + if (ch != '*' && ch != ' ') + break; + } + if (i < comment.length()) { + cModel.setDescription(cModel.getDescription() + ' ' + comment.substring(i)); } - - if (iStart == -1) - return null; - else - return str.substring(iStart, iEnd); + continue; + } + } + } + + /************************************************************************* + * strPrevWord + * + * @param str + * - string to search + * @param iSearch + * - where to start searching backwards from + * @return - the previous word, or null if none found. + */ + public static String strPrevWord(String str, int iSearch) { + if (str == null) + return null; + if (iSearch >= str.length()) + return null; + + int iStart; + int iEnd; + for (iStart = iSearch - 1, iEnd = 0; iStart >= 0; iStart--) { + if (iEnd == 0) { + if (str.charAt(iStart) == ' ') + continue; + iEnd = iStart + 1; + } else if (str.charAt(iStart) == ' ') { + iStart++; + break; + } } - - /************************************************************************* - * @description Count the number of occurrences of character in the string - * @param str - * @param ch - * @return int - */ - private static int countChars(String str, char ch) { - int count = 0; - for (int i = 0; i < str.length(); ++i) { + + if (iStart == -1) + return null; + else + return str.substring(iStart, iEnd); + } + + /************************************************************************* + * @description Count the number of occurrences of character in the string + * @param str + * @param ch + * @return int + */ + private static int countChars(String str, char ch) { + int count = 0; + for (int i = 0; i < str.length(); ++i) { if (str.charAt(i) == ch) { - ++count; + ++count; } - } - return count; - } - - /* - private static void debug(ClassModel cModel){ - try{ - System.out.println("Class::::::::::::::::::::::::"); - if(cModel.getClassName() != null) System.out.println(cModel.getClassName()); - if(cModel.getNameLine() != null) System.out.println(cModel.getNameLine()); - System.out.println(cModel.getAuthor()); - System.out.println(cModel.getDescription()); - System.out.println(cModel.getDate()); - - System.out.println("Properties::::::::::::::::::::::::"); - for (PropertyModel property : cModel.getProperties()) { - System.out.println(property.getNameLine()); - System.out.println(property.getDescription()); - } - - System.out.println("Methods::::::::::::::::::::::::"); - for (MethodModel method : cModel.getMethods()) { - System.out.println(method.getMethodName()); - System.out.println(method.getAuthor()); - System.out.println(method.getDescription()); - System.out.println(method.getDate()); - for (String param : method.getParams()) { - System.out.println(param); - } - - } - - }catch (Exception e){ - e.printStackTrace(); - } } - */ + return count; + } + + /* + * private static void debug(ClassModel cModel){ try{ + * System.out.println("Class::::::::::::::::::::::::"); + * if(cModel.getClassName() != null) + * System.out.println(cModel.getClassName()); if(cModel.getNameLine() != + * null) System.out.println(cModel.getNameLine()); + * System.out.println(cModel.getAuthor()); + * System.out.println(cModel.getDescription()); + * System.out.println(cModel.getDate()); + * + * System.out.println("Properties::::::::::::::::::::::::"); for + * (PropertyModel property : cModel.getProperties()) { + * System.out.println(property.getNameLine()); + * System.out.println(property.getDescription()); } + * + * System.out.println("Methods::::::::::::::::::::::::"); for (MethodModel + * method : cModel.getMethods()) { + * System.out.println(method.getMethodName()); + * System.out.println(method.getAuthor()); + * System.out.println(method.getDescription()); + * System.out.println(method.getDate()); for (String param : + * method.getParams()) { System.out.println(param); } + * + * } + * + * }catch (Exception e){ e.printStackTrace(); } } + */ } \ No newline at end of file diff --git a/src/org/salesforce/apexdoc/ApexModel.java b/src/org/salesforce/apexdoc/ApexModel.java index 49c00a7..8555e15 100644 --- a/src/org/salesforce/apexdoc/ApexModel.java +++ b/src/org/salesforce/apexdoc/ApexModel.java @@ -2,47 +2,59 @@ public class ApexModel { public String getNameLine() { - return nameLine; + return nameLine; } + public int getInameLine() { return inameLine; -} + } + public void setNameLine(String nameLine, int iLine) { - this.nameLine = nameLine.trim(); - this.inameLine = iLine; - parseScope(); + this.nameLine = nameLine.trim(); + this.inameLine = iLine; + parseScope(); } + public String getDescription() { - return description == null ? "" : description; + return description == null ? "" : description; } + public void setDescription(String description) { - this.description = description; + this.description = description; } + public String getAuthor() { - return author == null ? "" : author; + return author == null ? "" : author; } + public void setAuthor(String author) { - this.author = author; + this.author = author; } + public String getDate() { - return date == null ? "" : date; + return date == null ? "" : date; } + public void setDate(String date) { - this.date = date; - } + this.date = date; + } + public String getReturns() { - return returns == null ? "" : returns; + return returns == null ? "" : returns; } + public void setReturns(String returns) { - this.returns = returns; + this.returns = returns; } + public String getScope() { return scope == null ? "" : scope; } + public void setScope(String scope) { - this.scope = scope; + this.scope = scope; } - + private void parseScope() { scope = null; if (nameLine != null) { @@ -51,7 +63,7 @@ private void parseScope() { scope = str; } } - + private String nameLine; private int inameLine; private String description; @@ -59,5 +71,5 @@ private void parseScope() { private String date; private String returns; private String scope; - + } \ No newline at end of file diff --git a/src/org/salesforce/apexdoc/ClassGroup.java b/src/org/salesforce/apexdoc/ClassGroup.java index dd78362..4bd84d8 100644 --- a/src/org/salesforce/apexdoc/ClassGroup.java +++ b/src/org/salesforce/apexdoc/ClassGroup.java @@ -8,29 +8,29 @@ public ClassGroup(String strName, String strContent) { this.strName = strName; this.strContentSource = strContent; } - + public String getName() { return strName; } - + public void setName(String strName) { this.strName = strName; } - + public String getContentSource() { return strContentSource; } - + public void setContentSource(String strContent) { this.strContentSource = strContent; } - + public String getContentFilename() { if (strContentSource != null) { int idx1 = strContentSource.lastIndexOf("/"); int idx2 = strContentSource.lastIndexOf("."); if (idx1 != -1 && idx2 != -1) { - return strContentSource.substring(idx1+1, idx2); + return strContentSource.substring(idx1 + 1, idx2); } } return null; diff --git a/src/org/salesforce/apexdoc/ClassModel.java b/src/org/salesforce/apexdoc/ClassModel.java index 46a5c1a..311f201 100644 --- a/src/org/salesforce/apexdoc/ClassModel.java +++ b/src/org/salesforce/apexdoc/ClassModel.java @@ -1,121 +1,123 @@ package org.salesforce.apexdoc; + import java.util.ArrayList; import java.util.TreeMap; public class ClassModel extends ApexModel { - - public ClassModel(ClassModel cmodelParent){ - methods = new ArrayList(); - properties = new ArrayList(); - this.cmodelParent = cmodelParent; - childClasses = new ArrayList(); - } - private ArrayList methods; - private ArrayList properties; - private String strClassGroup; - private String strClassGroupContent; - private ClassModel cmodelParent; - private ArrayList childClasses; - private boolean isInterface; - - public ArrayList getProperties() { - return properties; - } - - public ArrayList getPropertiesSorted() { - TreeMap tm = new TreeMap(); - for (PropertyModel prop : properties) - tm.put(prop.getPropertyName().toLowerCase(), prop); - return new ArrayList(tm.values()); - } + public ClassModel(ClassModel cmodelParent) { + methods = new ArrayList(); + properties = new ArrayList(); + this.cmodelParent = cmodelParent; + childClasses = new ArrayList(); + } - public void setProperties(ArrayList properties) { - this.properties = properties; - } + private ArrayList methods; + private ArrayList properties; + private String strClassGroup; + private String strClassGroupContent; + private ClassModel cmodelParent; + private ArrayList childClasses; + private boolean isInterface; - public ArrayList getMethods() { - return methods; - } + public ArrayList getProperties() { + return properties; + } - public ArrayList getMethodsSorted() { - TreeMap tm = new TreeMap(); - for (MethodModel method : methods) - tm.put(method.getMethodName().toLowerCase(), method); - return new ArrayList(tm.values()); - } + public ArrayList getPropertiesSorted() { + TreeMap tm = new TreeMap(); + for (PropertyModel prop : properties) + tm.put(prop.getPropertyName().toLowerCase(), prop); + return new ArrayList(tm.values()); + } - public void setMethods(ArrayList methods) { - this.methods = methods; - } - - public ArrayList getChildClasses() { - return childClasses; - } - - public void addChildClass(ClassModel child) { - childClasses.add(child); - } - - public String getClassName() { - String nameLine = getNameLine(); - String strParent = cmodelParent == null ? "" : cmodelParent.getClassName() + "."; - if (nameLine != null) nameLine = nameLine.trim(); - if (nameLine != null && nameLine.trim().length() > 0 ) { - int fFound = nameLine.toLowerCase().indexOf("class "); - int cch = 6; - if (fFound == -1) { - fFound = nameLine.toLowerCase().indexOf("interface "); - cch = 10; - } - if (fFound > -1) - nameLine = nameLine.substring(fFound + cch).trim(); - int lFound = nameLine.indexOf(" "); - if (lFound == -1) - return strParent + nameLine; - try { - String name = nameLine.substring(0, lFound); - return strParent + name; - } catch(Exception ex) { - return strParent + nameLine.substring(nameLine.lastIndexOf(" ") + 1); - } - } else { - return ""; - } - - } - - public String getTopmostClassName() { - if (cmodelParent != null) - return cmodelParent.getClassName(); - else - return getClassName(); - } - - public String getClassGroup() { - if (this.cmodelParent != null) - return cmodelParent.getClassGroup(); - else - return strClassGroup; - } - - public void setClassGroup(String strGroup) { - strClassGroup = strGroup; - } - - public String getClassGroupContent() { - return strClassGroupContent; - } - - public void setClassGroupContent(String strGroupContent) { - strClassGroupContent = strGroupContent; - } - - public boolean getIsInterface() { - return isInterface; - } - - public void setIsInterface(boolean isInterface) { - this.isInterface = isInterface; + public void setProperties(ArrayList properties) { + this.properties = properties; + } + + public ArrayList getMethods() { + return methods; + } + + public ArrayList getMethodsSorted() { + TreeMap tm = new TreeMap(); + for (MethodModel method : methods) + tm.put(method.getMethodName().toLowerCase(), method); + return new ArrayList(tm.values()); + } + + public void setMethods(ArrayList methods) { + this.methods = methods; + } + + public ArrayList getChildClasses() { + return childClasses; + } + + public void addChildClass(ClassModel child) { + childClasses.add(child); + } + + public String getClassName() { + String nameLine = getNameLine(); + String strParent = cmodelParent == null ? "" : cmodelParent.getClassName() + "."; + if (nameLine != null) + nameLine = nameLine.trim(); + if (nameLine != null && nameLine.trim().length() > 0) { + int fFound = nameLine.toLowerCase().indexOf("class "); + int cch = 6; + if (fFound == -1) { + fFound = nameLine.toLowerCase().indexOf("interface "); + cch = 10; + } + if (fFound > -1) + nameLine = nameLine.substring(fFound + cch).trim(); + int lFound = nameLine.indexOf(" "); + if (lFound == -1) + return strParent + nameLine; + try { + String name = nameLine.substring(0, lFound); + return strParent + name; + } catch (Exception ex) { + return strParent + nameLine.substring(nameLine.lastIndexOf(" ") + 1); + } + } else { + return ""; } + + } + + public String getTopmostClassName() { + if (cmodelParent != null) + return cmodelParent.getClassName(); + else + return getClassName(); + } + + public String getClassGroup() { + if (this.cmodelParent != null) + return cmodelParent.getClassGroup(); + else + return strClassGroup; + } + + public void setClassGroup(String strGroup) { + strClassGroup = strGroup; + } + + public String getClassGroupContent() { + return strClassGroupContent; + } + + public void setClassGroupContent(String strGroupContent) { + strClassGroupContent = strGroupContent; + } + + public boolean getIsInterface() { + return isInterface; + } + + public void setIsInterface(boolean isInterface) { + this.isInterface = isInterface; + } } diff --git a/src/org/salesforce/apexdoc/Constants.java b/src/org/salesforce/apexdoc/Constants.java index 65eb06e..254aad4 100644 --- a/src/org/salesforce/apexdoc/Constants.java +++ b/src/org/salesforce/apexdoc/Constants.java @@ -2,45 +2,45 @@ public class Constants { - public static final String HEADER_OPEN = "" + - "" + - "" + - "" + - " " + - "" + - ""; - - public static final String HEADER_CLOSE = - "" + - "" + - "" + - ""; - - public static final String FOOTER = "
" + - "
Powered By ApexDoc" + - "
"; - - public static final String ROOT_DIRECTORY = "ApexDocumentation"; - public static final String DEFAULT_HOME_CONTENTS = "

Project Home

"; - public static final String PROJECT_DETAIL = - "
" + - "" + - "" + - "" + + "" + + "
" + - "" + - "" + - "

Project Demo

" + - "Check out the gitHub project at:
" + - "http://github.com/SalesforceFoundation/ApexDoc
"; + public static final String HEADER_OPEN = "" + + "" + + "" + + "" + + " " + + "" + + ""; + + public static final String HEADER_CLOSE = + "
" + + "
"; + + public static final String FOOTER = "
" + + "
Powered By ApexDoc" + + "
"; + + public static final String ROOT_DIRECTORY = "ApexDocumentation"; + public static final String DEFAULT_HOME_CONTENTS = "

Project Home

"; + public static final String PROJECT_DETAIL = + "
" + + "" + + "" + + ""; - return str; + str += ""; + return str; + } + + /******************************************************************************************** + * @description main routine that creates an HTML file for each class + * specified + * @param mapClassNameToClassGroup + * @param cModels + * @param projectDetail + * @param homeContents + * @param hostedSourceURL + * @param monitor + */ + private void makeFile(TreeMap mapClassNameToClassGroup, ArrayList cModels, + String projectDetail, String homeContents, String hostedSourceURL, IProgressMonitor monitor) { + String links = "
" + + "" + + "" + + "

Project Demo

" + + "Check out the gitHub project at:
" + + "http://github.com/SalesforceFoundation/ApexDoc
"; - public static String getHeader(String projectDetail){ - String header; - if(projectDetail != null && projectDetail.trim().length() > 0){ - header = Constants.HEADER_OPEN + projectDetail; - }else{ - header = Constants.HEADER_OPEN + Constants.PROJECT_DETAIL + Constants.HEADER_CLOSE; - } - return header; + public static String getHeader(String projectDetail) { + String header; + if (projectDetail != null && projectDetail.trim().length() > 0) { + header = Constants.HEADER_OPEN + projectDetail; + } else { + header = Constants.HEADER_OPEN + Constants.PROJECT_DETAIL + Constants.HEADER_CLOSE; } + return header; + } } \ No newline at end of file diff --git a/src/org/salesforce/apexdoc/FileManager.java b/src/org/salesforce/apexdoc/FileManager.java index 44733b1..776bf4b 100644 --- a/src/org/salesforce/apexdoc/FileManager.java +++ b/src/org/salesforce/apexdoc/FileManager.java @@ -1,19 +1,29 @@ package org.salesforce.apexdoc; -import java.io.*; -import java.util.*; +import java.io.BufferedReader; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.TreeMap; public class FileManager { - FileOutputStream fos; + FileOutputStream fos; DataOutputStream dos; String path; public String header; public String APEX_DOC_PATH = ""; - public StringBuffer infoMessages ; - public FileManager(){ + public StringBuffer infoMessages; + + public FileManager() { infoMessages = new StringBuffer(); } - + private static String escapeHTML(String s) { StringBuilder out = new StringBuilder(Math.max(16, s.length())); for (int i = 0; i < s.length(); i++) { @@ -28,411 +38,421 @@ private static String escapeHTML(String s) { } return out.toString(); } - - public FileManager(String path){ + + public FileManager(String path) { infoMessages = new StringBuffer(); - - if(path == null || path.trim().length() == 0) - this.path = "."; + + if (path == null || path.trim().length() == 0) + this.path = "."; else - this.path = path; + this.path = path; } - - private boolean createHTML(TreeMap classTreeMap, IProgressMonitor monitor){ - try{ - if(path.endsWith("/") || path.endsWith("\\")){ - path += Constants.ROOT_DIRECTORY; // + "/" + fileName + ".html"; - }else{ - path += "/" + Constants.ROOT_DIRECTORY; // + "/" + fileName + ".html"; - } - - (new File(path)).mkdirs(); - - for(String fileName : classTreeMap.keySet()){ - String contents = classTreeMap.get(fileName); - fileName = path + "/" + fileName + ".html"; - File file= new File(fileName); - fos = new FileOutputStream(file); - dos=new DataOutputStream(fos); - dos.writeBytes(contents); - dos.close(); - fos.close(); - infoMessages.append(fileName + " Processed...\n"); - System.out.println(fileName + " Processed..."); - if (monitor != null) monitor.worked(1); - } - copy(path); - return true; - }catch(Exception e){ - - e.printStackTrace(); - } - - return false; + + private boolean createHTML(TreeMap classTreeMap, IProgressMonitor monitor) { + try { + if (path.endsWith("/") || path.endsWith("\\")) { + path += Constants.ROOT_DIRECTORY; // + "/" + fileName + ".html"; + } else { + path += "/" + Constants.ROOT_DIRECTORY; // + "/" + fileName + ".html"; + } + + (new File(path)).mkdirs(); + + for (String fileName : classTreeMap.keySet()) { + String contents = classTreeMap.get(fileName); + fileName = path + "/" + fileName + ".html"; + File file = new File(fileName); + fos = new FileOutputStream(file); + dos = new DataOutputStream(fos); + dos.writeBytes(contents); + dos.close(); + fos.close(); + infoMessages.append(fileName + " Processed...\n"); + System.out.println(fileName + " Processed..."); + if (monitor != null) + monitor.worked(1); + } + copy(path); + return true; + } catch (Exception e) { + + e.printStackTrace(); } - - private String strLinkfromModel(ApexModel model, String strClassName, String hostedSourceURL) { - return ""; + + return false; + } + + private String strLinkfromModel(ApexModel model, String strClassName, String hostedSourceURL) { + return ""; + } + + private String strHTMLScopingPanel() { + String str = "
"; + str += "Show: "; + + for (int i = 0; i < ApexDoc.rgstrScope.length; i++) { + str += "" + + ApexDoc.rgstrScope[i] + "  "; } - - private String strHTMLScopingPanel() { - String str = "
"; - str += "Show: "; - - for (int i = 0; i < ApexDoc.rgstrScope.length; i++) { - str += "" + - ApexDoc.rgstrScope[i] + "  "; - } - str += "
"; + links += strHTMLScopingPanel(); + links += ""; + links += getPageLinks(mapClassNameToClassGroup, cModels); + + if (homeContents != null && homeContents.trim().length() > 0) { + homeContents = links + ""; + homeContents = Constants.getHeader(projectDetail) + homeContents + Constants.FOOTER; + } else { + homeContents = Constants.DEFAULT_HOME_CONTENTS; + homeContents = links + ""; + homeContents = Constants.getHeader(projectDetail) + homeContents + Constants.FOOTER; } - - /******************************************************************************************** - * @description main routine that creates an HTML file for each class specified - * @param mapClassNameToClassGroup - * @param cModels - * @param projectDetail - * @param homeContents - * @param hostedSourceURL - * @param monitor - */ - private void makeFile(TreeMap mapClassNameToClassGroup, ArrayList cModels, - String projectDetail, String homeContents, String hostedSourceURL, IProgressMonitor monitor){ - String links = "
" + "

Home

" + homeContents + "
" + "

Home

" + homeContents + "
" ; - links += strHTMLScopingPanel(); - links += ""; - links += getPageLinks(mapClassNameToClassGroup, cModels); - - if(homeContents != null && homeContents.trim().length() > 0 ){ - homeContents = links + ""; - homeContents = Constants.getHeader(projectDetail) + homeContents + Constants.FOOTER; - }else{ - homeContents = Constants.DEFAULT_HOME_CONTENTS; - homeContents = links + ""; - homeContents = Constants.getHeader(projectDetail) + homeContents + Constants.FOOTER; - } - - - String fileName = ""; - TreeMap classTreeMap = new TreeMap(); - classTreeMap.put("index", homeContents); - - // create our Class Group content files - createClassGroupContent(classTreeMap, links, projectDetail, mapClassNameToClassGroup, cModels, monitor); - - for(ClassModel cModel : cModels){ - String contents = links; - if(cModel.getNameLine() != null && cModel.getNameLine().length() > 0){ - fileName = cModel.getClassName(); - contents += ""; - strHtml += Constants.FOOTER; - classTreeMap.put(cg.getContentFilename(), strHtml); - if (monitor != null) monitor.worked(1); - } + for (String strGroup : mapClassNameToClassGroup.keySet()) { + ClassGroup cg = mapClassNameToClassGroup.get(strGroup); + if (cg.getContentSource() != null) { + String cgContent = parseHTMLFile(cg.getContentSource()); + if (cgContent != "") { + String strHtml = Constants.getHeader(projectDetail) + links + ""; + strHtml += Constants.FOOTER; + classTreeMap.put(cg.getContentFilename(), strHtml); + if (monitor != null) + monitor.worked(1); } } } + } - /********************************************************************************************************** - * @description generate the HTML string for the Class Menu to display on each page. - * @param mapClassNameToClassGroup map that holds all the Class names, and their respective Class Group. - * @param cModels list of ClassModels - * @return String of HTML - */ - private String getPageLinks(TreeMap mapClassNameToClassGroup, ArrayList cModels){ - - String links = ""; + return links; + } + + private void docopy(String source, String target) throws Exception { - links += ""; - return links; + InputStream is = this.getClass().getResourceAsStream(source); + // InputStreamReader isr = new InputStreamReader(is); + // BufferedReader reader = new BufferedReader(isr); + FileOutputStream to = new FileOutputStream(target + "/" + source); + + byte[] buffer = new byte[4096]; + int bytesRead; + + while ((bytesRead = is.read(buffer)) != -1) { + to.write(buffer, 0, bytesRead); // write } - - private void docopy(String source, String target) throws Exception{ - - - InputStream is = this.getClass().getResourceAsStream(source); - //InputStreamReader isr = new InputStreamReader(is); - //BufferedReader reader = new BufferedReader(isr); - FileOutputStream to = new FileOutputStream(target + "/" + source); - - - - byte[] buffer = new byte[4096]; - int bytesRead; - - while ((bytesRead = is.read(buffer)) != -1){ - to.write(buffer, 0, bytesRead); // write + + to.flush(); + to.close(); + is.close(); + } + + private void copy(String toFileName) throws IOException, Exception { + docopy("apex_doc_logo.png", toFileName); + docopy("ApexDoc.css", toFileName); + docopy("ApexDoc.js", toFileName); + docopy("CollapsibleList.js", toFileName); + docopy("jquery-latest.js", toFileName); + docopy("toggle_block_btm.gif", toFileName); + docopy("toggle_block_stretch.gif", toFileName); + + } + + public ArrayList getFiles(String path) { + File folder = new File(path); + ArrayList listOfFilesToCopy = new ArrayList(); + if (folder != null) { + File[] listOfFiles = folder.listFiles(); + if (listOfFiles != null && listOfFiles.length > 0) { + for (int i = 0; i < listOfFiles.length; i++) { + if (listOfFiles[i].isFile()) { + listOfFilesToCopy.add(listOfFiles[i]); + } } - - to.flush(); - to.close(); - is.close(); + } } - - private void copy(String toFileName) throws IOException,Exception { - docopy("apex_doc_logo.png", toFileName); - docopy("ApexDoc.css", toFileName); - docopy("ApexDoc.js", toFileName); - docopy("CollapsibleList.js", toFileName); - docopy("jquery-latest.js", toFileName); - docopy("toggle_block_btm.gif", toFileName); - docopy("toggle_block_stretch.gif", toFileName); + return listOfFilesToCopy; + } - } - - public ArrayList getFiles(String path){ - File folder = new File(path); - ArrayList listOfFilesToCopy = new ArrayList(); - if(folder != null){ - File[] listOfFiles = folder.listFiles(); - if(listOfFiles != null && listOfFiles.length > 0){ - for(int i = 0; i < listOfFiles.length; i++){ - if (listOfFiles[i].isFile()){ - listOfFilesToCopy.add(listOfFiles[i]); - } - } - } - } - return listOfFilesToCopy; - } - - - - public void createDoc(TreeMap mapClassNameToClassGroup, ArrayList cModels, String projectDetail, String homeContents, String hostedSourceURL, IProgressMonitor monitor){ - makeFile(mapClassNameToClassGroup, cModels, projectDetail, homeContents, hostedSourceURL, monitor); - } - - private String parseFile(String filePath){ - try{ - if(filePath != null && filePath.trim().length() > 0){ - FileInputStream fstream = new FileInputStream(filePath); - // Get the object of DataInputStream - DataInputStream in = new DataInputStream(fstream); - BufferedReader br = new BufferedReader(new InputStreamReader(in)); - String contents = ""; - String strLine; - - while ((strLine = br.readLine()) != null) { - //Print the content on the console - strLine = strLine.trim(); - if(strLine != null && strLine.length() > 0){ - contents += strLine; - } - } - //System.out.println("Contents = " + contents); - br.close(); - return contents; - } - }catch(Exception e){ - e.printStackTrace(); + public void createDoc(TreeMap mapClassNameToClassGroup, ArrayList cModels, + String projectDetail, String homeContents, String hostedSourceURL, IProgressMonitor monitor) { + makeFile(mapClassNameToClassGroup, cModels, projectDetail, homeContents, hostedSourceURL, monitor); + } + + private String parseFile(String filePath) { + try { + if (filePath != null && filePath.trim().length() > 0) { + FileInputStream fstream = new FileInputStream(filePath); + // Get the object of DataInputStream + DataInputStream in = new DataInputStream(fstream); + BufferedReader br = new BufferedReader(new InputStreamReader(in)); + String contents = ""; + String strLine; + + while ((strLine = br.readLine()) != null) { + // Print the content on the console + strLine = strLine.trim(); + if (strLine != null && strLine.length() > 0) { + contents += strLine; + } } - - return ""; + // System.out.println("Contents = " + contents); + br.close(); + return contents; + } + } catch (Exception e) { + e.printStackTrace(); } - - public String parseHTMLFile(String filePath){ - - String contents = (parseFile(filePath)).trim(); - if(contents != null && contents.length() > 0){ - int startIndex = contents.indexOf(""); - int endIndex = contents.indexOf(""); - if(startIndex != -1){ - if(contents.indexOf("") != -1){ - contents = contents.substring(startIndex,endIndex); - return contents; - } - } + + return ""; + } + + public String parseHTMLFile(String filePath) { + + String contents = (parseFile(filePath)).trim(); + if (contents != null && contents.length() > 0) { + int startIndex = contents.indexOf(""); + int endIndex = contents.indexOf(""); + if (startIndex != -1) { + if (contents.indexOf("") != -1) { + contents = contents.substring(startIndex, endIndex); + return contents; } - return ""; + } } - + return ""; + } + } \ No newline at end of file diff --git a/src/org/salesforce/apexdoc/MethodModel.java b/src/org/salesforce/apexdoc/MethodModel.java index caa2a65..0663391 100644 --- a/src/org/salesforce/apexdoc/MethodModel.java +++ b/src/org/salesforce/apexdoc/MethodModel.java @@ -3,46 +3,49 @@ import java.util.ArrayList; public class MethodModel extends ApexModel { - - public MethodModel(){ - params = new ArrayList(); - } - - public void setNameLine(String nameLine, int iLine) { - // remove anything after the parameter list - if (nameLine != null) { - int i = nameLine.lastIndexOf(")"); - if (i >= 0) - nameLine = nameLine.substring(0, i+1); - } - super.setNameLine(nameLine, iLine); - } - - public ArrayList getParams() { - return params; - } - public void setParams(ArrayList params) { - this.params = params; - } - public String getReturnType() { - return returnType; - } - public void setReturnType(String returnType) { - this.returnType = returnType; + + public MethodModel() { + params = new ArrayList(); + } + + public void setNameLine(String nameLine, int iLine) { + // remove anything after the parameter list + if (nameLine != null) { + int i = nameLine.lastIndexOf(")"); + if (i >= 0) + nameLine = nameLine.substring(0, i + 1); } - - public String getMethodName(){ - String nameLine = getNameLine().trim(); - if(nameLine != null && nameLine.length() > 0 ){ - int lastindex = nameLine.indexOf("("); - if (lastindex >= 0) { - String methodName = ApexDoc.strPrevWord(nameLine, lastindex); - return methodName; - } - } - return ""; + super.setNameLine(nameLine, iLine); + } + + public ArrayList getParams() { + return params; + } + + public void setParams(ArrayList params) { + this.params = params; + } + + public String getReturnType() { + return returnType; + } + + public void setReturnType(String returnType) { + this.returnType = returnType; + } + + public String getMethodName() { + String nameLine = getNameLine().trim(); + if (nameLine != null && nameLine.length() > 0) { + int lastindex = nameLine.indexOf("("); + if (lastindex >= 0) { + String methodName = ApexDoc.strPrevWord(nameLine, lastindex); + return methodName; + } } + return ""; + } - private ArrayList params; - private String returnType; + private ArrayList params; + private String returnType; } diff --git a/src/org/salesforce/apexdoc/PropertyModel.java b/src/org/salesforce/apexdoc/PropertyModel.java index b010034..50b7878 100644 --- a/src/org/salesforce/apexdoc/PropertyModel.java +++ b/src/org/salesforce/apexdoc/PropertyModel.java @@ -2,30 +2,33 @@ public class PropertyModel extends ApexModel { - public PropertyModel() { - } + public PropertyModel() { + } - public void setNameLine(String nameLine, int iLine) { - if (nameLine != null) { - // remove any trailing stuff after property name. { = - int i = nameLine.indexOf('{'); - if (i == -1) i = nameLine.indexOf('='); - if (i == -1) i = nameLine.indexOf(';'); - if (i >= 0) nameLine = nameLine.substring(0, i); + public void setNameLine(String nameLine, int iLine) { + if (nameLine != null) { + // remove any trailing stuff after property name. { = + int i = nameLine.indexOf('{'); + if (i == -1) + i = nameLine.indexOf('='); + if (i == -1) + i = nameLine.indexOf(';'); + if (i >= 0) + nameLine = nameLine.substring(0, i); - } - super.setNameLine(nameLine, iLine); } + super.setNameLine(nameLine, iLine); + } - public String getPropertyName(){ - String nameLine = getNameLine().trim(); - if(nameLine != null && nameLine.length() > 0 ){ - int lastindex = nameLine.lastIndexOf(" "); - if (lastindex >= 0) { - String propertyName = nameLine.substring(lastindex + 1); - return propertyName; - } - } - return ""; + public String getPropertyName() { + String nameLine = getNameLine().trim(); + if (nameLine != null && nameLine.length() > 0) { + int lastindex = nameLine.lastIndexOf(" "); + if (lastindex >= 0) { + String propertyName = nameLine.substring(lastindex + 1); + return propertyName; + } } + return ""; + } } \ No newline at end of file
" + "

Home

" + homeContents + "
" + "

Home

" + homeContents + "
"; - - contents += htmlForClassModel(cModel, hostedSourceURL); - - // deal with any nested classes - for (ClassModel cmChild : cModel.getChildClasses()) { - contents += "

"; - contents += htmlForClassModel(cmChild, hostedSourceURL); - } - - }else{ - continue; - } - contents += ""; - - contents = Constants.getHeader(projectDetail) + contents + Constants.FOOTER; - classTreeMap.put(fileName, contents); - if (monitor != null) monitor.worked(1); + + String fileName = ""; + TreeMap classTreeMap = new TreeMap(); + classTreeMap.put("index", homeContents); + + // create our Class Group content files + createClassGroupContent(classTreeMap, links, projectDetail, mapClassNameToClassGroup, cModels, monitor); + + for (ClassModel cModel : cModels) { + String contents = links; + if (cModel.getNameLine() != null && cModel.getNameLine().length() > 0) { + fileName = cModel.getClassName(); + contents += "

"; + + contents += htmlForClassModel(cModel, hostedSourceURL); + + // deal with any nested classes + for (ClassModel cmChild : cModel.getChildClasses()) { + contents += "

"; + contents += htmlForClassModel(cmChild, hostedSourceURL); } - createHTML(classTreeMap, monitor); + + } else { + continue; + } + contents += ""; + + contents = Constants.getHeader(projectDetail) + contents + Constants.FOOTER; + classTreeMap.put(fileName, contents); + if (monitor != null) + monitor.worked(1); } + createHTML(classTreeMap, monitor); + } - /********************************************************************************************* - * @description creates the HTML for the provided class, including its property and methods - * @param cModel - * @param hostedSourceURL - * @return html string - */ - private String htmlForClassModel(ClassModel cModel, String hostedSourceURL) { - String contents = ""; - contents += "

" + - strLinkfromModel(cModel, cModel.getTopmostClassName(), hostedSourceURL) + + /********************************************************************************************* + * @description creates the HTML for the provided class, including its + * property and methods + * @param cModel + * @param hostedSourceURL + * @return html string + */ + private String htmlForClassModel(ClassModel cModel, String hostedSourceURL) { + String contents = ""; + contents += "

" + + strLinkfromModel(cModel, cModel.getTopmostClassName(), hostedSourceURL) + cModel.getClassName() + "" + "

"; - - contents += "
" + + + contents += "
" + strLinkfromModel(cModel, cModel.getTopmostClassName(), hostedSourceURL) + escapeHTML(cModel.getNameLine()) + "
"; - - if (cModel.getDescription() != "") - contents += "
" + escapeHTML(cModel.getDescription()); - if (cModel.getAuthor() != "") - contents += "

" + escapeHTML(cModel.getAuthor()); - if (cModel.getDate() != "") - contents += "
" + escapeHTML(cModel.getDate()); - contents += "

"; - - - if (cModel.getProperties().size() > 0) { - // start Properties - contents += - "

Properties

" + - "
" + - " "; - - for (PropertyModel prop : cModel.getPropertiesSorted()) { - contents += ""; } - - if (cModel.getMethods().size() > 0) { - // start Methods - contents += - "

Methods

" + - "
"; - - // method Table of Contents (TOC) - contents += "
    "; - for (MethodModel method : cModel.getMethodsSorted()) { - contents += "
  • "; - contents += "" + method.getMethodName() + ""; - if (method.getDescription() != "") - contents += "
    " + method.getDescription() + "
    "; - contents += "
  • "; - } - contents += "
"; - - // full method display - for (MethodModel method : cModel.getMethodsSorted()) { - contents += "
"; - contents += "

" + method.getMethodName() + "

" + - ""; - - if (method.getDescription() != "") - contents += "
" + escapeHTML(method.getDescription()) + "
"; - - if (method.getParams().size() > 0) { - contents += "
Parameters
"; - for (String param : method.getParams()) { - param = escapeHTML(param); - if (param != null && param.trim().length() > 0) { - int ich = param.indexOf(" "); - String paramName; - String paramDescription; - if (ich != -1) { - paramName = param.substring(0, ich); - paramDescription = param.substring(ich+1); - } else { - paramName = param; - paramDescription = null; - } - contents += "
" + paramName + "
"; - - if (paramDescription != null) - contents += "
" + paramDescription + "
"; - } + // end Properties + contents += "
" + + + if (cModel.getDescription() != "") + contents += "
" + escapeHTML(cModel.getDescription()); + if (cModel.getAuthor() != "") + contents += "

" + escapeHTML(cModel.getAuthor()); + if (cModel.getDate() != "") + contents += "
" + escapeHTML(cModel.getDate()); + contents += "

"; + + if (cModel.getProperties().size() > 0) { + // start Properties + contents += + "

Properties

" + + "
" + + " "; + + for (PropertyModel prop : cModel.getPropertiesSorted()) { + contents += ""; - contents += ""; - } - // end Properties - contents += "
" + prop.getPropertyName() + "
" + + contents += "
" + strLinkfromModel(prop, cModel.getTopmostClassName(), hostedSourceURL) + escapeHTML(prop.getNameLine()) + "
"; - contents += "
" + escapeHTML(prop.getDescription()) + "

"; + contents += "

" + escapeHTML(prop.getDescription()) + "

"; + } + + if (cModel.getMethods().size() > 0) { + // start Methods + contents += + "

Methods

" + + "
"; + + // method Table of Contents (TOC) + contents += "
    "; + for (MethodModel method : cModel.getMethodsSorted()) { + contents += "
  • "; + contents += "" + + method.getMethodName() + ""; + if (method.getDescription() != "") + contents += "
    " + method.getDescription() + "
    "; + contents += "
  • "; + } + contents += "
"; + + // full method display + for (MethodModel method : cModel.getMethodsSorted()) { + contents += "
"; + contents += "

" + + method.getMethodName() + "

" + + ""; + + if (method.getDescription() != "") + contents += "
" + escapeHTML(method.getDescription()) + "
"; + + if (method.getParams().size() > 0) { + contents += "
Parameters
"; + for (String param : method.getParams()) { + param = escapeHTML(param); + if (param != null && param.trim().length() > 0) { + int ich = param.indexOf(" "); + String paramName; + String paramDescription; + if (ich != -1) { + paramName = param.substring(0, ich); + paramDescription = param.substring(ich + 1); + } else { + paramName = param; + paramDescription = null; + } + contents += "
" + paramName + "
"; + + if (paramDescription != null) + contents += "
" + paramDescription + "
"; } - // end Parameters - } - - if (method.getReturns() != "") { - contents += "
Return Value
"; - contents += "
" + escapeHTML(method.getReturns()) + "
"; - } - - if (method.getAuthor() != "") { - contents += "
Author
"; - contents += "
" + escapeHTML(method.getAuthor()) + "
"; } + // end Parameters + } - if (method.getDate() != "") { - contents += "
Date
"; - contents += "
" + escapeHTML(method.getDate()) + "
"; - } - - // end current method - contents += "
"; + if (method.getReturns() != "") { + contents += "
Return Value
"; + contents += "
" + escapeHTML(method.getReturns()) + "
"; + } + + if (method.getAuthor() != "") { + contents += "
Author
"; + contents += "
" + escapeHTML(method.getAuthor()) + "
"; + } + + if (method.getDate() != "") { + contents += "
Date
"; + contents += "
" + escapeHTML(method.getDate()) + "
"; } - //end all methods + + // end current method contents += "
"; } - - return contents; + // end all methods + contents += "
"; } - - // create our Class Group content files - private void createClassGroupContent(TreeMap classTreeMap, String links, String projectDetail, TreeMap mapClassNameToClassGroup, + + return contents; + } + + // create our Class Group content files + private void createClassGroupContent(TreeMap classTreeMap, String links, String projectDetail, + TreeMap mapClassNameToClassGroup, ArrayList cModels, IProgressMonitor monitor) { - for (String strGroup : mapClassNameToClassGroup.keySet()) { - ClassGroup cg = mapClassNameToClassGroup.get(strGroup); - if (cg.getContentSource() != null) { - String cgContent = parseHTMLFile(cg.getContentSource()); - if (cgContent != "") { - String strHtml = Constants.getHeader(projectDetail) + links + "
" + - "

" + - escapeHTML(cg.getName()) + "

" + cgContent + "
" + + "

" + + escapeHTML(cg.getName()) + "

" + cgContent + "
"; - links += ""; + links += ""; + links += ""; + } + + links += ""; + + links += "