-
-
Notifications
You must be signed in to change notification settings - Fork 1k
#2987 Support for defining Javadoc in the generated mapper implementation #3219
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
Merged
filiphr
merged 21 commits into
mapstruct:main
from
jccampanero:2987_support_for_javadoc_in_generated_mapper
May 1, 2023
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
286506a
#2987 Support for Javadoc in generated Mapper initial implementation
jccampanero d420377
Merge branch 'main' into 2987_support_for_javadoc_in_generated_mapper
jccampanero 8652a31
Merge branch 'main' into 2987_support_for_javadoc_in_generated_mapper
jccampanero de28022
Change Javadoc annotation retention policy type
jccampanero baad101
Provide Javadoc documentation for the Javadoc annotation
jccampanero c3fa867
Improve Javadoc Freemarker related templates
jccampanero 0bf3043
Make javadoc instance field final in Mapper.
jccampanero 1c79639
Remove obsolete test reference
jccampanero 1571249
Check that at least one attribute is provided for @Javadoc
jccampanero 702eee5
Add reference to @Javadoc annotation in comments.
jccampanero d4d2184
Provide some comments for Javadoc model.
jccampanero 72b2117
Provide information about AnotationMirror on empty Javadoc annotation.
jccampanero 041c974
Remove trailing characters on JAVADOC_NO_ELEMENTS error message.
jccampanero 57fce09
Add falling test for empty javadoc annotation error.
jccampanero 9896924
Fix reported error line number
jccampanero ecef346
Polishing
filiphr 3e847f6
Minor Javadocs improvements
jccampanero a8664ed
Add Javadoc annotation documentation.
jccampanero 4b832c6
Add fixtures to test Javadoc annotation.
jccampanero 1c13dff
Update documentation/src/main/asciidoc/chapter-3-defining-a-mapper.as…
jccampanero e0aa570
Small javadoc polishing
filiphr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| /* | ||
| * Copyright MapStruct Authors. | ||
| * | ||
| * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
| */ | ||
| package org.mapstruct; | ||
|
|
||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
|
|
||
| /** | ||
| * Allows the definition of Javadoc comments in the MapStruct <code>Mapper</code> generated class. | ||
| * | ||
| * <p>The annotation provides support for the usual Javadoc comments elements by defining analogous attributes.</p> | ||
| * | ||
| * | ||
| * <p>Please, note that at least one of these attributes must be specified.</p> | ||
| * | ||
| * <p> | ||
| * For instance, the following definition; | ||
| * </p> | ||
| * <pre><code class='java'> | ||
| * @Javadoc( | ||
| * value = "This is the description", | ||
| * authors = { "author1", "author2" }, | ||
| * deprecated = "Use {@link OtherMapper} instead", | ||
| * since = "0.1" | ||
| * ) | ||
| * </code></pre> | ||
| * | ||
| * <p> | ||
| * will generate: | ||
| * </p> | ||
| * | ||
| * <pre><code class='java'> | ||
| * /** | ||
| * * This is the description | ||
| * * | ||
| * * @author author1 | ||
| * * @author author2 | ||
| * * | ||
| * * @deprecated Use {@link OtherMapper} instead | ||
| * * @since 0.1 | ||
| * */ | ||
| * </code></pre> | ||
| * | ||
| * <p> | ||
| * The entire Javadoc comment block can be passed directly: | ||
| * </p> | ||
| * <pre><code class='java'> | ||
| * @Javadoc("This is the description\n" | ||
| * + "\n" | ||
| * + "@author author1\n" | ||
| * + "@author author2\n" | ||
| * + "\n" | ||
| * + "@deprecated Use {@link OtherMapper} instead\n" | ||
| * + "@since 0.1\n" | ||
| * ) | ||
| * </code></pre> | ||
| * | ||
| * <pre><code class='java'> | ||
| * // or using Text Blocks | ||
| * @Javadoc( | ||
| * """ | ||
| * This is the description | ||
| * | ||
| * @author author1 | ||
| * @author author2 | ||
| * | ||
| * @deprecated Use {@link OtherMapper} instead | ||
| * @since 0.1 | ||
| * """ | ||
| * ) | ||
| * </code></pre> | ||
| */ | ||
| @Target(ElementType.TYPE) | ||
| @Retention(RetentionPolicy.SOURCE) | ||
| public @interface Javadoc { | ||
| /** | ||
| * Main Javadoc comment text block. | ||
| * | ||
| * @return Main Javadoc comment text block. | ||
| */ | ||
| String value() default ""; | ||
|
|
||
| /** | ||
| * List of authors of the code that it is being documented. | ||
| * <p> | ||
| * It will generate a list of the Javadoc tool comment element <code>@author</code> | ||
| * with the different values and in the order provided. | ||
| * | ||
| * @return array of javadoc authors. | ||
| */ | ||
| String[] authors() default { }; | ||
|
|
||
| /** | ||
| * Specifies that the functionality that is being documented is deprecated. | ||
| * <p> | ||
| * Corresponds to the <code>@deprecated</code> Javadoc tool comment element. | ||
| * | ||
| * @return Deprecation message about the documented functionality | ||
| */ | ||
| String deprecated() default ""; | ||
|
|
||
| /** | ||
| * Specifies the version since the functionality that is being documented is available. | ||
| * <p> | ||
| * Corresponds to the <code>@since</code> Javadoc tool comment element. | ||
| * | ||
| * @return Version since the functionality is available | ||
| */ | ||
| String since() default ""; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
processor/src/main/java/org/mapstruct/ap/internal/model/Javadoc.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| /* | ||
| * Copyright MapStruct Authors. | ||
| * | ||
| * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
| */ | ||
| package org.mapstruct.ap.internal.model; | ||
|
|
||
| import org.mapstruct.ap.internal.model.common.ModelElement; | ||
| import org.mapstruct.ap.internal.model.common.Type; | ||
|
|
||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.Set; | ||
|
|
||
| /** | ||
| * Represents the javadoc information that should be generated for a {@link Mapper}. | ||
| * | ||
| * @author Jose Carlos Campanero Ortiz | ||
| */ | ||
| public class Javadoc extends ModelElement { | ||
|
|
||
| public static class Builder { | ||
|
|
||
| private String value; | ||
| private List<String> authors; | ||
| private String deprecated; | ||
| private String since; | ||
|
|
||
| public Builder value(String value) { | ||
| this.value = value; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder authors(List authors) { | ||
| this.authors = authors; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder deprecated(String deprecated) { | ||
| this.deprecated = deprecated; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder since(String since) { | ||
| this.since = since; | ||
| return this; | ||
| } | ||
|
|
||
| public Javadoc build() { | ||
| return new Javadoc( | ||
| value, | ||
| authors, | ||
| deprecated, | ||
| since | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| private final String value; | ||
| private final List<String> authors; | ||
| private final String deprecated; | ||
| private final String since; | ||
|
|
||
| private Javadoc(String value, List<String> authors, String deprecated, String since) { | ||
| this.value = value; | ||
| this.authors = authors != null ? Collections.unmodifiableList( authors ) : Collections.emptyList(); | ||
| this.deprecated = deprecated; | ||
| this.since = since; | ||
| } | ||
|
|
||
| public String getValue() { | ||
| return value; | ||
| } | ||
|
|
||
| public List<String> getAuthors() { | ||
| return authors; | ||
| } | ||
|
|
||
| public String getDeprecated() { | ||
| return deprecated; | ||
| } | ||
|
|
||
| public String getSince() { | ||
| return since; | ||
| } | ||
|
|
||
| @Override | ||
| public Set<Type> getImportTypes() { | ||
| return Collections.emptySet(); | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.