Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes #5

Merged
merged 6 commits into from
Jan 3, 2024
Merged
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
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
docletVersion=0.3.0
schemaVersion=0.3.0
docletVersion=0.4.0
schemaVersion=0.4.0
docletTitle=XmlDoclet
docletName=xmldoclet
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,14 @@ public void processTree(DocTree tree) {
break;
case PARAM:
case RETURN:
case DEPRECATED:
// Handled in enclosing class
break;
case DEPRECATED:
DeprecatedTree depTree = (DeprecatedTree) tree;
startElement(depTree.getTagName());
html(depTree.getBody());
endElement(depTree.getTagName());
break;
case CODE:
case LITERAL:
LiteralTree ltree = (LiteralTree) tree;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,16 @@ public void scan() {
builder = new XmlBuilder(this);
startDocument();
for (Element element : elements) {
xmlscan(element);
if (element.getKind() == ElementKind.CLASS) {
TypeElement xelem = (TypeElement) element;
if (xelem.getNestingKind() == NestingKind.TOP_LEVEL) {
// Don't output nested, inner classes at the top level. They'll automatically
// be output in the surrounding class
xmlscan(element);
}
} else {
xmlscan(element);
}
}
endDocument();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public void scan(DocTree tree) {
for (TypeMirror ttype : element.getThrownTypes()) {
Element telem = ((DeclaredType) ttype).asElement();
// N.B. I'd like to use the fully qualified name here (it's what toString() returns),
// but I can't work out how to get the fully qualified name from the ThrowsTree
// but I can't work out how to get the fully qualified name from the ThrowsTree.
// Note that we try to be careful in the matching code below.
thrownTypes.put(telem.getSimpleName().toString(), (DeclaredType) ttype);
}

Expand Down Expand Up @@ -79,7 +80,17 @@ public void scan(DocTree tree) {

if (block.getKind() == DocTree.Kind.THROWS) {
String name = ((ThrowsTree) block).getExceptionName().getSignature();
thrownTypes.remove(name);
// The name could be either com.example.Exception or just Exception.
// If either of those occurs in thrownTypes, we want to remove it.
String removeKey = null;
for (String key : thrownTypes.keySet()) {
if (name.equals(key) || name.equals(thrownTypes.get(key).toString())) {
removeKey = key;
}
}
if (removeKey != null) {
thrownTypes.remove(removeKey);
}
}
break;
}
Expand All @@ -89,7 +100,7 @@ public void scan(DocTree tree) {
if (!thrownTypes.isEmpty()) {
for (String name : thrownTypes.keySet()) {
Map<String,String> tattr = new HashMap<>();
tattr.put("exception", name);
tattr.put("exception", thrownTypes.get(name).toString());
builder.startElement("throws", tattr);
builder.endElement("throws");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public void scan(DocTree tree) {
attr.clear();
attr.put("name", tp.toString());
builder.startElement("typeparam", attr);
for (TypeMirror bound : tp.getBounds()) {
TypeUtils.xmlType(builder, "type", bound);
}
builder.endElement("typeparam");
}
builder.endElement("typeparams");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ public void sample() {
public void saxonSample() {
String[] docletArgs = new String[]{
"-doclet", XmlDoclet.class.getName(),
"-private",
"-docletpath", "build/classes/",
"-classpath", "/Users/ndw/.m2/repository/jline/jline/2.14.6/jline-2.14.6.jar:/Volumes/Saxonica/src/saxonica/saxondev/build/releases/eej/lib/xmlresolver-5.2.2.jar",
"-sourcepath", "../../saxondev/src/main/java",
"net.sf.saxon.serialize", "net.sf.saxon.event"
"net.sf.saxon.trans"
};

DocumentationTool docTool = ToolProvider.getSystemDocumentationTool();
Expand Down