Log4j Docgen AsciiDoctor extension
While the descriptor generator converts Javadoc to AsciiDoc, it cannot resolve links.
That is, it cannot blindly replace a {@link example.MyAppender foo}
Javadoc snippet with a xref:MyAppender.adoc[foo]
AsciiDoc snippet instead.
This is because, the mapping of types to AsciiDoc files are not available to the descriptor generator, but the documentation generator.
That is, the descriptor generator doesn’t know if the type will be mapped to <className>.adoc
or <artifactId>/<className>.adoc
.
As a matter of fact, it should not need to know this either: descriptors capture immutable metadata, whereas documentation file structure can always change.
To work around this, we convert {@link example.MyAppender foo}
to apiref:example.MyAppender[foo]
and provide an apiref
inline AsciiDoc macro to resolve these while generating the documentation.
DocgenExtension
AsciiDoctor extension provides the apiref
inline macro which can be configured using the below shared AsciiDoctor document attributes:
log4j-docgen-descriptor-dot-files-included
-
Indicates if dot files (i.e.,
.
-prefix file names) will be accepted in [log4j-docgen-asciidoctor-extension-attribute-descriptor-path-matcher]. This attribute defaults tofalse
.
log4j-docgen-descriptor-path-matcher
-
The path pattern (e.g.,
glob:*/.xml
) to locate files produced by the descriptor generator. This attribute is required. log4j-docgen-type-filter-exclude-pattern
-
The regular expression to match against the types loaded from descriptors and determine if a type will be excluded to generate links. This argument defaults to not exclude anything.
log4j-docgen-type-filter-include-pattern
-
The regular expression to match against the types loaded from descriptors and determine if a type will be included to generate links. This argument defaults to
.*
, that is, all loaded types will be used to generate links. log4j-docgen-package-name-stripped
-
Indicates if the package name will be stripped for unknown types. That is, if
true
,apiref:some.unknown.Class[]
will be converted to<code>Class</code>
;<code>some.unknown.Class</code>
, otherwise. Note that this only applies to types where the label is not provided. This flag is disabled by default.
log4j-docgen-type-target-template
-
The FreeMarker template to produce the link target for individual types documented, for instance:
#${sourcedType.groupId?replace('.', '-')}_${sourcedType.artifactId?replace('.', '-')}_${sourcedType.type.className?replace('.', '-')
This attribute is required.