[ https://issues.apache.org/jira/browse/DOXIA-710?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17797415#comment-17797415 ]
ASF GitHub Bot commented on DOXIA-710: -------------------------------------- michael-o commented on code in PR #180: URL: https://github.com/apache/maven-doxia/pull/180#discussion_r1428795972 ########## doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java: ########## @@ -189,6 +229,25 @@ protected boolean isSecondParsing() { return secondParsing; } + @Override + public void registerSinkWrapperFactory(SinkWrapperFactory factory) { Review Comment: Maybe rather `get`/`add` semantic names? ########## doxia-core/src/main/java/org/apache/maven/doxia/index/IndexingSink.java: ########## @@ -76,19 +80,41 @@ public class IndexingSink extends SinkAdapter { */ private final Map<String, AtomicInteger> usedIds; + private final IndexEntry rootEntry; + + /** + * @deprecated legacy constructor, use {@link #IndexingSink(Sink)} with {@link SinkAdapter} as argument and call {@link #getRootEntry()} to retrieve the index tree afterwards. + */ + @Deprecated + public IndexingSink(IndexEntry rootEntry) { + this(rootEntry, new SinkAdapter()); + } + + public IndexingSink(Sink delegate) { + this(new IndexEntry("index"), delegate); + } + /** * Default constructor. - * - * @param sectionEntry The first index entry. */ - public IndexingSink(IndexEntry sectionEntry) { + private IndexingSink(IndexEntry rootEntry, Sink delegate) { + super(delegate); + this.rootEntry = rootEntry; stack = new Stack<>(); - stack.push(sectionEntry); + stack.push(rootEntry); usedIds = new HashMap<>(); - usedIds.put(sectionEntry.getId(), new AtomicInteger()); + usedIds.put(rootEntry.getId(), new AtomicInteger()); init(); } + /** + * This should only be called once the sink is closed. + * Before that the tree might not be complete. + * @return the tree of entries starting from the root + */ + public IndexEntry getRootEntry() { + return rootEntry; + } Review Comment: You see a way to throw ISE if the documented condition is not met? ########## doxia-core/src/main/java/org/apache/maven/doxia/parser/SinkWrapperFactory.java: ########## @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.doxia.parser; + +import org.apache.maven.doxia.sink.Sink; + +/** + * A factory for a sink wrapping another sink. + * The delegate may either be the original sink or another wrapper. + * @since 2.0.0 + */ +public interface SinkWrapperFactory { + + /** + * By default all wrappers just delegate each method to the wrapped sink's method. + * For certain Sink methods the wrapper may modify the sink before/after or instead of calling the delegate's method. + * @param sink the delegate + * @return a new sink wrapping the given one + */ + Sink createWrapper(Sink sink); + + /** + * Determines the order of sink wrappers. The highest ranked wrapper factory is called first. + * @return the rank of this factory + */ + int getRank(); Review Comment: In DI we use the term priority. Maybe that be suit here too? This making the terms consistent while `Integer.MAX_VALUE` would be the highest one? Comment talks about order, but method name is rank... > Inconsistent anchors between toc macro and headers > -------------------------------------------------- > > Key: DOXIA-710 > URL: https://issues.apache.org/jira/browse/DOXIA-710 > Project: Maven Doxia > Issue Type: Bug > Reporter: Slawomir Jaranowski > Assignee: Konrad Windszus > Priority: Critical > > In markdown document add: > {code:java} > <!-- MACRO{toc|fromDepth=2} --> > {code} > Then anchors generated by toc macro looks like: {{#Your_First_Mojo}} > and anchors generated by skin looks like: {{#your-first-plugin}} > - Doxia Site Renderer 2.0.0-M4 > - Fluido Skin 1.11.1 > Tested on Maven main site without more investigate. -- This message was sent by Atlassian Jira (v8.20.10#820010)