From 1b4c43f7baea04cd1d5fbcdac030e454798f686c Mon Sep 17 00:00:00 2001 From: priya-soni Date: Tue, 28 Dec 2021 23:39:38 +0530 Subject: [PATCH] BAEL-5241 : Formatting code snippets as part of documentation comments (#11630) --- .../javadoc/CodeSnippetFormatting.java | 154 ++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 core-java-modules/core-java/src/main/java/com/baeldung/javadoc/CodeSnippetFormatting.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/javadoc/CodeSnippetFormatting.java b/core-java-modules/core-java/src/main/java/com/baeldung/javadoc/CodeSnippetFormatting.java new file mode 100644 index 0000000000..2bb9614e66 --- /dev/null +++ b/core-java-modules/core-java/src/main/java/com/baeldung/javadoc/CodeSnippetFormatting.java @@ -0,0 +1,154 @@ +package com.baeldung.javadoc; + +public class CodeSnippetFormatting { + + /** + * This is an example to show default behavior of code snippet formatting in Javadocs + * + * public class Application(){ + * + * } + * + */ + public void showCodeSnippetFormatting() { + // do nothing + } + + /** + * This is an example to show usage of HTML pre tag while code snippet formatting in Javadocs + * + *
+     * public class Application(){
+     *     List nums = new ArrayList<>();
+     * }
+     * 
+     * 
+ */ + public void showCodeSnippetFormattingUsingPRETag() { + // do nothing + } + + /** + * This is an example to show usage of HTML character entities while code snippet formatting in Javadocs + * + *
+     * public class Application(){
+     *     List<Integer> nums = new ArrayList<>();
+     * }
+     * 
+     * 
+ */ + public void showCodeSnippetFormattingUsingCharacterEntities() { + // do nothing + } + + /** + * This is an example to show usage of javadoc code tag while code snippet formatting in Javadocs + * + *
+     * 
+     * public class Application(){
+     *     {@code List nums = new ArrayList<>(); }
+     * }
+     *
+     * 
+ */ + public void showCodeSnippetFormattingUsingCodeTag() { + // do nothing + } + + /** + * This is an example to show issue faced while using annotations in Javadocs + * + *
+     * 
+     * public class Application(){
+     *            @Getter
+     *     {@code List nums = new ArrayList<>(); }
+     * }
+     *
+     * 
+ */ + public void showCodeSnippetFormattingIssueUsingCodeTag() { + // do nothing + } + + /** + * This is an example to show usage of javadoc code tag for handling '@' character + * + *
+     * 
+     * public class Application(){
+     *     {@code @Getter}
+     *     {@code List nums = new ArrayList<>(); }
+     * }
+     *
+     * 
+ */ + public void showCodeSnippetAnnotationFormattingUsingCodeTag() { + // do nothing + } + + + /** + * This is an example to show difference in javadoc literal and code tag + * + *

+ * + * {@literal @Getter} + * {@literal List nums = new ArrayList<>(); } + * + *
+ * {@code @Getter} + * {@code List nums = new ArrayList<>(); } + *

+ */ + public void showCodeSnippetCommentsFormattingUsingCodeAndLiteralTag() { + // do nothing + } + + /** + * This is an example to illustrate a basic jQuery code snippet embedded in documentation comments + *
+     * {@code }
+     * 
+ */ + public void showJSCodeSnippetUsingJavadoc() { + // do nothing + } + + /** + * This is an example to illustrate an HTML code snippet embedded in documentation comments + *
{@code
+     * 
+     * 
+     * 

Hello World!

+ * + * } + *
+ * + */ + public void showHTMLCodeSnippetUsingJavadoc() { + // do nothing + } + + /** + * This is an example to illustrate an HTML code snippet embedded in documentation comments + *
+     * 
+     * 
+     * 

Hello World!

+ * + * + *
+ * + */ + public void showHTMLCodeSnippetIssueUsingJavadoc() { + // do nothing + } + +}