Skip to content

Javadoc code language is not migrated correctly to Markdown #1127

@barbulescu

Description

@barbulescu

What version of OpenRewrite are you using?

I am using

  • OpenRewrite main branch
  • Maven/Gradle plugin 6.41.0
  • rewrite-migrate-java_ 3.36.0

How are you running OpenRewrite?

I am using the Maven plugin, and my project is a mult-module project.

    <profile>
      <id>openrewrite</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.openrewrite.maven</groupId>
            <artifactId>rewrite-maven-plugin</artifactId>
            <version>6.41.0</version>
            <configuration>
              <exportDatatables>true</exportDatatables>
              <activeRecipes>
                <recipe>org.openrewrite.java.migrate.lang.JavadocToMarkdownDocComment</recipe>
              </activeRecipes>
            </configuration>
            <dependencies>
              <dependency>
                <groupId>org.openrewrite.recipe</groupId>
                <artifactId>rewrite-migrate-java</artifactId>
                <version>3.36.0</version>
              </dependency>
            </dependencies>
          </plugin>
        </plugins>
      </build>
    </profile>

What is the smallest, simplest way to reproduce the problem?

@Test
    public void codeClassShouldBeAddedToMarkdown() {
        rewriteRun(
          spec -> spec.recipe(new JavadocToMarkdownDocComment()),
          java(
            """
              class Test {
                  /**
                   * Examples:
                   * <pre><code class='java'>
                   * // assertion succeeds:
                   * assertThat("foo").isEqualTo("foo");
                   * </code></pre>
                   */
                  public void withErrorMessageForFields() {
                  }
              }
              """,
            """
              class Test {
                  /// Examples:
                  /// ```java
                  /// // assertion succeeds:
                  /// assertThat("foo").isEqualTo("foo");
                  /// ```
                  public void withErrorMessageForFields() {
                  }
              }
              """)
        );
    }

What did you expect to see?

see above

What did you see instead?

@Test
    public void codeClassShouldBeAddedToMarkdown() {
        rewriteRun(
          spec -> spec.recipe(new JavadocToMarkdownDocComment()),
          java(
            """
              class Test {
                  /**
                   * Examples:
                   * <pre><code class='java'>
                   * // assertion succeeds:
                   * assertThat("foo").isEqualTo("foo");
                   * </code></pre>
                   */
                  public void withErrorMessageForFields() {
                  }
              }
              """,
            """
              class Test {
                  /// Examples:
                  /// ```<code class='java'>
                  /// // assertion succeeds:
                  /// assertThat("foo").isEqualTo("foo");
                  /// ```
                  public void withErrorMessageForFields() {
                  }
              }
              </code>""")
        );
    }

What is the full stack trace of any errors you encountered?

Are you interested in contributing a fix to OpenRewrite?

I will try to provide a fix, too.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions