Repository navigation
Start on conventions.md #5
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |
| !.gitignore | ||
| !build.gradle | ||
| !config.json | ||
| !CONVENTIONS.md | ||
| !gradle.properties | ||
| !gradlew | ||
| !gradlew.bat | ||
|
|
||
| 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 | ||||||||||||||
|
|
||||||||||||||
| 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. | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the document should use
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. | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 American English spelling, such as “color” rather than “colour”. | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 lowercase for ordinary references to game content, such as “snow fox” rather than “Snow Fox”. Preserve capitalization when referring to code identifiers. | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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. | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
|
|
||||||||||||||
| Link when it helps the reader find related documentation; repeating a link on every mention is unnecessary. | ||||||||||||||
|
|
||||||||||||||
| ## Explain parameters and results only when needed | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||||||||||
|
|
||||||||||||||
| Keep parameter descriptions focused on useful details. For example: | ||||||||||||||
|
|
||||||||||||||
| ```markdown | ||||||||||||||
| @param namespace the namespace, restricted to `[a-z0-9_.-]` | ||||||||||||||
| ``` | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normal quotes instead of a fancy quotes as mentioned before.
Suggested change
|
||||||||||||||
There was a problem hiding this comment.
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.