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

Correct Java snippet rendering in Hello World tutorial #10421

Closed
wants to merge 2 commits into from

Conversation

theejazz
Copy link

This PR corrects a rendering error for a Java snippet from the Hello World tutorial. Specifically, versions 2.8.2 and 2.8.x of the Play Application Overview provide the following Java code:

public Result index() {
       return ok(views.html.index.render("Your new application is
  return ok(javaguide.hello.html.index.render("Your new application is ready.", assetsFinder));
}

which is meaningless and won't compile.

The problem is caused by the ###replace: directive from the PlayDoc library. Its purpose is to replace the code underneath the directive with the code directly after the directive. However, it cannot handle newlines within its input, so this fix turns it into a one-liner.

It might be useful to extend the PlayDoc with multiline replace directives if they get more future use, but this is a much more reasonable fix for now.

Lastly, I slightly changed the spacing between ###replace: and the code snippet to be replaced. It now aligns with the other replace directives in the file.

Cheers

The PlayDoc "###replace" directive only matches single lines, which caused the generated code to be jumbled with the replaced snippet and be incompilable. Aligned indentation with the other directives as well.
@ignasi35
Copy link
Member

@Mergifyio backport master

@mergify
Copy link
Contributor

mergify bot commented Oct 26, 2020

Command backport master: pending

Waiting for the pull request to get merged

@ignasi35
Copy link
Member

The build fails because the java formatter splits the comment into shorter lines:

   public Result index() {
-    // ###replace:     return ok(views.html.index.render("Your new application is ready.", assetsFinder));
+    // ###replace:     return ok(views.html.index.render("Your new application is ready.",
+    // assetsFinder));
     return ok(javaguide.hello.html.index.render("Your new application is ready.", assetsFinder));
   }

@octonato
Copy link
Contributor

Thanks @theejazz

This is already fixed in #10789, so I'm closing this PR.

@octonato octonato closed this Nov 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants