use of org.gradle.build.docs.dsl.docbook.model.BlockDoc in project gradle by gradle.
the class BlocksRenderer method renderDetailsTo.
public void renderDetailsTo(ClassDoc classDoc, Element parent) {
if (hasBlocks(classDoc)) {
Document document = parent.getOwnerDocument();
Element detailsSection = document.createElement("section");
parent.appendChild(detailsSection);
Element title = document.createElement("title");
detailsSection.appendChild(title);
title.appendChild(document.createTextNode("Script block details"));
for (BlockDoc blockDoc : classDoc.getClassBlocks()) {
blockDetailRenderer.renderTo(blockDoc, detailsSection);
}
for (ClassExtensionDoc extensionDoc : classDoc.getClassExtensions()) {
for (BlockDoc blockDoc : extensionDoc.getExtensionBlocks()) {
blockDetailRenderer.renderTo(blockDoc, detailsSection);
}
}
}
}
use of org.gradle.build.docs.dsl.docbook.model.BlockDoc in project gradle by gradle.
the class ClassDocMethodsBuilder method build.
/**
* Builds the methods and script blocks of the given class. Assumes properties have already been built.
*/
public void build(ClassDoc classDoc) {
Set<String> signatures = new HashSet<String>();
for (Element tr : children(classDoc.getMethodsTable(), "tr")) {
List<Element> cells = children(tr, "td");
if (cells.size() != 1) {
throw new RuntimeException(String.format("Expected 1 cell in <tr>, found: %s", tr));
}
String methodName = cells.get(0).getTextContent().trim();
Collection<MethodMetaData> methods = classDoc.getClassMetaData().findDeclaredMethods(methodName);
if (methods.isEmpty()) {
throw new RuntimeException(String.format("No metadata for method '%s.%s()'. Available methods: %s", classDoc.getName(), methodName, classDoc.getClassMetaData().getDeclaredMethodNames()));
}
for (MethodMetaData method : methods) {
DocComment docComment = javadocConverter.parse(method, listener);
MethodDoc methodDoc = new MethodDoc(method, docComment.getDocbook());
if (methodDoc.getDescription() == null) {
throw new RuntimeException(String.format("Docbook content for '%s %s' does not contain a description paragraph.", classDoc.getName(), method.getSignature()));
}
PropertyDoc property = classDoc.findProperty(methodName);
boolean multiValued = false;
if (property != null && method.getParameters().size() == 1 && method.getParameters().get(0).getType().getSignature().equals(Closure.class.getName())) {
TypeMetaData type = property.getMetaData().getType();
if (type.getName().equals("java.util.List") || type.getName().equals("java.util.Collection") || type.getName().equals("java.util.Set") || type.getName().equals("java.util.Iterable")) {
type = type.getTypeArgs().get(0);
multiValued = true;
}
classDoc.addClassBlock(new BlockDoc(methodDoc, property, type, multiValued));
} else {
classDoc.addClassMethod(methodDoc);
signatures.add(method.getOverrideSignature());
}
}
}
for (ClassDoc supertype : classDoc.getSuperTypes()) {
for (MethodDoc method : supertype.getClassMethods()) {
if (signatures.add(method.getMetaData().getOverrideSignature())) {
classDoc.addClassMethod(method);
}
}
}
}
use of org.gradle.build.docs.dsl.docbook.model.BlockDoc in project gradle by gradle.
the class BlockTableRenderer method renderTo.
public void renderTo(Iterable<BlockDoc> blocks, Element parent) {
Document document = parent.getOwnerDocument();
// <thead>
// <tr>
// <td>Block</td>
// <td>Description</td>
// </tr>
// </thead>
Element thead = document.createElement("thead");
parent.appendChild(thead);
Element tr = document.createElement("tr");
thead.appendChild(tr);
Element td = document.createElement("td");
tr.appendChild(td);
td.appendChild(document.createTextNode("Block"));
td = document.createElement("td");
tr.appendChild(td);
td.appendChild(document.createTextNode("Description"));
for (BlockDoc blockDoc : blocks) {
// <tr>
// <td><link linkend="$id"><literal>$name</literal></link</td>
// <td>$description</td>
// </tr>
tr = document.createElement("tr");
parent.appendChild(tr);
td = document.createElement("td");
tr.appendChild(td);
Element link = document.createElement("link");
td.appendChild(link);
link.setAttribute("linkend", blockDoc.getId());
Element literal = document.createElement("literal");
link.appendChild(literal);
literal.appendChild(document.createTextNode(blockDoc.getName()));
td = document.createElement("td");
tr.appendChild(td);
if (blockDoc.isDeprecated()) {
Element caution = document.createElement("caution");
td.appendChild(caution);
caution.appendChild(document.createTextNode("Deprecated"));
}
if (blockDoc.isIncubating()) {
Element caution = document.createElement("caution");
td.appendChild(caution);
caution.appendChild(document.createTextNode("Incubating"));
}
td.appendChild(document.importNode(blockDoc.getDescription(), true));
}
}
use of org.gradle.build.docs.dsl.docbook.model.BlockDoc in project gradle by gradle.
the class BlocksRenderer method renderSummaryTo.
public void renderSummaryTo(ClassDoc classDoc, Element parent) {
Document document = parent.getOwnerDocument();
Element summarySection = document.createElement("section");
parent.appendChild(summarySection);
Element title = document.createElement("title");
summarySection.appendChild(title);
title.appendChild(document.createTextNode("Script blocks"));
Collection<BlockDoc> classBlocks = classDoc.getClassBlocks();
if (!classBlocks.isEmpty()) {
Element table = document.createElement("table");
summarySection.appendChild(table);
title = document.createElement("title");
table.appendChild(title);
title.appendChild(document.createTextNode("Script blocks - " + classDoc.getSimpleName()));
blockTableRenderer.renderTo(classBlocks, table);
}
for (ClassExtensionDoc extensionDoc : classDoc.getClassExtensions()) {
extensionBlocksSummaryRenderer.renderTo(extensionDoc, summarySection);
}
if (!hasBlocks(classDoc)) {
Element para = document.createElement("para");
summarySection.appendChild(para);
para.appendChild(document.createTextNode("No script blocks"));
}
}
Aggregations