in log4j-docgen-asciidoctor-extension/src/main/java/org/apache/logging/log4j/docgen/asciidoctor/ApirefMacro.java [77:100]
private PhraseNode createPhraseNode(
final StructuralNode parent, final String target, final Map<String, Object> attributes) {
final int methodSplitterIndex = target.indexOf('#');
final boolean methodProvided = methodSplitterIndex > 0;
final String className = methodProvided ? target.substring(0, methodSplitterIndex) : target;
@Nullable final String label = (String) attributes.get("label");
// If this is a type we expect to find in an AsciiDoc file produced by `DocumentationGenerator`
@Nullable final ArtifactSourcedType sourcedType = lookup.get(className);
if (sourcedType != null) {
Map<String, Object> nodeOptions = new HashMap<>();
nodeOptions.put("type", ":xref");
nodeOptions.put("target", createTypeTemplateTargetPath(sourcedType));
final String effectiveLabel = label != null ? label : className.substring(className.lastIndexOf('.') + 1);
return createPhraseNode(parent, "anchor", effectiveLabel, attributes, nodeOptions);
}
// Otherwise we don't know the link
if (label != null) {
return createPhraseNode(parent, "quoted", "<em>" + label + "</em>", attributes);
}
final String effectiveLabel = packageNameStripped ? target.replaceFirst("^([a-z][a-z0-9_]*\\.)*", "") : target;
return createPhraseNode(parent, "quoted", "<code>" + effectiveLabel + "</code>", attributes);
}