-
Notifications
You must be signed in to change notification settings - Fork 6
Consolidate Parameter annotation data into Op Javadoc #28
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
Conversation
d048699 to
fe13f4b
Compare
|
To set up javadoc scraping within your own Java 11 Maven project:
NOTE: depending on scijava-ops will automatically register all three of these dependencies
For users of JPMS, there is an additional step: You must module foo {
exports foo.bar to therapi.runtime.javadoc;
exports foo.baz to therapi.runtime.javadoc;
opens foo.bar to therapi.runtime.javadoc;
opens foo.baz to therapi.runtime.javadoc;
requires therapi.runtime.javadoc;
uses javax.annotation.processing.Processor;
}You must open and export to all projects you wish to scrape the javadoc of. I have created a small example of how this works here |
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.
Thank you very much for working on this! ✨ I am excited to see the @Parameter annotation DIAF. 😆 🔥
We discussed a bit some of the issues surrounding this work. Here are some thoughts, in no particular order:
- Therapi is an source-time annotation processor. It might have access to the parameter names of methods, even though they are typically not stored into the bytecode. If so, we could map the
@paramnames to the actual parameter names, in case the@paramdeclarations are out of order, or some are missing, or some are spurious. This would be better than the current assumption that everything is there, and in same order as the method. However, it's not a blocker for merging this PR—it can always be fixed later. The question for then is: do we need to fork therapi, or write our own annotation processor with analogous logic, or what? - Relatedly, there is also the flag allowing to compile parameter names into the bytecode—we could add this to pom-scijava so that every project does this by default. It expands the bytecode a little, but in my tests, it was small (<3%? I don't remember exactly). But does Ops need it?
- We should test whether
<scope>provided</scope>works for the therapi-related dependencies. Certainly, we do not want otherwise-independent projects such asimglib2-algorithmto become polluted with therapi runtime dependencies; it is only ops that needs to depend on it at runtime, for reading the javadoc. Relatedly, we should test in both JPMS and non-JPMS scenarios. Curtis thinks provided scope is probably not what we ultimately want, even if it works, because it's also a form of dependency pollution of sorts. What we really want is to add therapi to the annotation processor classpath. This can be done in themaven-compiler-pluginconfiguration. Here is an SO post about it; in a nutshell, you can add the deps to the compiler plugin's dependencies, instead of the project dependencies. - In the case of mixed
@paramand@input/@output, therapi indexes things in such a way that the order is lost. We should consider either:- Submitting an issue and/or PR to therapi adding a general-purpose getter of all the javadoc annotations in original order; or
- Fork therapi and merge its logic into scijava-indexer, so that everyone can have this functionality without incurring additional annotation-time dependencies.
As far as what actually needs to happen for this PR to merge:
- Convert therapi usage to annotation processor classpath (i.e. maven-compiler-plugin classpath). Ensure it works.
- Clean up git history.
- File issues for any remaining concerns, as detailed above.
- Remove support for
@input/@output/etc. fromOpClassandOpMethod. People need to always use@param/@returnfor those types of ops. Otherwise, the javadoc won't be fully correct. This also avoids dealing with issue (4) above. - Log a warning for any op that does not have properly javadoc'd parameters.
- Fix the JPMS configuration: every package that we want javadoc for needs to be opened and exported to therapi. This raises a larger question of: is there automation we could introduce into pom-scijava easing the burden of
module-info.javafor our community? This is outside the scope of ops specifically, but would be super helpful for people.
cd3774b to
6692444
Compare
I solved this issue by using Apache Velocity to autogenerate the
This is also fixed. Interestingly, I found out that therapi treats these as equivalent: /**
* Tests javadoc scraping of mutable taglet
*
* @param foo the i/o argument
*/ /**
* Tests javadoc scraping of mutable taglet
*
* @param foo the i/o argument
* @return
*/As far as I can tell, there is no way to determine whether the |
0822a9b to
6bbcd18
Compare
|
In response to the logging bullet point, I have created issue scijava/scijava#64 (as it should sit on the backburner until scijava/scijava#13 has been completed). For that reason, I will check that bullet point. |
958a97c to
30f47f9
Compare
|
@ctrueden as of this writing, all commits build with passing tests One consideration for a future issue: we still use Velocity to generate the |
30f47f9 to
f0b8c1c
Compare
f0b8c1c to
a654a04
Compare
There were two different methods that wrote printouts for OpInfos, using
rather different syntaxes. We decided that one syntax was better, and
added member highlight support (which was only available using the other
syntax).
It has outlived its usefulness to us. RIP
This change applies only to method and class Ops, however it enables @input synonymous with @param and @output synonymous with @return. This also allows us to use @container and @mutable on Ops written as classes and as methods. This then changes the paradigm to make the parsing of @param and @return a bonus, but favors using @input and @output respectively.
Suppose that an Inplace OpMethod is annotated with the functional interface BiFunction. We must catch these situations quickly and fail before the struct is generated, as it is not the job of ParameterStructs to deal with incorrectly annotated methods
Used so that we maintain one tag per input for Ops written as methods. This taglet should not appear on Ops written as Fields or as Classes (although it will not break anything if they do, the javadoc parser just ignores these lines)
Unnecessary - maven handles this for us
Not sure how these escaped the purge
The annotation processor side of therapi should not be transitively passed to projects depending on scijava ops - we only need the side of therapi that looks up the javadoc
This ensures that everyone will be writing proper javadoc whenever proper javadoc will be sufficient for our purposes
Rely on pom-scijava for this
They are not being used by our annotation processors, so there is no reason to keep them.
Doing this allows us to remove the maven compiler plugin conifguration from scijava-ops' POM
This is not needed; pom-scijava-base does this for us
When we move the module-path annotation processors upstream, we want to make as few changes as possible. These options are not necessary, thus we'll remove them
9ddc289 to
7d44ec7
Compare
Because it's not a standard dependency for everything, but it needs to be built first, so that it's available during the javadoc build.
|
I don't see anything else substantial to do on this PR, so I didn't even bother to start a review. My review points from earlier have already been addressed. Thanks! 💯 |
This PR makes the usage of the
@Parameterannotation obsolete; from now on, parameter names and descriptions should be described within the Op's Javadoc. At compile time, the Javadoc will be stored, to be parsed during runtime. As there are 3 different types of Ops, there are 3 different ways to store the parameter data:Ops written as Methods
Intuitively, the
@paramand@returntags can be applied within the Op's javadoc. Note that if only some of the parameters are described, the parser will not be able to determine which parameters correspond to the given tags. In this case the parser will give up and synthesize names (and empty descriptions) for the Op. This means that an Op written aswill correspond to an
OpInfoOps written as Classes
Documentation for Ops written as Classes is written similarly to that of
OpMethods, however the javadoc should be written on the functional method of the Op. For example:This Op will produce an
OpInfo:Ops written as Fields:
Ops written as
Fields require different Javadoc syntax, asFields do not have the@paramand@returntags thatMethods do (and we don't want to misuse them 😅 ). Thus we substitute@paramfor@inputand@returnfor@output:This Op produces an
OpInfo:Ideally, we would write
Taglets for both@inputand@output, however I have not (yet) had success in doing so (as the syntax changed in Java 9). This work may be pursued in a later PR.TODO:
Tagletwork now, or at a later date (so we can get this out of the door). There is some work on anInputTagletin this iteration of the codebase. We should move it to another branch if we decide to wait on it.Notes:
therapi-runtime-javadoc. The version information should probably be moved upstream.