Skip to content

Generate JavaDoc usage examples in builders + processor model refactor - #229

Merged
AndreasIgel merged 22 commits into
mainfrom
feature/code-example
Aug 3, 2026
Merged

AndreasIgel merged 22 commits into
mainfrom
feature/code-example

Conversation

@AndreasIgel

@AndreasIgel AndreasIgel commented Aug 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Generates JavaDoc usage examples into the generated builder sources. Each generated builder class and each builder method now carries an <h4>Example:</h4> <pre>{@code ...}</pre> block showing a realistic fluent chain (basic setters, String.format overloads, suppliers, consumers, collection helpers), so consumers see copy-pasteable usage directly in their IDE tooltips.

To support this, the processor's internal model was restructured:

  • Split builder/method definitions from generation-specific types: new BuilderMethodDto, CodeTemplateDto, BuilderToGenerationTypeMapper, BuilderNestedTypeDto, and javadoc DTOs (JavadocDto, JavadocCodeBlockDto).
  • Example values are produced by JavadocExampleValues and assembled via MethodGeneratorUtil into per-method and per-class example chains.
  • Example generation is extended to non-default classes too: a target is included when it has a builder or a parameterless constructor.
  • Method-conflict resolution now happens primarily in BuilderDefinitionCreator, with RoasterCodeGenerator only as a fallback.

Changes

  • generators/util/JavadocExampleValues.java, MethodGeneratorUtil.java — example-value synthesis and chain assembly.
  • model/method/{BuilderMethodDto,CodeTemplateDto,MethodCodeDto,MethodDto}.java, model/core/{BuilderDefinitionDto,BuilderToGenerationTypeMapper,GenerationTargetClassDto,...}, model/javadoc/*, model/type/* — model split + mapping to generation types.
  • generators/builder/* and generators/field/* — enhancers/field generators emit example fragments.
  • processing/BuilderDefinitionCreator.java — conflict resolution + example wiring.
  • Tests: new BuilderJavadocExampleTest, expanded ComprehensiveFeatureIntegrationTest, CustomizingDocumentationTest, plus committed example/target/generated-sources/** snapshots showing the produced JavaDoc.

Notes

No public runtime API change; this affects generated JavaDoc and the processor's internal structure.

closes #135

AndreasIgel and others added 13 commits April 23, 2026 23:04
…or that it checks if there is a builder or a parameterless constructor
…method-definition and to map them afterwards to generation specific classes
…initionCreator, only on fallback cases it is in RoasterCodeGenerator
…condition, use imports

Co-Authored-By: Andreas Igel <andreas.igel@computacenter.com>
Resolve PR #229 divergence: adopt main's strict-mode reporting and
per-class rendering-exception isolation alongside the branch's
JavaDoc-example generation and model refactor. Generated example
builders relocated to example/generated-example-builder/ per main.

Co-Authored-By: Andreas Igel <andreas.igel@computacenter.com>
@codecov

codecov Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

…parameterize method-example tests (S5976)

Co-Authored-By: Andreas Igel <andreas.igel@computacenter.com>
devin-ai-integration Bot and others added 8 commits August 2, 2026 21:05
…ple value

Co-Authored-By: Andreas Igel <andreas.igel@computacenter.com>
…els (S1172)

Co-Authored-By: Andreas Igel <andreas.igel@computacenter.com>
Co-Authored-By: Andreas Igel <andreas.igel@computacenter.com>
…tors (CodeQL expose-internal-representation)

Co-Authored-By: Andreas Igel <andreas.igel@computacenter.com>
Co-Authored-By: Andreas Igel <andreas.igel@computacenter.com>
Co-Authored-By: Andreas Igel <andreas.igel@computacenter.com>
…eratorUtil javadoc

Co-Authored-By: Andreas Igel <andreas.igel@computacenter.com>
…de-block list

Co-Authored-By: Andreas Igel <andreas.igel@computacenter.com>
@sonarqubecloud

sonarqubecloud Bot commented Aug 2, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
11.8% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@AndreasIgel
AndreasIgel merged commit 7db0069 into main Aug 3, 2026
7 of 8 checks passed
@AndreasIgel
AndreasIgel deleted the feature/code-example branch August 3, 2026 06:36
AndreasIgel pushed a commit that referenced this pull request Aug 5, 2026
Bring the default-value feature up to date with current main (PR #229
JavaDoc-example generation + model refactor is now merged there).

Conflicts resolved by taking main's version of the JavaDoc-example /
model-refactor code and re-applying the default-value feature on top:
- TrackedValue.valueOr / ifSet(...).orElse(...) fluent default API
- FieldDto default-value field + isRequired()
- CoreMethodsEnhancer applies defaults in build()
- BuilderDefinitionCreator + FieldAnnotationExtractor extract @Default/@DefaultValue
- README Default Values section, example DTOs, DefaultValueTest

Generated example builders regenerated via 'mvn -pl example clean compile'
(CI-consistent, no fmt); BookDtoBuilder is byte-identical to main, only the
new OrderWithDefaultsBuilder/ProductWithDefaultsBuilder are added.

main's strict-mode, resilience and exception-isolation retained.

Co-Authored-By: Andreas Igel <andreas.igel@computacenter.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extending documentation on generated sources

2 participants