-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMarkdownDocumentationComments.java
More file actions
89 lines (81 loc) · 2.88 KB
/
Copy pathMarkdownDocumentationComments.java
File metadata and controls
89 lines (81 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package java23.markdown;
/**
* Java 23 Markdown Documentation Comments Demonstrates using Markdown syntax in Javadoc comments
* This feature allows you to use Markdown syntax in Javadoc comments, making documentation more readable and easier to write.
*/
public class MarkdownDocumentationComments
{
/**
* # Example Method
* This method demonstrates **Markdown** syntax in Javadoc.
* ## Features
* - **Bold text** using `**text**` - *Italic text* using `*text*` - Code blocks using backticks - Lists and nested structures
* ### Usage
* ```java MarkdownDocumentationComments example = new MarkdownDocumentationComments(); example.exampleMethod(); ```
*
* @param value The input value (must be > 0)
* @return The processed result
* @throws IllegalArgumentException if value <= 0
*/
public int exampleMethod(int value)
{
if (value <= 0)
{
throw new IllegalArgumentException("Value must be positive");
}
return value * 2;
}
/**
* ## Class Overview
* This class demonstrates **Markdown** in Javadoc comments.
* ### Key Points
* 1. Markdown syntax is supported 2. Makes documentation more readable 3. Easier to write and maintain
* ### Example
* ```java // Create instance MarkdownDocumentationComments obj = new MarkdownDocumentationComments();
* // Call method int result = obj.exampleMethod(5); ```
*/
public static void main(String[] args)
{
System.out.println("=== Java 23 Markdown Documentation Comments ===\n");
System.out.println("Overview:");
System.out.println("--------");
System.out.println("Java 23 allows you to use Markdown syntax in Javadoc comments.");
System.out.println("This makes documentation more readable and easier to write.\n");
System.out.println("Supported Markdown Features:");
System.out.println("- Headers (#, ##, ###)");
System.out.println("- Bold text (**text**)");
System.out.println("- Italic text (*text*)");
System.out.println("- Code blocks (```)");
System.out.println("- Inline code (`code`)");
System.out.println("- Lists (-, *, 1.)");
System.out.println("- Links ([text](url))");
System.out.println("- Tables");
System.out.println("\nExample Javadoc with Markdown:");
System.out.println("""
/**
* # Title
*
* This is a **bold** statement and *italic* text.
*
* ## Section
*
* - Item 1
* - Item 2
*
* ### Code Example
*
* ```java
* int value = 42;
* ```
*/
""");
System.out.println("\nBenefits:");
System.out.println("- More readable documentation");
System.out.println("- Easier to write");
System.out.println("- Better formatting");
System.out.println("- Standard Markdown syntax");
System.out.println("- Works with existing Javadoc tools");
System.out.println("\nNote: This feature is available in Java 23+.");
System.out.println("No special flags needed - just use Markdown in your Javadoc comments!");
}
}