dnault/therapi-runtime-javadoc

@Code tag doesn't always get reformatted

jhameier opened this issue · 4 comments

I noticed when running the formatter over a doc with slightly different code blocks that some appear to get formatted with <code> tags and others do not.

The driver:

import com.github.therapi.runtimejavadoc.ClassJavadoc;
import com.github.therapi.runtimejavadoc.CommentFormatter;
import com.github.therapi.runtimejavadoc.MethodJavadoc;
import com.github.therapi.runtimejavadoc.RuntimeJavadoc;

public class Driver {

  public static void main(String[] args) {
    ClassJavadoc javadoc = RuntimeJavadoc.getJavadoc(Test.class);
    MethodJavadoc methodJavadoc = javadoc.getMethods().get(0);
    String format = new CommentFormatter().format(methodJavadoc.getComment());
    System.out.println(format);
  }
}

The Test file:

public class Test {

  /**
   * <pre>{@code
   *    <Class>
   *         <Load>ask</Load>
   *         <ConstructArg>
   *            <ArgName>facilities</ArgName>
   *            <ArgType>java.lang.String</ArgType>
   *            <ArgValue>ZDC,ZOB,ZNY</ArgValue>
   *         </ConstructArg>
   *     </Class>
   * }</pre>
   *
   * <pre>{@code
   * echo 'net.ipv4.igmp_max_memberships=1024' > /usr/lib/sysctl.d/51-adsb.conf
   * }</pre>
   */
  public void testMethod() {}
}

The output:

<pre>{@code
    <Class>
         <Load>ask</Load>
         <ConstructArg>
            <ArgName>facilities</ArgName>
            <ArgType>java.lang.String</ArgType>
            <ArgValue>ZDC,ZOB,ZNY</ArgValue>
         </ConstructArg>
     </Class>
 }</pre>

 <pre><code>echo 'net.ipv4.igmp_max_memberships=1024' &gt; /usr/lib/sysctl.d/51-adsb.conf
 </code></pre>

On an aside in intellij

image

Regarding the aside, the JsonObject class marked in red is part of the Minimal-Json library that is bundled and repackaged with the reader. The Gradle "shadow" plugin is relocating the dependency classes, but doesn't update the sources. See GradleUp/shadow#41

Not much we can do about that, short of switching to Maven or undertaking the huge effort of enhancing the shadow plugin.

Hi John, Thanks for reporting this. I have a hunch the code that parses the "{@code ...}" inline tag does not expect a line break within the tag. I can take a look.

Yea, but strange thing is that both @code tags have a line break after them but the first doesn't get changed and the second one does. It also removes the line break when it changes the @code tag to the tag.