Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
!.gitignore
!build.gradle
!config.json
!CONVENTIONS.md
!gradle.properties
!gradlew
!gradlew.bat
Expand Down
65 changes: 65 additions & 0 deletions CONVENTIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Javadoc conventions

## Document what adds value

Explain what a developer cannot learn from the declaration, leave obvious members undocumented.

For example, `Gets the width.` adds nothing to `getWidth()`. If the unit matters, `Returns the width in pixels.` is useful.

Avoid descriptions such as `The position.` for `pos` or `The result.` for a return value.

## Start with a short summary

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Only the first line of this section is related to starting with a short summary. The rest of the section is concerned with, respectively: terminology, American vs British English spelling and capitalization.

Either the section could be split, or its title and content could be centred around how to write documentation prose.


Write a concise first sentence that makes sense on its own. Capitalize it and end it with a period. For methods, start with a verb such as “Returns”, “Sets”, or “Removes”. Add a blank line before further explanation.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the document should use ' and " instead of fancy quotes. This might also be a good thing to mention here so people use the correct ones in the Javadocs.
However, in lists like these I would recommend italic words instead of quotes so the sentences don't get cluttered with punctuation marks. On top of that, I would write the examples in lowercase despite being noted to be at the start of a sentence, as they are still part of this sentence.

Suggested change
Write a concise first sentence that makes sense on its own. Capitalize it and end it with a period. For methods, start with a verb such as “Returns”, “Sets”, or “Removes”. Add a blank line before further explanation.
Write a concise first sentence that makes sense on its own. Capitalize it and end it with a period. For methods, start with a verb such as *returns*, *sets*, or *removes*. Add a blank line before further explanation.


Use plain English and terminology consistent with Minecraft and nearby documentation. Describe behavior from the caller’s perspective rather than walking through the implementation.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normal quotes instead of a fancy quotes as mentioned before.

Suggested change
Use plain English and terminology consistent with Minecraft and nearby documentation. Describe behavior from the caller’s perspective rather than walking through the implementation.
Use plain English and terminology consistent with Minecraft and nearby documentation. Describe behavior from the caller's perspective rather than walking through the implementation.


Use American English spelling, such as “color” rather than “colour”.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same formatting as mentioned earlier, italic words rather than quotes.

Suggested change
Use American English spelling, such as “color” rather than “colour”.
Use American English spelling, such as *color* rather than *colour*.


Use lowercase for ordinary references to game content, such as “snow fox” rather than “Snow Fox”. Preserve capitalization when referring to code identifiers.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The developers do capitalise these words in official documents, such as in snapshot articles, so if you also want to stay consistent with Minecraft terminology these words should be capitalised imo

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same formatting as mentioned earlier, italic words rather than quotes. (The other comment about the capitalisation still stands)

Suggested change
Use lowercase for ordinary references to game content, such as “snow fox” rather than “Snow Fox”. Preserve capitalization when referring to code identifiers.
Use lowercase for ordinary references to game content, such as *snow fox* rather than *Snow Fox*. Preserve capitalization when referring to code identifiers.


## Use Markdown Javadoc

Use backticks for identifiers, literals, and short expressions. Separate paragraphs with blank lines; prefer Markdown lists and fenced code blocks over HTML. Include a short code example when it explains usage better than prose.

Prefer Markdown reference links over `{@link}` and `{@linkplain}` for references to classes and members. For example:

```markdown
Use [java.util.List#copyOf(java.util.Collection)] to create an unmodifiable copy.
```

Use `#` to reference a member of the current class, such as `[#clear()]`. Use `[clearing the entries][#clear()]` for a custom label in plain text, or a block tag such as `@see #clear()` for a related reference. Use ordinary Markdown links such as `[label](https://example.com)` for external URLs.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Use `#` to reference a member of the current class, such as `[#clear()]`. Use `[clearing the entries][#clear()]` for a custom label in plain text, or a block tag such as `@see #clear()` for a related reference. Use ordinary Markdown links such as `[label](https://example.com)` for external URLs.
Use `#` to reference a member of the current class, such as `[#clear()]`. Use `[clearing the entries][#clear()]` for a custom label in plain text, or a block tag such as `@see #clear()` for a related reference. Use ordinary Markdown links such as `[label](https://example.com)` for external URLs.


