Skip to content

Comments

feat: add --mintlify flag to kosli docs command#663

Merged
dangrondahl merged 5 commits intomainfrom
662-add---mintlify-flag-to-kosli-docs-command
Feb 23, 2026
Merged

feat: add --mintlify flag to kosli docs command#663
dangrondahl merged 5 commits intomainfrom
662-add---mintlify-flag-to-kosli-docs-command

Conversation

@dangrondahl
Copy link
Contributor

Summary

  • Adds --mintlify flag to kosli docs command to generate Mintlify-compatible MDX documentation directly from the CLI
  • Introduces new internal/docgen package with a Formatter interface, implemented by HugoFormatter (existing behavior) and MintlifyFormatter (new)
  • Converts bare https://docs.kosli.com/path URLs in flag descriptions to clickable [docs](/path) markdown links in Mintlify output
  • Hugo output remains unchanged (backward compatible)

Details

New package internal/docgen/ extracts doc generation logic from cmd/kosli/docs.go into a clean architecture:

  • Formatter interface with Hugo and Mintlify implementations
  • CommandMetaFunc callback bridges cmd/kosli (isBeta/isDeprecated) with docgen
  • LiveDocProvider interface abstracts HTTP calls for live doc examples
  • Shared helpers (CommandsInTable, RenderFlagsTables, etc.) moved from cmd/kosli

Mintlify-specific features:

  • Front matter uses description: (sanitized, truncated) instead of summary:
  • <Warning>, <Tabs>/<Tab>, <AccordionGroup>/<Accordion> components instead of Hugo shortcodes
  • JSX escaping for {expr} and <WORD> patterns outside code fences
  • No h1 title (Mintlify renders from front matter)
  • Relative doc URLs converted to clickable markdown links

Test plan

  • go test ./internal/docgen/... — all new unit tests pass
  • go test ./cmd/kosli/... -run TestDocsCommandTestSuite — Hugo golden file unchanged
  • Mintlify golden file tests for snyk and deprecated artifact commands
  • Generated full CLI reference (92 pages) and verified in Mintlify docs repo
  • Compared Hugo output against existing docs.kosli.com content (identical except machine-local paths)

Closes #662

Introduce internal/docgen package with a Formatter interface and two
implementations (HugoFormatter, MintlifyFormatter) so the CLI can
directly generate Mintlify-compatible MDX documentation.

- Extract doc rendering logic from cmd/kosli/docs.go into docgen
- Add MintlifyFormatter with <Warning>, <Tabs>/<Tab>,
  <AccordionGroup>/<Accordion> components, JSX escaping, and
  relative URLs
- Move CommandsInTable and helpers to docgen/helpers.go
- Add GenMarkdownTree tree walker using Formatter + callbacks
- Wire --mintlify flag in docsOptions to select formatter
- Add golden file tests for both Mintlify snyk and artifact pages
- Existing Hugo golden file test unchanged (no regression)
Move Hugo golden files from testdata/output/docs/ to
testdata/output/docs/hugo/ for symmetry with mintlify/.
Hugo golden file content is unchanged.

Add Mintlify golden file comparison tests for snyk and deprecated
artifact commands. Update Hugo test golden path only.
Mintlify renders the front matter title as h1 automatically, so
the generated docs should not include a duplicate # heading.

Add Title() method to Formatter interface — Hugo emits # name,
Mintlify returns empty string. Pages now start with ## Synopsis.
Replace bare https://docs.kosli.com/path URLs in Mintlify output
with markdown links [docs](/path) so they are clickable both
locally (mint dev) and when deployed.

Applies to flag descriptions and synopsis text.
@dangrondahl dangrondahl linked an issue Feb 22, 2026 that may be closed by this pull request
@dangrondahl dangrondahl marked this pull request as draft February 22, 2026 14:16
@dangrondahl
Copy link
Contributor Author

Tests

Current Hugo docs

I have tested and compared the creation of Hugo CLI docs. By first running make cli-doc on main and then

mkdir tmp
DOCS=true go run ./cmd/kosli docs --dir tmp

On the feature branch. All files are identical

Mintlify

In the docs repo I ran:

DOCS=true go run <path to cli repo>/cmd/kosli docs --dir mintlify --mintlify

on a path that was covered by docs.json

All files looks correct.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds a --mintlify flag to the kosli docs command to generate Mintlify-compatible MDX documentation alongside the existing Hugo markdown format. The implementation introduces a new internal/docgen package that extracts and refactors the documentation generation logic into a clean, interface-based architecture.

Changes:

  • Introduces internal/docgen package with Formatter interface implemented by HugoFormatter and MintlifyFormatter
  • Converts bare https://docs.kosli.com/path URLs in flag descriptions to clickable markdown links in Mintlify output
  • Refactors existing Hugo documentation generation to use the new architecture while maintaining backward compatibility

Reviewed changes

Copilot reviewed 15 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/docgen/formatter.go Defines Formatter interface and related types (CommandMeta, CIExample, LiveDocProvider)
internal/docgen/hugo.go Hugo formatter implementation (extracted from cmd/kosli/docs.go)
internal/docgen/mintlify.go New Mintlify formatter with MDX components and JSX escaping
internal/docgen/helpers.go Shared helper functions (CommandsInTable, HashTitledExamples, etc.) moved from cmd/kosli
internal/docgen/generate.go Main generation logic using the Formatter interface
internal/docgen/*_test.go Comprehensive unit tests for formatters and helpers
cmd/kosli/docs.go Refactored to use internal/docgen package with new --mintlify flag
cmd/kosli/docs_test.go Updated tests with new golden file paths and Mintlify test cases
cmd/kosli/testdata/output/docs/hugo/* Hugo golden files for testing (relocated from previous path)
cmd/kosli/testdata/output/docs/mintlify/* New Mintlify golden files for testing
cmd/kosli/printCommandsInTable.go Removed (functionality moved to internal/docgen/helpers.go with modernization)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dangrondahl dangrondahl marked this pull request as ready for review February 23, 2026 08:17
@dangrondahl dangrondahl merged commit 9636869 into main Feb 23, 2026
10 checks passed
@dangrondahl dangrondahl deleted the 662-add---mintlify-flag-to-kosli-docs-command branch February 23, 2026 08:32
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.

Add --mintlify flag to kosli docs command

2 participants