diff --git a/.github/workflows/cli.yml b/.github/workflows/cli.yml index 3e54e572..62cff564 100644 --- a/.github/workflows/cli.yml +++ b/.github/workflows/cli.yml @@ -5,12 +5,14 @@ on: branches: [ main, next ] paths: - 'cli/**' + - 'docs/**' - 'examples/**' - '.github/workflows/cli.yml' pull_request: branches: [ main, next ] paths: - 'cli/**' + - 'docs/**' - 'examples/**' - '.github/workflows/cli.yml' workflow_dispatch: @@ -28,6 +30,9 @@ jobs: go-version: '1.25' cache-dependency-path: cli/go.sum + - name: Sync topic docs + run: make sync-docs + - name: Install linters run: make lint-install @@ -50,6 +55,9 @@ jobs: go-version: '1.25' cache-dependency-path: cli/go.sum + - name: Sync topic docs + run: make sync-docs + - name: Download dependencies run: cd cli && go mod download diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index b53c45e8..635b6e34 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -20,6 +20,9 @@ jobs: go-version: '1.24' cache-dependency-path: cli/go.sum + - name: Sync topic docs + run: make sync-docs + - name: Generate coverage working-directory: cli run: go test -coverprofile=coverage.txt -covermode=atomic ./... || true diff --git a/.gitignore b/.gitignore index f1a380a9..0ce1b837 100644 --- a/.gitignore +++ b/.gitignore @@ -54,6 +54,8 @@ dist apps/web/icons coverage.out cli/bin/yapi +cli/internal/docs/topics +docs/commands specs .specify .claude/commands/specify.* diff --git a/Makefile b/Makefile index a250f8ec..8c60a63f 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: build run run-print-analytics test fuzz fmt fmt-check clean install docker web web-run bump-patch bump-minor bump-major release build-all lint lint-install install-lint lint-quick lint-full gen-docs gh-action fuzz-cover local-release +.PHONY: build run run-print-analytics test fuzz fmt fmt-check clean install docker web web-run bump-patch bump-minor bump-major release build-all lint lint-install install-lint lint-quick lint-full gen-docs gh-action fuzz-cover local-release sync-docs NAME := yapi VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev") @@ -45,7 +45,12 @@ lint-full: lint @echo "Running govulncheck..." @cd cli && govulncheck ./... -build: +sync-docs: + @mkdir -p cli/internal/docs/topics + @rm -rf cli/internal/docs/topics/* + @cp docs/topics/*.md cli/internal/docs/topics/ + +build: sync-docs @echo "Building yapi CLI..." @cd cli && go build -ldflags "$(LDFLAGS)" -o ./bin/yapi ./cmd/yapi @codesign --sign - --force ./cli/bin/yapi 2>/dev/null || true diff --git a/apps/web/app/docs/madea.config.tsx b/apps/web/app/docs/madea.config.tsx index e3710eec..febad95b 100644 --- a/apps/web/app/docs/madea.config.tsx +++ b/apps/web/app/docs/madea.config.tsx @@ -11,7 +11,6 @@ import Markdown from "react-markdown"; import remarkGfm from "remark-gfm"; import rehypeHighlight from "rehype-highlight"; import path from "path"; -import fs from "fs"; import { execSync } from "child_process"; // Get version info at build time (uses Vercel env vars, falls back to git for local dev) @@ -117,11 +116,11 @@ function ArticleView({ article }: ArticleViewProps) { } function extractDescription(content: string): string { - // Get the first non-empty line after the title (## heading) + // Get the first non-empty line after the title (# or ## heading) const lines = content.split('\n'); let foundTitle = false; for (const line of lines) { - if (line.startsWith('## ')) { + if (/^#{1,2}\s/.test(line)) { foundTitle = true; continue; } @@ -132,47 +131,69 @@ function extractDescription(content: string): string { return ''; } +function ArticleList({ articles }: { articles: FileInfo[] }) { + return ( +
+ {description} +
+ )} + + ); + })} +- Auto-generated documentation for yapi CLI commands + Guides and command reference for the yapi CLI
No docs yet. Run go run scripts/gendocs.go to generate.
No docs yet. Run make gen-docs to generate command reference.
- {description} -
- )} - - ); - })} +