Repository navigation
Conversation
Earthcomputer
left a comment
There was a problem hiding this comment.
I'm surprised the javadoc lint was okay with [a-z0-9/._-], I'd have thought that would be interpreted as a link
modmuss50
left a comment
There was a problem hiding this comment.
Sorry for being picky, but I think we need to be on these early PRs, Ill have a PR with some convensions soon so hopefully that will help.
Co-authored-by: Joseph Burton <burtonjae@hotmail.co.uk>
|
Picky is good - didn't know about |
|
I recommend looking at this article as it explains the available keywords, as well as this article for markdown formatting as some keywords (like As for this earlier comment:
It's 'accepted' but renders the text red as it can't find the reference, as |
|
The javadoc lint is supposed to check that references are valid... |
|
Ah. If you're talking about the changes from #4, this branch doesn't have those commits, so it's not checking anything. |
|
No, the javadoc lint was added in #1 |
|
The task only seems to fail for cases where the body has a correct reference format, but the reference itself is invalid. I think it passes because A few tests with these references gave the following results:
|
|
I have tested it, the javadoc tool only treats it as a link if the text inside the |
|
Sorry - why would it be read as a link in the first place? It's wrapped in a code block. |
|
We're talking about before it was wrapped in a code block and worrying about why it wasn't caught by any lint. It might be something for @its-miroma's linter to catch |
|
|
its-miroma
left a comment
There was a problem hiding this comment.
This review of mine is intentionally way too nitpicky, because we need to properly establish the conventions to follow.
My comments aren't necessarily changes to be applied, some are food for thought and discussion.
| @@ -0,0 +1,40 @@ | |||
| CLASS net/minecraft/resources/Identifier | |||
| COMMENT `Identifier`s are used in Minecraft's code to identify a resource's location. | |||
There was a problem hiding this comment.
The Docs' refreshed guidelines say: "Avoid specifying that the [modded] game is Minecraft"
Should we apply that rule to Annotater too?
There was a problem hiding this comment.
IMO, we should not apply that to the annotator, since the code is not modified yet.
There was a problem hiding this comment.
That's even more of a reason why mentioning "Minecraft" is redundant.
There was a problem hiding this comment.
Annotater's guidelines don't specify this, I think the clarification is fine.
| COMMENT To avoid ambiguity, they consist of a namespace representing the creator of the resource and the path to the resource. | ||
| COMMENT When converted to a string, the namespace and path are combined becoming `namespace:path`. | ||
| METHOD assertValidPath (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; | ||
| COMMENT @throws IdentifierException If the path contains a non `[a-z0-9/._-]` character. |
There was a problem hiding this comment.
I'm not super familiar with javadocs conventions, is this supposed to be read as a sentence? Should "If" be lowercase?
This is an internal private method, should it be documented?
There was a problem hiding this comment.
Technically all Minecraft methods are "internal". I don't think we should limit ourselves to only documenting what is public, assuming there is actually something worth documenting.
There was a problem hiding this comment.
A private method is only intended to be used by that class, so in that sense it's internal. I think we might want to avoid documenting methods unless they are public or access-widened, to keep the scope of the project contained.
There was a problem hiding this comment.
access widened methods do not exist in the annotater realm.
There was a problem hiding this comment.
I don't see the harm in documenting private methods if it benefits the user. Neither Yarn or Annotater had restrictions about documenting private methods.
| COMMENT @throws IdentifierException If the path contains a non `[a-z0-9/._-]` character. | ||
| METHOD fromNamespaceAndPath (Ljava/lang/String;Ljava/lang/String;)Lnet/minecraft/resources/Identifier; | ||
| COMMENT Creates an identifier from a namespace and a path. | ||
| COMMENT @param namespace The namespace, restricted to `[a-z0-9_.-]`. |
There was a problem hiding this comment.
The "Effective Dart: Documentation" page that our guidelines cite discourage the usage of @param, especially when the description is redundant. Instead, they suggest formatting it as prose, like:
Both [namespace] and [path] are restricted to `[a-z0-9/._-]`.In fact, given that we have a @throws clause, in this case we might want to do something like:
@throws IdentifierException if either [namespace] or [path] contain an invalid character.Question: can multiple @throws clauses reference the same error?
@throws IdentifierException if [namespace] contains an invalid non-`[a-z0-9._-]` character.
@throws IdentifierException if [path] contains an invalid non-`[a-z0-9/._-]` character.There was a problem hiding this comment.
Annotater's guidelines do not discourage the use of @param, I think it is a benefit to be able to see descriptions on the parameters themselves.
There was a problem hiding this comment.
That's interesting, I was not aware of that detail regarding @param.
| METHOD toLanguageKey (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; | ||
| COMMENT @return A translation key in the format `prefix.namespace.path.suffix`. | ||
| METHOD toShortLanguageKey ()Ljava/lang/String; | ||
| COMMENT @return A translation key in the format `namespace.path`. If the namespace is `minecraft`, the translation key is shortened to `path`. |
There was a problem hiding this comment.
Should we reference other methods? For example:
Similar to [toLanguageKey], but drops the default [namespace] `minecraft`.Question: can multiple @return clauses be used in the same comment?
@return A translation key in the format `namespace.path`.
@return A translation key in the format `path`, if the [namespace] is {@value #DEFAULT_NAMESPACE}.There was a problem hiding this comment.
yes, multiple @return clauses can be used in the same comment and will be formatted like multiple @param clauses.
There was a problem hiding this comment.
I think referencing other methods makes sense. Multiple @return declarations doesn't though, this isn't allowed per the javadoc spec.
There was a problem hiding this comment.
I think referencing other methods makes sense. Multiple
@returndeclarations doesn't though, this isn't allowed per the javadoc spec.
It isn't?
| COMMENT @param namespace The namespace, restricted to `[a-z0-9_.-]`. | ||
| COMMENT @param path The path, restricted to `[a-z0-9/._-]` |
There was a problem hiding this comment.
Maybe this description of namespace and path, and their constraints, should be moved to the class comment? That way all methods would document what they do with invalid parameters (throw, return null, etc).
There was a problem hiding this comment.
Annotater's guidelines allow for repeated descriptions like these - being able to see them when looking at a method is better than having to check the class itself.
There was a problem hiding this comment.
Would it make sense to reference the ALLOWED_NAMESPACE_CHARACTERS constant here instead?
| COMMENT @param path The path, restricted to `[a-z0-9/._-]` | ||
| COMMENT @return An `Identifier` created from the namespace and path, or `null` if either string contains an invalid character. | ||
| METHOD withDefaultNamespace (Ljava/lang/String;)Lnet/minecraft/resources/Identifier; | ||
| COMMENT Creates an `Identifier` in the vanilla `minecraft` namespace. |
There was a problem hiding this comment.
Should we reference DEFAULT_NAMESPACE?
The @param description is more verbose than the other comments.
There was a problem hiding this comment.
I'm not sure - DEFAULT_NAMESPACE is a variable that's inlined at the compilation stage. We'll need to decide what to do about variables like these that need unpicking.
| COMMENT @return A new `Identifier` with the same namespace and a different path. | ||
| METHOD withPath (Ljava/util/function/UnaryOperator;)Lnet/minecraft/resources/Identifier; | ||
| COMMENT @param modifier A modifier to prepend to the existing path, with the result restricted to `[a-z0-9/._-]` | ||
| COMMENT @return Creates a new `Identifier` with the same namespace and a different path. |
There was a problem hiding this comment.
I don't know if this. is allowed in javadocs like these:
@return a new [Identifier] with the same [this.namespace] and the new [path].I also think that we should prefer references to code blocks, such as [Identifier] instead of `Identifier`, because the former can be validated.
There was a problem hiding this comment.
It is valid by prepending it with a #; [#namespace] refers to the namespace field. As for the method parameters, those aren't valid references within the class, so using inline code is fine.
@return a new [Identifier] with the same [#namespace] and the new `path`.| COMMENT @param path the path, restricted to `[a-z0-9/._-]` | ||
| COMMENT @return an `Identifier` created from the namespace and path, or `null` if either string contains an invalid character. | ||
| METHOD withDefaultNamespace (Ljava/lang/String;)Lnet/minecraft/resources/Identifier; | ||
| COMMENT Creates an `Identifier` with the namespace set to [DEFAULT_NAMESPACE]. |
There was a problem hiding this comment.
| COMMENT Creates an `Identifier` with the namespace set to [DEFAULT_NAMESPACE]. | |
| COMMENT Creates an [Identifier] with the [default namespace][#DEFAULT_NAMESPACE]. |
Renders like this, which reads more like a sentence:
Creates an Identifier with the default namespace.

Not comprehensive - opening this PR as a test of the editing/submission process.