-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[MS9] Schema and documentation generation from source code #1954
Comments
I think I've proposed something along these lines in the past, but it seemed like too much work at the time. However, I love this idea in general. It would be great if we could extract JavaDoc metadata from plugin declarations to help form the documentation. Otherwise, we have a lot of duplicated information about plugins. Might also be useful to include metadata that specifies some sample source files to inline for examples. |
The plan is to delete all The manual will be split into a Configuration Reference (cf Tomcat's reference) and a User Guide (cf. Tomcat's user guide). The latter will only explain how the system works, how to use the different configuration formats (with examples) and will not be encumbered with lots of technical details. The Configuration Reference can even collect documentation from third-party plugin developers, if they embed metadata into their jars (or publish on Maven). |
Note that |
I have published a preview of a documentation generated from real data. Interesting pages:
|
The descriptions are taken from Javadoc comments, which shows us how many Javadoc comments are missing. Also the links in the descriptions (which are taken from |
Great work Piotr! 💯 👏
What is the plan to address this shortcoming? |
As far as I understand we can either:
|
Looks good to me, thanks for all the hard work! |
Abstract: This PR completes the STF milestone 9 by implementing the infrastructure to auto-generate 1) the Log4j plugin documentation (to be deployed as a part of the Log4j website) and 2) the XSD (for assisting the Log4j runtime configuration, i.e.,
log4j2.xml
, in user applications).The problem description
Log4j runtime is a composition of 300+ plugins, which is analogous to beans in Java EE and Spring applications. Developers document these plugins in the website. Users assemble them in the
log4j2.xml
file describing their Log4j runtime configurations.Currently, several plugins are either not documented (e.g. LOG4J2-3485), or their documentation doesn't match the behaviour of the source code. This not only causes users to misconfigure their applications or not be aware of all options available to them, but can also pose security implications due to unintended (mis)configurations. Next to lacking documentation, the
log4j-config.xsd
file users use to get assisted while assembling theirlog4j2.xml
configurations is severely outdated. It doesn't cover a very big part of the available plugin ecosystem.Deliverable 1: Log4j Docgen
Log4j Docgen (Documentation Generator) project aims to attack this problem by generating 1) the documentation, 2) plugin configuration options, and 3) XSD from the Java source code of the Log4j project itself. Effectively, this enables the following improvements:
json-template-layout.adoc
page for the website, again, documenting each component. Last, but not least,log4j-config.xsd
also needs to be updated (which is not!) to document all these whistles and bells too. By generating documentation from the source code, developers can precisely capture the behaviour of their components only in the very code itself that they change. As a result, there will be one and only place of the truth: the source code itself.Currently being released Log4j Tools
0.8.0
bundles several components to implement this end-to-end operation. Refer to the Log4j Tools0.8.0
website to read about all these new exciting Log4j Docgen features. Implementation details of the newlog4j-docgen
,log4j-docgen-maven-plugin
, andlog4j-docgen-asciidoc-extension
can be viewed in this diff.Deliverable 2: Log4j plugin documentation and XSD
Of course, it would not be complete to announce this work as complete without demonstrating its integration into the Log4j project itself. The
2.x-docgen
and3.x-docgen
branches of the Log4j repository contain the changes that integrate Log4j Docgen into Log4j 2 and 3, respectively, to generate plugin reference manual to be built along with the website and to generate the plugin XSD (aka.log4j-config.xsd
) capturing the type hierarchy of the available set of plugins. (The branch will be merged after the Log4j Tools0.8.0
release scheduled for 2024-03-21.)Deliverable 3: Centralizing XML namespace
Log4j project publishes four major XSDs:
Yet there does not exist a central place where users can access to all available versions of all these XSDs with sufficient descriptions. Inspired by the battle-tested principles practiced in Java EE: XML Schemas for Java EE Deployment Descriptors, we have compiled https://logging.apache.org/xml/ns/ for this purpose.
Implementation details
The bulk of the work is accessible in two locations:
0.8.0
release (the changes incorporated)2.x
site #24043.x
site #2407Other supporting ground work is implemented in following tasks:
xmllint
(cf. Fix regex error in Log4j-config.xsd #2357)The text was updated successfully, but these errors were encountered: