feat: markdown translator#87
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
1 issue found across 5 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="internal/translate/markdown/translator_test.go">
<violation number="1" location="internal/translate/markdown/translator_test.go:184">
P2: Incorrect index check: `strings.Index` returns 0 for a match at position 0, but this assertion requires `> 0`. Use `assert.GreaterOrEqual` or check `!= -1` to properly verify the substring was found.</violation>
</file>
Architecture diagram
sequenceDiagram
participant CLI as CLI (cmd/daco)
participant REG as Translator Registry
participant MT as NEW: Markdown Translator
participant RES as NEW: Markdown Resolver
participant CORE as translate.Prepare (Core Lib)
participant TPL as Go Template Engine (markdown.go.tmpl)
Note over CLI, TPL: daco ports translate --format markdown
CLI->>REG: registerTranslators()
REG->>MT: NEW: Register "markdown" implementation
CLI->>MT: Translate(portName, schema)
MT->>CORE: Prepare(portName, schema, resolver)
loop For each Field/Definition
CORE->>RES: NEW: FormatRootName / FormatDefName
RES-->>CORE: PascalCase name
CORE->>RES: NEW: PrimitiveType / ArrayType
RES-->>CORE: Markdown-friendly type string
opt is Reference ($ref)
CORE->>RES: NEW: RefType(defName)
RES-->>CORE: Returns [Name](#Name) anchor link
end
end
CORE-->>MT: Prepared Template Data (hierarchical)
MT->>MT: NEW: formatConstraints(constraints)
Note right of MT: Formats Enum, Min/Max, Pattern, etc.<br/>into comma-separated strings
MT->>TPL: ExecuteTemplate("markdown.go.tmpl", data)
alt Template Success
TPL-->>MT: Generated Markdown Bytes
MT-->>CLI: Return .md content
else Template Error
TPL-->>MT: Error
MT-->>CLI: Return "failed to execute template"
end
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
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.
Add markdown translator for ports
The translator generates a markdown file showing the schema and constraints.
Use:
daco ports translate --format markdown