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
Add basic support of @author, @since, @return tags for methods and classes for javadoc (#1770) #2967
Add basic support of @author, @since, @return tags for methods and classes for javadoc (#1770) #2967
Conversation
Well done! Very impressive for the first contribution to Dokka. The questions seem very reasonable, I'll write out detailed answers as well as do a very high-level (API) review by the end of the week for sure, but hopefully much sooner than that |
…om margins of nested elements collapse, it makes the line gaps equal.
I've finally gotten to writing out my thoughts
The answer to both questions: Dokka's javadoc format is basically a copycat of Java's Javadoc format. So for questions like that, we can just generate the true native javadocs, and see what it outputs. Let's look at what it generates for the example you gave: /**
* @since 2021.03.10
* @author test author
*/
public class TestClass { } /**
* Simple test function
* @param s simple String parameter
* @param n simple Int parameter
* @author Initial Author
* @author First Contributor
* @author Second Contributor
* @since 20.04.2023
* @throws NullPointerException description
* @see List for information
* @return an empty list for now
*/
public String testFunction(String s, int n) {
return "Test";
} As you can see, it renders And the order should be like in the true Javadocs: parameters, return, since, see also, author (author is for classes only)
What you found are probably these tests. If that's the case, the
I'll leave a review comment for this piece of code so that there's a thread in which we can discuss it.
Not sure what exactly you mean. Could you clarify, what exactly is missing and where? |
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.
Well done! Looks like I only have two comments, and I'd be happy to merge the PR after they are resolved :)
upd: oh, forgot about the order of tags - I mentioned it in the previous comment. I don't think it matters much really, but having the same order as in Java's javadocs would be nice
plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt
Outdated
Show resolved
Hide resolved
plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt
Outdated
Show resolved
Hide resolved
Thank you for your feedback. I agree with all the points. The only thing I'd like to clarify is the purpose of the Javadoc format. I was sure it should be exactly the same as the Dokka default HTML but in a familiar Javadoc HTML layout. For example, in Dokka HTML, the @author tags are rendered for functions (and the author of the issue wanted @author for functions in their example - I think that's where my confusion started from). Kotlin documentation doesn't specify the types of entities that can have the @author tag:
So we render KDoc according to KDoc rules in the Javadoc HTML layout, don't we? I think that's what the Dokka users want. As for the @receiver tag, I meant not the @receiver tag itself but documentation for extension functions. Looking for a reference for rendering this tag content, I've noticed that Dokka default HTML misses extension functions.
|
…prove properties names
@IgnatBeresnev I don't mean to bother you, but have you been able to look through my thoughts in the comment above? |
Hi! Yeah, sorry, we've been busy with preparations for Kotlin 2.0 these the last couple of weeks, but you now have my full attention :)
If you have a mixed codebase with both Kotlin and Java, Java's If you have a Kotlin-only codebase, or if Kotlin is the primary/dominant language, there's really no reason to be using the Javadoc format, it's not the use case we want to support as we'd end up with a fork of the Javadoc format that we'd need to modify and support - for instance, because there are no top-level declarations in Java, there's no place for them on the Javadoc pages, so we'd need to add something custom. Little reason to do that if we already have our own primary HTML format
That could be the case if the Javadoc format had Kotlin signatures and features, but as you may have noticed, all Kotlin code is transformed to look like Java code. So Following this logic, I'd say the Kotlin code needs to be rendered using the same rules as the Java code, so KDoc should be adapter to be like Javadoc
I'm still not sure what you mean, sorry :( Kotlin has extension functions, these are displayed properly (just as the Kotlin code) in Dokka's own HTML format, example here. Java doesn't have extension functions as a concept. But Kotlin and Java have interoperability, so you should be able to call Kotlin functions from Java code. Kotlin's extension functions are compiled as static Java functions, where the receiver is converted to be the first argument of the static function. If you try calling a Kotlin extension from Java, you should see that. Dokka's Javadoc format translates Kotlin signatures to look like Java signatures. And because Java doesn't have extension functions, it translates them into static functions. Basically what you're seeing on your screenshot: So it looks like the signature is correct. The only problem I see is the documentation for
Right, and it shouldn't - in the Javadoc format it should look familiar to Java users :) Hopefully I was able to clear some things up |
Hi! Wow! You wrote kind of a book chapter for me. It seems I've fixed the things we had discussed. I also checked the Javadoc behavior for the It seems, that Please, notify me if I missed something |
Oh, I forgot to update api( Will be done in a minute |
Thank you, especially for the comparison screenshots :) I don't think I have anything else to add, well done! 👍 Could you please run After you do that, I'll start longer integration tests just in case, and will merge the PR after they pass |
The tests are looking good! There's only a slight problem with the empty "Since" tag, I left a comment. As soon as it's fixed, I'm ready to merge it :) |
Oh, right, I'd missed that. Fixed it |
Thanks for fixing it and thank you for the contribution! Looks like it's ready to be merged, and it will be released in Dokka 1.9.0 :) and sorry for the delay with review
No need now, the unit tests are good enough. Currently, the integration tests do not have such specific asserts - they just generally check that the documentation was built successfully, that all types were resolved and some similar common things, and they also upload the resulting output to the web somewhere so that we can open it in a browser and have a look (that's how I noticed the bug with the empty tag) |
Thank you for guiding me on my way to the first contribution to Dokka! |
…otlin#2967)" This reverts commit f457506.
This draft PR adds @author, @SInCE, and @return tags support for Javadoc output.
Here is an example:
The PR may need some improvements, and there are some questions I'd like to clarify before publishing the PR for review.
<p>
, and since the margin value isn't inherited, it causes larger gaps between list elements than in the parameters section. I will fix that in the following commits, but it's unclear what's the proper way to deal with that.(name = "Franklin D. Roosevelt")
. Do we need to process this syntax also?to contain also @sample and @see tags, for example, and to implement that in Classes, Functions, and Properties nodes.
And the interface
was planned to include @receiver and @throws tags.
Do you think this structure is appropriate, or should it be reworked?
6. Regarding the @receiver tag for extension functions. I've noticed that in Javadoc style it's rendered as
final List<String> testExtension(String $self, Integer n)
and is missing in Dokka style. I think it's a discussion for another issue, but I feel encouraged to help if needed.Pay attention that this causes API changes.
Thanks for your feedback in advance.