add generator to extract javadoc in separate yaml#2788
add generator to extract javadoc in separate yaml#2788christiangoerdes wants to merge 8 commits intomasterfrom
Conversation
📝 WalkthroughWalkthroughAdds a YAML documentation generator and integrates it into the annotation processor; adjusts doc entry sorting to use a priority-based order and related empty-value handling. Changes
Sequence DiagramsequenceDiagram
participant APT as Annotation Processor
participant YDG as YamlDocsGenerator
participant Model as Model
participant Filer as Filer
APT->>YDG: write(model)
YDG->>Model: read namespaces & element docs
Model-->>YDG: return documentation model
YDG->>YDG: build YAML structure (docFormatVersion, schemas...)
YDG->>Filer: createSourceFile("docs.yaml")
alt file exists -> FilerException
Filer-->>YDG: throw FilerException
YDG->>YDG: suppress / no-op on duplicate
else success
Filer->>Filer: write YAML content
Filer-->>YDG: write complete
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
/ok-to-test |
|
This pull request needs "/ok-to-test" from an authorized committer. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In
`@annot/src/main/java/com/predic8/membrane/annot/generator/YamlDocsGenerator.java`:
- Around line 42-45: The catch block in YamlDocsGenerator currently relies on
the exact FilerException message ("Source file already created"), which is
brittle; update the catch(FilerException e) in YamlDocsGenerator to remove the
message.contains check and instead handle the exception unconditionally for the
duplicate-resource case: log a concise note (including the exception) via the
existing logger or processLogger and return/skip further processing, so
legitimate duplicate creation is silently handled while still recording the
exception details for debugging.
- Around line 123-127: writeScalar currently may emit its own trailing newline
for block scalars which causes callers like writeRoot and writeDocBlock to add
an extra blank line; change writeScalar to return a boolean (e.g.,
wroteTrailingNewline) that is true when it already emitted the trailing newline,
and update callers (writeRoot, writeDocBlock) to only call w.write("\n") when
writeScalar returned false. Ensure the new boolean is used wherever writeScalar
is invoked so single-line and multi-line scalars produce exactly one separating
newline.
🧹 Nitpick comments (4)
annot/src/main/java/com/predic8/membrane/annot/model/doc/Doc.java (1)
107-127: Removal of the unknown-tag warning is intentional but worth noting.The old code warned when a Javadoc tag wasn't in the known-positive list. Now any tag not in
NEGATIVEis accepted silently. This is fine if the intent is to allow arbitrary custom tags (e.g.,@yaml), but it means typos in tag names (e.g.,@descrption) will no longer produce a warning.annot/src/main/java/com/predic8/membrane/annot/generator/YamlDocsGenerator.java (3)
181-252: The multi-line block-scalar logic is complex — consider simplifying or adding tests.The indentation-stripping heuristic (lines 195–226) with
firstNonBlank,minAll,minRest, andskipFirstis non-trivial. A couple of observations:
- If every line is blank,
firstNonBlankstays-1andminAllbecomes 0 (line 208). The block scalar then emits only indented blank lines — which is fine, but the|output would yield just whitespace.- The
skipFirstpath (lines 213–226) only activates when the first non-blank line has zero leading spaces while subsequent lines are indented. This re-indents everything except that first line, which is correct for typical Javadoc but hard to follow without comments.Adding a few unit tests for representative inputs (plain single-line, multi-line with varying indentation, all-blank) would help safeguard this logic.
260-278:yamlKey: theYAML_11_RESERVEDguard on~is unreachable.
~doesn't matchSIMPLE_KEY([A-Za-z0-9_]+), so it's already quoted before reaching the reserved-word check. Not a bug — just dead-code noise in the set.
18-291: Hand-rolled YAML emitter — acceptable here, but consider a library if complexity grows.For the current controlled output (no anchors, aliases, flow mappings, etc.) the manual approach works. If the format evolves (e.g., lists, more nesting, user-supplied keys with exotic characters), switching to a lightweight YAML library like SnakeYAML would reduce surface area for formatting bugs.
annot/src/main/java/com/predic8/membrane/annot/generator/YamlDocsGenerator.java
Show resolved
Hide resolved
annot/src/main/java/com/predic8/membrane/annot/generator/YamlDocsGenerator.java
Outdated
Show resolved
Hide resolved
…tion, replacing manual writing logic
Summary by CodeRabbit
New Features
Improvements