-
Notifications
You must be signed in to change notification settings - Fork 18
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
Adds log4j-docgen
module
#88
Conversation
log4j-docgen/src/main/java/org/apache/logging/log4j/docgen/internal/DefaultSchemaGenerator.java
Show resolved
Hide resolved
@ppkarwasz, I find it very difficult to understand what this PR does exactly and, maybe more importantly, what it is supposed to deliver. Could you provide some review kit, please? In particular, questions I have:
I guess, since you are deep in the problem, these might sound obvious to you. But I can assure you that the rest of us have no clue. |
This commit contains a set of AsciiDoc documents to evaluate the requirements for our documentation reference.
We disable Spotbugs on generated code and retrieve `XmlSchema.xsd`.
5945f32
to
f671c03
Compare
@vy, Here are some suggestions on how to review this PR. How to review this PRThis PR contains multiple contents that might require review:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some minor comments, but the overall looks good to me. Great job! 💯
Sanity check
To check if I get the wiring right, I share my notes below.
- A to-be-implemented
PluginScanner
generatesplugins.xml
(similar to the one intest/resources/META-INF/log4j/plugins.xml
) fromlog4j-core.jar
,log4j-layout-template-json.jar
, etc. - Modello, provided with
src/main/mdo/plugins.xml
, generates DTOs and an XML reader/writer. - We use Modello-generated DTOs and the XML reader to read
plugins.xml
. - Using DTOs populated from the XML, we manually generate XSD ourselves.
Correct?
plugins.xml
file name confusion
There are so many plugins.xml
and it requires quite some stretch to wrap my mind around them. I would appreciate it if we can use more self-explanatory file names:
src/main/mdo/plugins.xml
⇒src/main/mdo/plugins-model.xml
src/test/resources/META-INF/log4j/plugins.xml
⇒sample-plugins.xml
src/test/resources/xsd/log4j.xsd
⇒sample-plugins.xsd
src/main/resources/.../configuration.xml
⇒src/.../supplement-plugins.xml
src/site
src/site
is hand-crafted as a showcase, right?
XML group
s
I think the problem you're describing is as follows:
<complexType name="org.apache.logging.log4j.core.config.LoggerConfig">
<sequence>
<group ref="log4j:org.apache.logging.log4j.core.config.AppenderRef.group" minOccurs="0" maxOccurs="unbounded"/>
<group ref="log4j:org.apache.logging.log4j.core.Filter.group" minOccurs="0"/>
</sequence>
<attribute name="name" type="string"/>
</complexType>
Naively thinking, wouldn't omitting the sequence
work? That is,
<complexType name="org.apache.logging.log4j.core.config.LoggerConfig">
<group ref="log4j:org.apache.logging.log4j.core.config.AppenderRef.group" minOccurs="0" maxOccurs="unbounded"/>
<group ref="log4j:org.apache.logging.log4j.core.Filter.group" minOccurs="0"/>
<attribute name="name" type="string"/>
</complexType>
<field> | ||
<name>attributes</name> | ||
<required>true</required> | ||
<association> | ||
<type>PluginAttribute</type> | ||
<multiplicity>*</multiplicity> | ||
</association> | ||
<description>List of **all** the configuration attributes supported</description> | ||
</field> | ||
<field> | ||
<name>elements</name> | ||
<required>true</required> | ||
<association> | ||
<type>PluginElement</type> | ||
<multiplicity>*</multiplicity> | ||
</association> | ||
<description>List of **all** possible nested components.</description> | ||
</field> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Attribute-vs-element distinction feels to me an implementation detail. That is, from the pov of the user, they are all configuration properties of the plugin. As a matter of fact, JSON-, YAML-, and .properties
-formatted configurations cannot even accommodate the attribute concept, for them, every property is an element. Do we really need two different types, i.e., attribute & element? Can't we use a single property/attribute/element/etc. to refer the both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point,
From a JSON and YAML perspective the distinction is not as evident ("elements" are properties with an object value), but I would keep the distinction for the user: "attributes" are injected by name, whereas "elements" are injected by type. Knowing that simplifies configuration considerably.
I will look at this again to see if I can simplify things.
log4j-docgen/src/main/java/org/apache/logging/log4j/docgen/internal/DefaultSchemaGenerator.java
Outdated
Show resolved
Hide resolved
log4j-docgen/src/main/java/org/apache/logging/log4j/docgen/internal/DefaultSchemaGenerator.java
Outdated
Show resolved
Hide resolved
log4j-docgen/src/main/java/org/apache/logging/log4j/docgen/internal/DefaultSchemaGenerator.java
Outdated
Show resolved
Hide resolved
log4j-docgen/src/main/java/org/apache/logging/log4j/docgen/internal/DefaultSchemaGenerator.java
Outdated
Show resolved
Hide resolved
log4j-docgen/src/main/java/org/apache/logging/log4j/docgen/internal/DefaultSchemaGenerator.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Volkan Yazıcı <[email protected]>
Co-authored-by: Volkan Yazıcı <[email protected]>
Co-authored-by: Volkan Yazıcı <[email protected]>
Hi @vy,
Exactly
I corrected it, thanks.
Yes, I will use it later to test the generation of AsciiDoc. The idea is to know the rough structure of the documentation, so that we know what elements we need. In the showcase documentation attributes and elements are in separate sections for example, so I would like to distinguish the two types.
Unfortunately the XMLSchema XSD does not allow that. I think we'll need to decide whether writing elements in an arbitrary order is important to users. We can assume for now it isn't and improve the schema later. |
I am closing this, since the documentation generator needs some refactoring to account for the generation of human documentation. This will be resubmitted in three more digestible parts:
|
Adds a
log4j-docgen
module whose purpose is to automatically generate the documentation of Log4j components based on annotations in the source code and Javadoc comments.This initial version:
/META-INF/log4j/plugins.xml
plugin descriptor, which is similar in nature to Maven's/META-INF/maven/plugin.xml
and uses the same model generator (Modello),SchemaGenerator
that produces a single XML schema from a collection ofplugins.xml
files.apache/logging-log4j2#1955