Repository navigation
Keep Markdown in cleaned comments; add protoc-utils-markdown for shared reference links - #14
Merged
Merged
Conversation
Edge detection treated any leading non-alphanumeric run as frame chrome, so ordinary // comments lost a leading code span backtick or reference-link bracket, shared list markers were stripped from every line, and lines with no alphanumerics (code fences, table rules) were blanked. Comments with no border lines and no column-zero fence are now treated as plain: only their common leading whitespace is removed and every line in the content range is kept. Framed, Holub, and JavaDoc comments keep the existing behavior. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reference-link resolution, failure reporting, and Markdown-to-plain-text conversion were implemented separately in protoc-gen-markdown and protoc-gen-openapi. This module extracts them so both plugins share one implementation: - ReferenceIndex indexes every proto element under every name a comment can use and resolves labels with protoc-gen-markdown's scope rules, mapping elements to a plugin-supplied target type. - ReferenceLinkProcessor is a commonmark LinkProcessor with NONE / WARN / FAIL_ON_INVALID modes, referenceLink URL overrides, and collected failures with a CodeGeneratorResponse-ready summary. - MarkdownText renders documents back to CommonMark and flattens them to plain text or a first sentence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 8, 2026
andrewtburns
approved these changes
Oct 8, 2026
andrewtburns
left a comment
There was a problem hiding this comment.
I did read through each file, and have a good notion of what's going on here.. no obvious errors spotted but kt isn't my finest language
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Two changes that let protoc-gen-markdown and protoc-gen-openapi handle doc-comment Markdown the same way.
Comment cleaning keeps Markdown intact
CommentParser.ParseContexttreated any leading non-alphanumeric run as frame chrome, so cleaning ordinary//comments:[(`entity_type` was…→entity_type` was…),- a/- b→a/b),Comments with no border lines and no column-zero fence are now treated as plain: only their common leading whitespace is removed and every line in the content range is kept.
Framed, Holub, and JavaDoc comments go through the existing path unchanged.
New module:
protoc-utils-markdownA JVM library (depends on the core library, commonmark-java, slf4j-api) extracted from protoc-gen-markdown's private resolver:
ReferenceIndex<T>indexes every message, field, enum, enum value, service, and RPC under every name a comment can use, and resolves labels with protoc-gen-markdown's scope rules. A plugin-supplied function maps each element to its own target type.ReferenceLinkProcessor<T>is a commonmarkLinkProcessorwithNONE/WARN/FAIL_ON_INVALIDmodes,referenceLink=<label>=<URL>overrides, and collected failures with aCodeGeneratorResponse-ready summary.MarkdownTextrenders documents back to CommonMark and flattens them to plain text or a first sentence for fields that can't hold Markdown.The license allowlist gains BSD-2-Clause (commonmark, as in the plugin repos) and slf4j-api, whose MIT license is declared only in its parent POM.
Release
Consumers pin
1.1.0, so this should be released as 1.1.0 (new module + behavior fix):Test plan
./gradlew build— 7 newCommentTestscases (leading code span, leading reference, shared reference prefix, bullet list, indented list, fenced code, table) plus all existing comment fixtures unchanged; 18 new tests for the markdown modulepublishToMavenLocalby all three plugins and the Partner API docs build🤖 Generated with Claude Code