Link when it helps the reader find related documentation; repeating a link on every mention is unnecessary.

## Explain parameters and results only when needed

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Section overlaps a bit with the section on documenting only where it adds value, which explicitly uses obvious return values as an example of unnecessary documentation.

Unsure on how to remedy this (or if it's worth changing), but having two sections go over "only document when it helps the reader" in different regards feels a bit odd.


Use `@param`, `@return`, and `@throws` when they help the reader understand a parameter, result, or failure condition. Repeating information from the prose is fine when it makes the documentation clearer or easier to use. Parameter and return descriptions should be short phrases without an initial capital or final period.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Use `@param`, `@return`, and `@throws` when they help the reader understand a parameter, result, or failure condition. Repeating information from the prose is fine when it makes the documentation clearer or easier to use. Parameter and return descriptions should be short phrases without an initial capital or final period.
Use `@param`, `@return`, and `@throws` when they help the reader understand a parameter, result, or failure condition, respectively. Repeating information from the prose is fine when it makes the documentation clearer or easier to use. Parameter and return descriptions should be short phrases without an initial capital or final period.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be useful to require a specific tag order (this Oracle article is a useful reference) so all Javadocs stay consistently ordered. You could also disallow certain tags like @exception (as @throws is preferred) or @author.


Keep parameter descriptions focused on useful details. For example:

```markdown
@param namespace the namespace, restricted to `[a-z0-9_.-]`
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better to prefix these with the Javadoc comment so it's a little clearer:

/// @param namespace the namespace, restricted to `[a-z0-9_.-]`


For a hypothetical method whose timeout has a special value, this may be enough:

```markdown
Waits for pending work to finish.

@param timeout the maximum wait in milliseconds, or `0` to wait indefinitely
```

Other parameters can remain undocumented. Likewise, omit `@return` when the summary already explains the result. Use `@throws` to explain a relevant failure condition, not to list every exception the implementation could produce.

For example:

```markdown
@throws IdentifierException if the path contains a character outside `[a-z0-9/._-]`
```

Write the exception name immediately after `@throws` without backticks.

Inspired by [Yarn’s conventions](https://github.com/FabricMC/yarn/blob/1.21.11/CONVENTIONS.md) and [Effective Dart’s documentation guide](https://dart.dev/effective-dart/documentation).

For Markdown Javadoc syntax, see Oracle’s [Markdown in Documentation Comments](https://docs.oracle.com/en/java/javase/26/javadoc/using-markdown-documentation-comments.html) guide.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use either the currently latest available Java version (27) or 25 as that's the current LTS and version Minecraft uses at the moment.

Comment on lines +63 to +65

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normal quotes instead of a fancy quotes as mentioned before.

Suggested change
Inspired by [Yarn’s conventions](https://github.com/FabricMC/yarn/blob/1.21.11/CONVENTIONS.md) and [Effective Dart’s documentation guide](https://dart.dev/effective-dart/documentation).
For Markdown Javadoc syntax, see Oracle’s [Markdown in Documentation Comments](https://docs.oracle.com/en/java/javase/26/javadoc/using-markdown-documentation-comments.html) guide.
Inspired by [Yarn's conventions](https://github.com/FabricMC/yarn/blob/1.21.11/CONVENTIONS.md) and [Effective Dart's documentation guide](https://dart.dev/effective-dart/documentation).
For Markdown Javadoc syntax, see Oracle's [Markdown in Documentation Comments](https://docs.oracle.com/en/java/javase/26/javadoc/using-markdown-documentation-comments.html) guide.