Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional cleanup for error-prone descriptions #93

Open
Philzen opened this issue Jun 16, 2024 · 1 comment
Open

Additional cleanup for error-prone descriptions #93

Philzen opened this issue Jun 16, 2024 · 1 comment
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@Philzen
Copy link

Philzen commented Jun 16, 2024

Following the discussion in openrewrite/rewrite-docs#282

The error-prone template descriptions by picnic seem to need some more treatment. See this example for https://docs.openrewrite.org/recipes/tech/picnic/errorprone/refasterrules/testngtoassertjrulesrecipes:

grafik

TODOs:

  • remove leading and trailing underscore
  • remove any <p> tags
  • convert the <pre>-block to a markdown code block and remove the surrounding {@code … } custom tag

openrewrite/rewrite-docs@5925d43 sort of already describes a good test case.

@timtebeek
Copy link
Contributor

Thanks for logging the issue separately; providing the context & links from the other issue for quick reference:

  • The JavaDoc for the original Refaster rule
  • This JavaDoc is then extracted into a recipe description with some light modifications already
    // Extract from JavaDoc
    Tokens.Comment comment = cu.docComments.getComment(classDecl);
    if (comment != null && comment.getText() != null && !comment.getText().isEmpty()) {
    String commentText = comment.getText()
    .replaceAll("\\{@\\S+\\s+(.*?)}", "`$1`")
    .replace("\\", "\\\\")
    .replace("\"", "\\\"")
    .replace("\b", "\\b")
    .replace("\t", "\\t")
    .replace("\f", "\\f")
    .replace("\r", "\\r");
    String[] lines = commentText.split("\\.\\R+", 2);
    displayName = lines[0].trim().replace("\n", "");
    if (displayName.endsWith(".")) {
    displayName = displayName.substring(0, displayName.length() - 1);
    }
    if (lines.length > 1 && !lines[1].trim().isEmpty()) {
    description = new StringBuilder(lines[1].trim().replace("\n", "\\n"));
    if (!description.toString().endsWith(".")) {
    description.append('.');
    }
    }
    }
  • The description is converted into Markdown in this generator, which should already account for the _ 🤔

All in all this will require some fixes both here and in the markdown generator, before they show up as fixed in the docs.

@timtebeek timtebeek added bug Something isn't working documentation Improvements or additions to documentation and removed enhancement New feature or request labels Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
Status: Backlog
Development

No branches or pull requests

2 participants