Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/org/salesforce/apexdoc/ApexDoc.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public ApexDoc() {
PrintStream ps = new PrintStream(fos);
System.setOut(ps);
} catch (Exception ex) {
System.out.println("Error: " + ex.getMessage());
}
}

Expand Down Expand Up @@ -80,7 +81,6 @@ public static void RunApexDoc(String[] args, IProgressMonitor monitor) {
System.exit(-1);
}
}

// default scope to global and public if not specified
if (rgstrScope == null || rgstrScope.length == 0) {
rgstrScope = new String[3];
Expand Down Expand Up @@ -529,7 +529,11 @@ private static void fillClassModel(ClassModel cModelParent, ClassModel cModel, S

idxStart = comment.toLowerCase().indexOf("@group-content");
if (idxStart != -1) {
cModel.setClassGroupContent(comment.substring(idxStart + 14).trim());
String path = comment.substring(idxStart + 14).trim();
File f = new File(path);
if (f.exists()) {
cModel.setClassGroupContent(path);
}
inDescription = false;
continue;
}
Expand Down
5 changes: 2 additions & 3 deletions src/org/salesforce/apexdoc/ClassModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,14 @@ public ArrayList<MethodModel> getMethodsSorted() {
@SuppressWarnings("unchecked")
List<MethodModel> sorted = (List<MethodModel>)methods.clone();
Collections.sort(sorted, new Comparator<MethodModel>(){
@Override
public int compare(MethodModel o1, MethodModel o2) {
String methodName1 = o1.getMethodName();
String methodName2 = o2.getMethodName();
String className = getClassName();

if(methodName1.equals(className)){
if(methodName1 != null && methodName1.equals(className)){
return Integer.MIN_VALUE;
} else if(methodName2.equals(className)){
} else if(methodName2 != null && methodName2.equals(className)){
return Integer.MAX_VALUE;
}
return (methodName1.toLowerCase().compareTo(methodName2.toLowerCase()));
Expand Down
50 changes: 29 additions & 21 deletions src/org/salesforce/apexdoc/FileManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ private void createClassGroupContent(TreeMap<String, String> mapFNameToContent,
ClassGroup cg = mapGroupNameToClassGroup.get(strGroup);
if (cg.getContentSource() != null) {
String cgContent = parseHTMLFile(cg.getContentSource());
if (cgContent != "") {
if (!cgContent.equals("")) {
String strHtml = Constants.getHeader(projectDetail) + links + "<td class='contentTD'>" +
"<h2 class='section-title'>" +
escapeHTML(cg.getName()) + "</h2>" + cgContent + "</td>";
Expand Down Expand Up @@ -337,9 +337,10 @@ private String getPageLinks(TreeMap<String, ClassGroup> mapGroupNameToClassGroup
}
cModels = new ArrayList<ClassModel>(tm.values());

String links = "<td width='20%' vertical-align='top' >";
links += "<div class='sidebar'><div class='navbar'><nav role='navigation'><ul id='mynavbar'>";
links += "<li id='idMenuindex'><a href='.' onclick=\"gotomenu('index.html', event);return false;\" class='nav-item'>Home</a></li>";
StringBuilder links = new StringBuilder();
links.append("<td width='20%' vertical-align='top' >");
links.append("<div class='sidebar'><div class='navbar'><nav role='navigation'><ul id='mynavbar'>");
links.append("<li id='idMenuindex'><a href='.' onclick=\"gotomenu('index.html', event);return false;\" class='nav-item'>Home</a></li>");

// add a bucket ClassGroup for all Classes without a ClassGroup specified
if (createMiscellaneousGroup)
Expand All @@ -350,12 +351,17 @@ private String getPageLinks(TreeMap<String, ClassGroup> mapGroupNameToClassGroup
for (String strGroup : mapGroupNameToClassGroup.keySet()) {
ClassGroup cg = mapGroupNameToClassGroup.get(strGroup);
String strGoTo = "onclick=\"gotomenu(document.location.href, event);return false;\"";
if (cg.getContentFilename() != null)
if (cg.getContentFilename() != null) {
strGoTo = "onclick=\"gotomenu('" + cg.getContentFilename() + ".html" + "', event);return false;\"";
links += "<li class='header' id='idMenu" + cg.getContentFilename() +
"'><a class='nav-item nav-section-title' href='.' " +
strGoTo + " class='nav-item'>" + strGroup + "<span class='caret'></span></a></li>";
links += "<ul>";
}
links.append("<li class='header' id='idMenu");
links.append(cg.getContentFilename());
links.append("'><a class='nav-item nav-section-title' href='.' ");
links.append(strGoTo);
links.append(" class='nav-item'>");
links.append(strGroup);
links.append("<span class='caret'></span></a></li>");
links.append("<ul>");

// even though this algorithm is O(n^2), it was timed at just 12
// milliseconds, so not an issue!
Expand All @@ -364,21 +370,21 @@ private String getPageLinks(TreeMap<String, ClassGroup> mapGroupNameToClassGroup
|| (cModel.getClassGroup() == null && strGroup == "Miscellaneous")) {
if (cModel.getNameLine() != null && cModel.getNameLine().trim().length() > 0) {
String fileName = cModel.getClassName();
links += "<li class='subitem classscope" + cModel.getScope() + "' id='idMenu" + fileName +
links.append("<li class='subitem classscope" + cModel.getScope() + "' id='idMenu" + fileName +
"'><a href='.' onclick=\"gotomenu('" + fileName + ".html', event);return false;\" class='nav-item sub-nav-item scope" +
cModel.getScope() + "'>" +
fileName + "</a></li>";
fileName + "</a></li>");
}
}
}

links += "</ul>";
links.append("</ul>");
}

links += "</ul></nav></div></div></div>";
links.append("</ul></nav></div></div></div>");

links += "</td>";
return links;
links.append("</td>");
return links.toString();
}

private void docopy(String source, String target) throws Exception {
Expand Down Expand Up @@ -414,17 +420,20 @@ private void copy(String toFileName) throws IOException, Exception {
public ArrayList<File> getFiles(String path) {
File folder = new File(path);
ArrayList<File> listOfFilesToCopy = new ArrayList<File>();
if (folder != null) {
try {
File[] listOfFiles = folder.listFiles();
if (listOfFiles != null && listOfFiles.length > 0) {
for (int i = 0; i < listOfFiles.length; i++) {
System.out.print(listOfFiles[i].getName() + ", ");
if (listOfFiles[i].isFile()) {
listOfFilesToCopy.add(listOfFiles[i]);
}
}
} else {
System.out.println("WARNING: No files found in directory: " + path);
}
} catch (SecurityException e) {
e.printStackTrace();
}
return listOfFilesToCopy;
}
Expand All @@ -441,22 +450,21 @@ private String parseFile(String filePath) {
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String contents = "";
StringBuilder contents = new StringBuilder();
String strLine;

while ((strLine = br.readLine()) != null) {
// Print the content on the console
strLine = strLine.trim();
if (strLine != null && strLine.length() > 0) {
contents += strLine;
contents.append(strLine);
}
}
// System.out.println("Contents = " + contents);
br.close();
return contents;
return contents.toString();
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Skipped " + filePath + ", doesn't exist.");
}

return "";
Expand Down
7 changes: 4 additions & 3 deletions src/org/salesforce/apexdoc/MethodModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ public void setReturnType(String returnType) {
}

public String getMethodName() {
String nameLine = getNameLine().trim();
if (nameLine != null && nameLine.length() > 0) {
String nameLine = getNameLine();
if (nameLine != null && nameLine.trim().length() > 0) {
nameLine = nameLine.trim();
int lastindex = nameLine.indexOf("(");
if (lastindex >= 0) {
String methodName = ApexDoc.strPrevWord(nameLine, lastindex);
return methodName;
return methodName == null ? "" : methodName;
}
}
return "";
Expand Down