You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "kwin (via GitHub)" <gi...@apache.org> on 2026/03/06 18:59:16 UTC
[PR] Make sure to emit metadata prior everything else [maven-doxia]
kwin opened a new pull request, #1042:
URL: https://github.com/apache/maven-doxia/pull/1042
Buffer everything until either body or head context is determined. Don't use init() from constructor to prevent inheritance related issues. Extract bufferStack into dedicated BufferingStackWriter.
This closes #1041
Following this checklist to help us incorporate your
contribution quickly and easily:
- [ ] Your pull request should address just one issue, without pulling in other changes.
- [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [ ] Each commit in the pull request should have a meaningful subject line and body.
Note that commits might be squashed by a maintainer on merge.
- [ ] Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
This may not always be possible but is a best-practice.
- [ ] Run `mvn verify` to make sure basic checks pass.
A more thorough check will be performed on your pull request automatically.
- [ ] You have run the integration tests successfully (`mvn -Prun-its verify`).
If your pull request is about ~20 lines of code you don't need to sign an
[Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
you have to acknowledge this by using the following check-box.
- [ ] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
- [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make sure to emit metadata prior everything else [maven-doxia]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #1042:
URL: https://github.com/apache/maven-doxia/pull/1042#discussion_r2900192539
##########
doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownSink.java:
##########
@@ -387,14 +398,31 @@ private void startContext(ElementContext newContext) {
elementContextStack.add(newContext);
}
+ private String toogleToRootContextWithoutBuffering(boolean dumpBuffer) {
+ final String buffer;
+ if (elementContextStack.element() == ElementContext.ROOT_WITH_BUFFERING) {
+ buffer = bufferingStackWriter.getCurrentBuffer().toString();
+ endContext(ElementContext.ROOT_WITH_BUFFERING);
+ if (dumpBuffer) {
+ write(buffer);
+ }
+ startContext(ElementContext.ROOT_WITHOUT_BUFFERING);
+ } else if (elementContextStack.element() != ElementContext.ROOT_WITHOUT_BUFFERING) {
+ throw new IllegalStateException("Unexpected context " + elementContextStack.element()
+ + ", expected ROOT_WITH_BUFFERING or ROOT_WITHOUT_BUFFERING");
+ } else {
+ buffer = "";
Review Comment:
The idea is to throw ISE when this is not called on the root context at all.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make sure to emit metadata prior everything else [maven-doxia]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #1042:
URL: https://github.com/apache/maven-doxia/pull/1042#issuecomment-4018746387
@kwin Please assign appropriate label to PR according to the type of change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make sure to emit metadata prior everything else [maven-doxia]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin merged PR #1042:
URL: https://github.com/apache/maven-doxia/pull/1042
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make sure to emit metadata prior everything else [maven-doxia]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #1042:
URL: https://github.com/apache/maven-doxia/pull/1042#discussion_r2900189344
##########
doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java:
##########
@@ -135,9 +135,20 @@ public Xhtml5BaseSink(Writer out) {
this.tableCaptionXMLWriterStack = new LinkedList<>();
this.tableCaptionStack = new LinkedList<>();
Review Comment:
Orthogonal to this PR, but in init, those are just cleared.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make sure to emit metadata prior everything else [maven-doxia]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #1042:
URL: https://github.com/apache/maven-doxia/pull/1042#discussion_r2900198487
##########
doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java:
##########
@@ -135,9 +135,20 @@ public Xhtml5BaseSink(Writer out) {
this.tableCaptionXMLWriterStack = new LinkedList<>();
this.tableCaptionStack = new LinkedList<>();
- init();
+ doInit();
}
+ /**
+ * Called from constructor and from {@link #init()} to initialize certain instance fields.
+ */
+ private void doInit() {
Review Comment:
Renamed in https://github.com/apache/maven-doxia/pull/1042/commits/977d4f6bf472e4b2817f855db1e6ce13c55bd8f6.
##########
doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownSink.java:
##########
@@ -341,21 +339,34 @@ private String escapeForTableCell(LastTwoLinesBufferingWriter writer, String tex
// ----------------------------------------------------------------------
protected static MarkdownSink newInstance(Writer writer) {
- LastTwoLinesBufferingWriter bufferingWriter = new LastTwoLinesBufferingWriter(writer);
- return new MarkdownSink(bufferingWriter, new PrintWriter(bufferingWriter));
+ BufferingStackWriter bufferingStackWriter = new BufferingStackWriter(writer);
+ LastTwoLinesAwareWriter lineAwareWriter = new LastTwoLinesAwareWriter(bufferingStackWriter);
+ return new MarkdownSink(lineAwareWriter, bufferingStackWriter);
}
/**
* Constructor, initialize the Writer and the variables.
*
* @param writer not null writer to write the result. <b>Should</b> be an UTF-8 Writer.
*/
- private MarkdownSink(LastTwoLinesBufferingWriter bufferingWriter, PrintWriter writer) {
- super(writer);
- this.bufferingWriter = bufferingWriter;
- this.writer = writer;
+ private MarkdownSink(LastTwoLinesAwareWriter lineAwareWriter, BufferingStackWriter bufferingStackWriter) {
+ super(lineAwareWriter);
+ this.lineAwareWriter = lineAwareWriter;
+ this.bufferingStackWriter = bufferingStackWriter;
+ doInit();
+ }
- init();
+ private void doInit() {
Review Comment:
Renamed in https://github.com/apache/maven-doxia/pull/1042/commits/977d4f6bf472e4b2817f855db1e6ce13c55bd8f6
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make sure to emit metadata prior everything else [maven-doxia]
Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on code in PR #1042:
URL: https://github.com/apache/maven-doxia/pull/1042#discussion_r2899720539
##########
doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java:
##########
@@ -135,9 +135,20 @@ public Xhtml5BaseSink(Writer out) {
this.tableCaptionXMLWriterStack = new LinkedList<>();
this.tableCaptionStack = new LinkedList<>();
- init();
+ doInit();
}
+ /**
+ * Called from constructor and from {@link #init()} to initialize certain instance fields.
+ */
+ private void doInit() {
Review Comment:
We should make it `initInternal()`
##########
doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownSink.java:
##########
@@ -341,21 +339,34 @@ private String escapeForTableCell(LastTwoLinesBufferingWriter writer, String tex
// ----------------------------------------------------------------------
protected static MarkdownSink newInstance(Writer writer) {
- LastTwoLinesBufferingWriter bufferingWriter = new LastTwoLinesBufferingWriter(writer);
- return new MarkdownSink(bufferingWriter, new PrintWriter(bufferingWriter));
+ BufferingStackWriter bufferingStackWriter = new BufferingStackWriter(writer);
+ LastTwoLinesAwareWriter lineAwareWriter = new LastTwoLinesAwareWriter(bufferingStackWriter);
+ return new MarkdownSink(lineAwareWriter, bufferingStackWriter);
}
/**
* Constructor, initialize the Writer and the variables.
*
* @param writer not null writer to write the result. <b>Should</b> be an UTF-8 Writer.
*/
- private MarkdownSink(LastTwoLinesBufferingWriter bufferingWriter, PrintWriter writer) {
- super(writer);
- this.bufferingWriter = bufferingWriter;
- this.writer = writer;
+ private MarkdownSink(LastTwoLinesAwareWriter lineAwareWriter, BufferingStackWriter bufferingStackWriter) {
+ super(lineAwareWriter);
+ this.lineAwareWriter = lineAwareWriter;
+ this.bufferingStackWriter = bufferingStackWriter;
+ doInit();
+ }
- init();
+ private void doInit() {
Review Comment:
ditto
##########
doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java:
##########
@@ -135,9 +135,20 @@ public Xhtml5BaseSink(Writer out) {
this.tableCaptionXMLWriterStack = new LinkedList<>();
this.tableCaptionStack = new LinkedList<>();
Review Comment:
These are not subject to init?
##########
doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownSink.java:
##########
@@ -387,14 +398,31 @@ private void startContext(ElementContext newContext) {
elementContextStack.add(newContext);
}
+ private String toogleToRootContextWithoutBuffering(boolean dumpBuffer) {
+ final String buffer;
+ if (elementContextStack.element() == ElementContext.ROOT_WITH_BUFFERING) {
+ buffer = bufferingStackWriter.getCurrentBuffer().toString();
+ endContext(ElementContext.ROOT_WITH_BUFFERING);
+ if (dumpBuffer) {
+ write(buffer);
+ }
+ startContext(ElementContext.ROOT_WITHOUT_BUFFERING);
+ } else if (elementContextStack.element() != ElementContext.ROOT_WITHOUT_BUFFERING) {
+ throw new IllegalStateException("Unexpected context " + elementContextStack.element()
+ + ", expected ROOT_WITH_BUFFERING or ROOT_WITHOUT_BUFFERING");
+ } else {
+ buffer = "";
Review Comment:
How can this be a tristate? It is either `ROOT_WITH_BUFFERING` or not, no?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make sure to emit metadata prior everything else [maven-doxia]
Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on code in PR #1042:
URL: https://github.com/apache/maven-doxia/pull/1042#discussion_r2900222778
##########
doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownSink.java:
##########
@@ -387,14 +398,31 @@ private void startContext(ElementContext newContext) {
elementContextStack.add(newContext);
}
+ private String toogleToRootContextWithoutBuffering(boolean dumpBuffer) {
+ final String buffer;
+ if (elementContextStack.element() == ElementContext.ROOT_WITH_BUFFERING) {
+ buffer = bufferingStackWriter.getCurrentBuffer().toString();
+ endContext(ElementContext.ROOT_WITH_BUFFERING);
+ if (dumpBuffer) {
+ write(buffer);
+ }
+ startContext(ElementContext.ROOT_WITHOUT_BUFFERING);
+ } else if (elementContextStack.element() != ElementContext.ROOT_WITHOUT_BUFFERING) {
+ throw new IllegalStateException("Unexpected context " + elementContextStack.element()
+ + ", expected ROOT_WITH_BUFFERING or ROOT_WITHOUT_BUFFERING");
+ } else {
+ buffer = "";
Review Comment:
Makes sense
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org