Adding option for class and method declaration code listings (default is 'none')
This commit is contained in:
@@ -13,7 +13,9 @@ javadoc -docletpath ../../target/TeXDoclet.jar \
|
|||||||
-author "Greg Wonderly \and S{\"o}ren Caspersen \and Stefan Marx" \
|
-author "Greg Wonderly \and S{\"o}ren Caspersen \and Stefan Marx" \
|
||||||
-sourcepath ../../src/main/java:../../src/test/java \
|
-sourcepath ../../src/main/java:../../src/test/java \
|
||||||
-subpackages org \
|
-subpackages org \
|
||||||
-shortinherited
|
-shortinherited \
|
||||||
|
-classdeclrframe trBL \
|
||||||
|
-methoddeclrframe single
|
||||||
|
|
||||||
cd texdoclet_output
|
cd texdoclet_output
|
||||||
pdflatex TeXDoclet.tex
|
pdflatex TeXDoclet.tex
|
||||||
|
|||||||
@@ -73,10 +73,13 @@ public class HelpOutput {
|
|||||||
.println("-tablescale <factor> Scale factor to specify width of tables. Default value is 0.9.");
|
.println("-tablescale <factor> Scale factor to specify width of tables. Default value is 0.9.");
|
||||||
System.err
|
System.err
|
||||||
.println("-createpdf Creates .pdf file from the .tex output file by using pdflatex tool.");
|
.println("-createpdf Creates .pdf file from the .tex output file by using pdflatex tool.");
|
||||||
System.err
|
System.err.println("-packageorder <pkg1>,<pkg2>,...");
|
||||||
.println("-packageorder <pkg1>,<pkg2>,...");
|
|
||||||
System.err
|
System.err
|
||||||
.println(" Use a specific package order.");
|
.println(" Use a specific package order.");
|
||||||
|
System.err
|
||||||
|
.println("-classdeclrframe Frame type parameter for class declaration code listing. Default is 'none'. See Latex Listings package documentation (lstlisting).");
|
||||||
|
System.err
|
||||||
|
.println("-methoddeclrframe Frame type parameter for class declaration code listing. Default is 'none'. See Latex Listings package documentation (lstlisting).");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,6 +193,9 @@ public class TeXDoclet extends Doclet {
|
|||||||
public static final String CHAPTER_LEVEL = "chapter";
|
public static final String CHAPTER_LEVEL = "chapter";
|
||||||
public static final String SUBSECTION_LEVEL = "subsection";
|
public static final String SUBSECTION_LEVEL = "subsection";
|
||||||
|
|
||||||
|
public static final String DEFAULT_CLASS_FRAME = "none";
|
||||||
|
public static final String DEFAULT_METHOD_FRAME = "none";
|
||||||
|
|
||||||
public static final String BOLD = "{\\bf ";
|
public static final String BOLD = "{\\bf ";
|
||||||
// no bold AND truetype support if using textbf !
|
// no bold AND truetype support if using textbf !
|
||||||
// public static final String BOLD = "\\textbf{";
|
// public static final String BOLD = "\\textbf{";
|
||||||
@@ -252,6 +255,8 @@ public class TeXDoclet extends Doclet {
|
|||||||
static double tableWidthScale = 0.9;
|
static double tableWidthScale = 0.9;
|
||||||
static boolean createPdf = false;
|
static boolean createPdf = false;
|
||||||
static String package_order = null;
|
static String package_order = null;
|
||||||
|
static String classDeclarationFrame = DEFAULT_CLASS_FRAME;
|
||||||
|
static String methodDeclarationFrame = DEFAULT_CLASS_FRAME;
|
||||||
static final String REPLACE_OUT = "_replace_data_";
|
static final String REPLACE_OUT = "_replace_data_";
|
||||||
static final String REPLACE_TITLE = "_replace_title_";
|
static final String REPLACE_TITLE = "_replace_title_";
|
||||||
static final String HTML_PDF_WRAPPER = "<!DOCTYPE html><html lang=\"en\" xml:lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\"><head>"
|
static final String HTML_PDF_WRAPPER = "<!DOCTYPE html><html lang=\"en\" xml:lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\"><head>"
|
||||||
@@ -389,6 +394,10 @@ public class TeXDoclet extends Doclet {
|
|||||||
return 1;
|
return 1;
|
||||||
} else if (option.equals("-packageorder")) {
|
} else if (option.equals("-packageorder")) {
|
||||||
return 2;
|
return 2;
|
||||||
|
} else if (option.equals("-classdeclrframe")) {
|
||||||
|
return 2;
|
||||||
|
} else if (option.equals("-methoddeclrframe")) {
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
System.out.println("unknown TeXDoclet option " + option);
|
System.out.println("unknown TeXDoclet option " + option);
|
||||||
|
|
||||||
@@ -497,6 +506,10 @@ public class TeXDoclet extends Doclet {
|
|||||||
createPdf = true;
|
createPdf = true;
|
||||||
} else if (args[i][0].equals("-packageorder")) {
|
} else if (args[i][0].equals("-packageorder")) {
|
||||||
package_order = args[i][1];
|
package_order = args[i][1];
|
||||||
|
} else if (args[i][0].equals("-classdeclrframe")) {
|
||||||
|
classDeclarationFrame = args[i][1];
|
||||||
|
} else if (args[i][0].equals("-methoddeclrframe")) {
|
||||||
|
methodDeclarationFrame = args[i][1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sectionLevelMax != null
|
if (sectionLevelMax != null
|
||||||
@@ -579,7 +592,8 @@ public class TeXDoclet extends Doclet {
|
|||||||
String[] pkg = package_order.split(",");
|
String[] pkg = package_order.split(",");
|
||||||
for (int i = 0; i < pkg.length; i++) {
|
for (int i = 0; i < pkg.length; i++) {
|
||||||
// Search for pkg[i] in the specifiedPackages
|
// Search for pkg[i] in the specifiedPackages
|
||||||
int j; boolean found = false;
|
int j;
|
||||||
|
boolean found = false;
|
||||||
for (j = i; j < specifiedPackages.length; j++) {
|
for (j = i; j < specifiedPackages.length; j++) {
|
||||||
if (specifiedPackages[j].name().equals(pkg[i])) {
|
if (specifiedPackages[j].name().equals(pkg[i])) {
|
||||||
found = true;
|
found = true;
|
||||||
@@ -587,7 +601,8 @@ public class TeXDoclet extends Doclet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
System.err.println("Package " + pkg + " not found, aborting.");
|
System.err.println("Package " + pkg
|
||||||
|
+ " not found, aborting.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (i != j) {
|
if (i != j) {
|
||||||
@@ -1160,7 +1175,8 @@ public class TeXDoclet extends Doclet {
|
|||||||
|
|
||||||
os.println("\\" + sectionLevels[2] + "{Declaration}{");
|
os.println("\\" + sectionLevels[2] + "{Declaration}{");
|
||||||
|
|
||||||
os.println("\\begin{lstlisting}[frame=trBL]");
|
os.println("\\begin{lstlisting}[frame=" + classDeclarationFrame
|
||||||
|
+ "]");
|
||||||
os.print(cd.modifiers() + " ");
|
os.print(cd.modifiers() + " ");
|
||||||
if (cd.isInterface() == false) {
|
if (cd.isInterface() == false) {
|
||||||
os.print("class ");
|
os.print("class ");
|
||||||
@@ -1168,8 +1184,7 @@ public class TeXDoclet extends Doclet {
|
|||||||
os.println(cd.name());
|
os.println(cd.name());
|
||||||
ClassDoc sc = cd.superclass();
|
ClassDoc sc = cd.superclass();
|
||||||
if (sc != null) {
|
if (sc != null) {
|
||||||
os.print(" extends "
|
os.print(" extends " + sc.qualifiedName());
|
||||||
+ sc.qualifiedName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassDoc intf[] = cd.interfaces();
|
ClassDoc intf[] = cd.interfaces();
|
||||||
@@ -1439,7 +1454,7 @@ public class TeXDoclet extends Doclet {
|
|||||||
}
|
}
|
||||||
// TRUETYPE ends
|
// TRUETYPE ends
|
||||||
os.println("}");
|
os.println("}");
|
||||||
|
|
||||||
if (f.inlineTags().length > 0 || f.seeTags().length > 0) {
|
if (f.inlineTags().length > 0 || f.seeTags().length > 0) {
|
||||||
os.println("\\begin{itemize}");
|
os.println("\\begin{itemize}");
|
||||||
if (f.inlineTags().length > 0) {
|
if (f.inlineTags().length > 0) {
|
||||||
@@ -1665,13 +1680,14 @@ public class TeXDoclet extends Doclet {
|
|||||||
os.println();
|
os.println();
|
||||||
|
|
||||||
// Print signature
|
// Print signature
|
||||||
os.println("\\begin{lstlisting}[frame=single]");
|
os.println("\\begin{lstlisting}[frame=" + methodDeclarationFrame + "]");
|
||||||
if (!mem.containingClass().isInterface()) {
|
if (!mem.containingClass().isInterface()) {
|
||||||
os.print(mem.modifiers() + " ");
|
os.print(mem.modifiers() + " ");
|
||||||
}
|
}
|
||||||
if (mem instanceof MethodDoc) {
|
if (mem instanceof MethodDoc) {
|
||||||
os.print(packageRelativIdentifier(pac, ((MethodDoc) mem)
|
os.print(packageRelativIdentifier(pac, ((MethodDoc) mem)
|
||||||
.returnType().toString()) + " ");
|
.returnType().toString())
|
||||||
|
+ " ");
|
||||||
}
|
}
|
||||||
os.print(mem.name() + "(");
|
os.print(mem.name() + "(");
|
||||||
Parameter[] parms = mem.parameters();
|
Parameter[] parms = mem.parameters();
|
||||||
@@ -2016,18 +2032,21 @@ public class TeXDoclet extends Doclet {
|
|||||||
String linkstr = "";
|
String linkstr = "";
|
||||||
String label;
|
String label;
|
||||||
if (link.referencedMember() != null) {
|
if (link.referencedMember() != null) {
|
||||||
MemberDoc member = link.referencedMember();
|
MemberDoc member = link.referencedMember();
|
||||||
linkstr = member.qualifiedName();
|
linkstr = member.qualifiedName();
|
||||||
label = classRelativeIdentifier(member.containingClass(), member.name());
|
label = classRelativeIdentifier(member.containingClass(),
|
||||||
|
member.name());
|
||||||
if (link.referencedMember() instanceof ExecutableMemberDoc) {
|
if (link.referencedMember() instanceof ExecutableMemberDoc) {
|
||||||
// If the member is a method, append the method signature
|
// If the member is a method, append the method
|
||||||
|
// signature
|
||||||
ExecutableMemberDoc m = (ExecutableMemberDoc) member;
|
ExecutableMemberDoc m = (ExecutableMemberDoc) member;
|
||||||
linkstr += m.signature();
|
linkstr += m.signature();
|
||||||
label += m.flatSignature();
|
label += m.flatSignature();
|
||||||
}
|
}
|
||||||
} else if (link.referencedClass() != null) {
|
} else if (link.referencedClass() != null) {
|
||||||
linkstr = link.referencedClass().qualifiedName();
|
linkstr = link.referencedClass().qualifiedName();
|
||||||
label = packageRelativIdentifier(this_package, link.referencedClass().name());
|
label = packageRelativIdentifier(this_package, link
|
||||||
|
.referencedClass().name());
|
||||||
} else if (link.referencedPackage() != null) {
|
} else if (link.referencedPackage() != null) {
|
||||||
linkstr = link.referencedPackage().name();
|
linkstr = link.referencedPackage().name();
|
||||||
label = linkstr;
|
label = linkstr;
|
||||||
@@ -2120,10 +2139,12 @@ public class TeXDoclet extends Doclet {
|
|||||||
// This is a member or a method of the same class
|
// This is a member or a method of the same class
|
||||||
return str.substring(doc.name().length() + 1);
|
return str.substring(doc.name().length() + 1);
|
||||||
} else if (str.startsWith(doc.containingPackage().name())) {
|
} else if (str.startsWith(doc.containingPackage().name())) {
|
||||||
// This is a member or a method of a different class but from the same package
|
// This is a member or a method of a different class but from the
|
||||||
|
// same package
|
||||||
return str.substring(doc.name().length() + 1);
|
return str.substring(doc.name().length() + 1);
|
||||||
} else {
|
} else {
|
||||||
// This is a member or a method from a different package, cannot be simplified
|
// This is a member or a method from a different package, cannot be
|
||||||
|
// simplified
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user