The Wayback Machine - https://web.archive.org/web/20201112101654/https://github.com/playframework/playframework/pull/10421
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

Open
wants to merge 1 commit into
base: 2.8.x
from

Conversation

@theejazz
Copy link

@theejazz theejazz commented Aug 12, 2020

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

@ignasi35 ignasi35 commented Oct 26, 2020

@Mergifyio backport master

@mergify
Copy link
Contributor

@mergify mergify bot commented Oct 26, 2020

Command backport master: pending

Waiting for the pull request to get merged

@ignasi35
Copy link
Member

@ignasi35 ignasi35 commented Oct 26, 2020

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));
   }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.