Skip to content

Commit 245c345

Browse files
committed
Add docs with examples to Node classes
1 parent 40f1fd5 commit 245c345

23 files changed

+169
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ with the exception that 0.x versions can break between minor versions.
88

99
## [Unreleased]
1010
### Added
11+
- More documentation with examples for `Node` classes
1112
### Changed
1213
### Fixed
1314
- `MarkdownRenderer`: Fix precedence for `nodeRendererFactory`: Factories passed

commonmark/src/main/java/org/commonmark/node/BlockQuote.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
package org.commonmark.node;
22

3+
/**
4+
* A block quote, e.g.:
5+
* <pre>
6+
* &gt; Some quoted text
7+
* </pre>
8+
* <p>
9+
* Note that child nodes are themselves blocks, e.g. {@link Paragraph}, {@link ListBlock} etc.
10+
*
11+
* @see <a href="https://spec.commonmark.org/0.31.2/#block-quotes">CommonMark Spec</a>
12+
*/
313
public class BlockQuote extends Block {
414

515
@Override

commonmark/src/main/java/org/commonmark/node/BulletList.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
package org.commonmark.node;
22

3+
/**
4+
* A bullet list, e.g.:
5+
* <pre>
6+
* - One
7+
* - Two
8+
* - Three
9+
* </pre>
10+
* <p>
11+
* The children are {@link ListItem} blocks, which contain other blocks (or nested lists).
12+
*
13+
* @see <a href="https://spec.commonmark.org/0.31.2/#list-items">CommonMark Spec: List items</a>
14+
*/
315
public class BulletList extends ListBlock {
416

517
private String marker;

commonmark/src/main/java/org/commonmark/node/Code.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
package org.commonmark.node;
22

3+
/**
4+
* Inline code span, e.g.:
5+
* <pre>
6+
* Some `inline code`
7+
* </pre>
8+
*
9+
* @see <a href="https://spec.commonmark.org/0.31.2/#code-spans">CommonMark Spec</a>
10+
*/
311
public class Code extends Node {
412

513
private String literal;
@@ -16,6 +24,10 @@ public void accept(Visitor visitor) {
1624
visitor.visit(this);
1725
}
1826

27+
/**
28+
* @return the literal text in the code span (note that it's not necessarily the raw text between tildes,
29+
* e.g. when spaces are stripped)
30+
*/
1931
public String getLiteral() {
2032
return literal;
2133
}

commonmark/src/main/java/org/commonmark/node/CustomBlock.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.commonmark.node;
22

3+
/**
4+
* A block that extensions can subclass to define custom blocks (not part of the core specification).
5+
*/
36
public abstract class CustomBlock extends Block {
47

58
@Override

commonmark/src/main/java/org/commonmark/node/CustomNode.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.commonmark.node;
22

3+
/**
4+
* A node that extensions can subclass to define custom nodes (not part of the core specification).
5+
*/
36
public abstract class CustomNode extends Node {
47
@Override
58
public void accept(Visitor visitor) {

commonmark/src/main/java/org/commonmark/node/Document.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.commonmark.node;
22

3+
/**
4+
* The root block of a document, containing the top-level blocks.
5+
*/
36
public class Document extends Block {
47

58
@Override

commonmark/src/main/java/org/commonmark/node/Emphasis.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
package org.commonmark.node;
22

3+
/**
4+
* Emphasis, e.g.:
5+
* <pre>
6+
* Some *emphasis* or _emphasis_
7+
* </pre>
8+
*
9+
* @see <a href="https://spec.commonmark.org/0.31.2/#emphasis-and-strong-emphasis">CommonMark Spec: Emphasis and strong emphasis</a>
10+
*/
311
public class Emphasis extends Node implements Delimited {
412

513
private String delimiter;

commonmark/src/main/java/org/commonmark/node/FencedCodeBlock.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
package org.commonmark.node;
22

3+
/**
4+
* A fenced code block, e.g.:
5+
* <pre>
6+
* ```
7+
* foo
8+
* bar
9+
* ```
10+
* </pre>
11+
* <p>
12+
*
13+
* @see <a href="https://spec.commonmark.org/0.31.2/#fenced-code-blocks">CommonMark Spec</a>
14+
*/
315
public class FencedCodeBlock extends Block {
416

517
private String fenceCharacter;

commonmark/src/main/java/org/commonmark/node/HardLineBreak.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
package org.commonmark.node;
22

3+
/**
4+
* A hard line break, e.g.:
5+
* <pre>
6+
* line\
7+
* break
8+
* </pre>
9+
* <p>
10+
*
11+
* @see <a href="https://spec.commonmark.org/0.31.2/#hard-line-breaks">CommonMark Spec</a>
12+
*/
313
public class HardLineBreak extends Node {
414

515
@Override

0 commit comments

Comments
 (0)