Skip to content

Conversation

@majiayu000
Copy link

Summary

This PR fixes #859

Changes

  • Added GitHub workflow to automatically generate CLI reference documentation when changes are made to cmd/notation
  • Created cmd/notation/doc.go with gendoc build tag for documentation generation using cobra/doc
  • Refactored cmd/notation/main.go to use !gendoc build tag and export NewRootCommand() function for reuse
  • Created cmd/notation/root.go containing the NewRootCommand() function that initializes the root cobra command
  • Added Makefile target cli-docs for manual CLI documentation generation
  • Updated .gitignore to exclude generated docs/cli/ directory
  • Updated dependencies to include github.com/spf13/cobra/doc for markdown generation

The workflow automatically creates a pull request when CLI commands change, similar to the minder project workflow referenced in the issue.

Testing

  • All unit tests pass
  • Build succeeds
  • Manual CLI docs generation works with make cli-docs
  • Generated markdown files are properly formatted

Generated with Claude Code

- Add GitHub workflow to auto-generate CLI docs when cmd/notation changes
- Create doc.go with build tag for documentation generation
- Refactor main.go to export NewRootCommand function
- Add Makefile target 'cli-docs' for manual doc generation
- Add docs/cli/ to .gitignore

Implements auto-generation of CLI reference documentation similar to the
minder project workflow. Documentation is generated using cobra/doc and
creates markdown files for all CLI commands.

Fixes notaryproject#859

Signed-off-by: majiayu000 <1835304752@qq.com>
Copy link

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 PR implements automatic generation of CLI reference documentation for the notation project. The implementation uses build tags to separate the documentation generation logic from the main CLI binary, and adds a GitHub Actions workflow that automatically creates pull requests when CLI commands are modified.

Key changes:

  • Added GitHub workflow to auto-generate CLI documentation on changes to cmd/notation
  • Introduced build tag separation (gendoc vs !gendoc) to enable dual-purpose main package usage
  • Refactored root command initialization into a reusable NewRootCommand() function
  • Updated dependencies to include cobra/doc for markdown generation

Reviewed changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
.github/workflows/update-docs-cli.yml New workflow that triggers on cmd/notation changes and creates PRs with updated CLI docs
cmd/notation/doc.go Documentation generation entry point using gendoc build tag
cmd/notation/main.go Simplified to use NewRootCommand() with !gendoc build tag
cmd/notation/root.go Extracted root command initialization logic for reuse
Makefile Added cli-docs target for manual documentation generation
.gitignore Excluded generated docs/cli directory from version control
go.mod Updated cobra and pflag versions, added new indirect dependencies
go.sum Updated checksums for new and upgraded dependencies

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

github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/veraison/go-cose v1.3.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

The import path go.yaml.in/yaml/v3 is incorrect. The correct import path for yaml.v3 is gopkg.in/yaml.v3. This appears to be introduced as an indirect dependency. Running go mod tidy should correct this to use the proper import path.

Suggested change
go.yaml.in/yaml/v3 v3.0.4 // indirect
gopkg.in/yaml.v3 v3.0.4 // indirect

Copilot uses AI. Check for mistakes.
go-version-file: 'go.mod'
check-latest: true

- name: Generate CLI documentation
Copy link
Member

Choose a reason for hiding this comment

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

Where will the CLI reference doc to be generated? From the cmd/notation/doc.go, will the doc be generated in a new folder created in the notation repo?

Copy link
Member

@FeynmanZhou FeynmanZhou left a comment

Choose a reason for hiding this comment

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

Thanks @majiayu000 .

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.

Support auto-generated CLI reference doc in the notation repo

2 participants