[
https://issues.apache.org/jira/browse/DOXIA-710?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17800099#comment-17800099
]
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_r1435692207
##########
doxia-core/src/main/java/org/apache/maven/doxia/index/IndexEntry.java:
##########
@@ -53,10 +56,41 @@ public class IndexEntry {
*/
private List<IndexEntry> childEntries = new ArrayList<>();
+ public enum Type {
+ /**
+ * Used for unknown types but also for the root entry
+ */
+ UNKNOWN,
+ SECTION_1,
+ SECTION_2,
+ SECTION_3,
+ SECTION_4,
+ SECTION_5,
+ SECTION_6,
+ DEFINED_TERM,
+ FIGURE,
+ TABLE;
+
+ static Type fromSectionLevel(int level) {
+ if (level < SECTION_1.ordinal() || level > SECTION_6.ordinal()) {
+ throw new IllegalArgumentException("Level must be between " +
SECTION_1.ordinal() + " and "
+ + SECTION_6.ordinal() + " but is " + level);
+ }
+ return Arrays.stream(Type.values())
+ .filter(t -> level == t.ordinal())
+ .findAny()
+ .orElseThrow(() -> new IllegalStateException("Could not
find enum with ordinal " + level));
+ }
+ };
/**
* The type of the entry, one of the types defined by {@link IndexingSink}
*/
- private final int type;
+ private final Type type;
+
+ /**
+ * System-dependent EOL.
+ */
+ private static final String EOL = System.getProperty("line.separator");
Review Comment:
Why not `Markup.EOL`?
##########
doxia-core/src/main/java/org/apache/maven/doxia/index/IndexEntry.java:
##########
@@ -53,10 +56,41 @@ public class IndexEntry {
*/
private List<IndexEntry> childEntries = new ArrayList<>();
+ public enum Type {
+ /**
+ * Used for unknown types but also for the root entry
+ */
+ UNKNOWN,
+ SECTION_1,
+ SECTION_2,
+ SECTION_3,
+ SECTION_4,
+ SECTION_5,
+ SECTION_6,
+ DEFINED_TERM,
+ FIGURE,
+ TABLE;
+
+ static Type fromSectionLevel(int level) {
+ if (level < SECTION_1.ordinal() || level > SECTION_6.ordinal()) {
Review Comment:
In general, it is a bad practice to the use ordinal for this. The ordinal is
rather an internal value. See Effective Java from Joshua Bloch. Better to
introduce a constructor value for this.
> 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)