Skip to content

feat(cli): add hype validate command#103

Merged
corylanou merged 4 commits into
mainfrom
issue-79-feat-cli-add-hype-validate-command-for-document-integrity-ch
Mar 16, 2026
Merged

feat(cli): add hype validate command#103
corylanou merged 4 commits into
mainfrom
issue-79-feat-cli-add-hype-validate-command-for-document-integrity-ch

Conversation

@corylanou

Copy link
Copy Markdown
Member

Summary

  • Add hype validate command that checks document integrity without performing a full export
  • Validates: asset existence (images, source files), heading hierarchy, local anchor links, duplicate figure IDs
  • Supports --exec flag for code execution validation, --format=json for tooling, and non-zero exit codes for CI/CD
  • Core validation logic in validate.go (reusable programmatically), CLI in cmd/hype/cli/validate.go

Fixes #79

Test Plan

  • 8 unit tests for core validation logic covering each check type (missing image, missing source, heading skip, broken anchor, duplicate IDs, valid document, summary format, issue string format)
  • 3 CLI integration tests (clean document, document with errors, JSON output format)
  • All tests pass: go test -run Test_Validate -v github.com/gopherguides/hype github.com/gopherguides/hype/cmd/hype/cli
  • Build verified: go build ./... and go vet clean

Add a validate command that checks document integrity without performing
a full export. Validates assets (images, source files), heading hierarchy,
local anchor links, and duplicate figure IDs. Supports --exec flag for
code execution validation, --format=json for tooling integration, and
returns non-zero exit codes for CI/CD pipelines.

Closes #79

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b24f4f2c49

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cmd/hype/cli/validate.go Outdated
Comment thread validate.go Outdated
- Add <ref> target validation to catch unresolved cross-references
- Fix p.Root to include file subdirectory for correct --exec behavior
- Collect IDs from all elements (not just figures) for anchor validation
- Upgrade duplicate figure IDs from warning to error severity
- Use AttrNode interface to collect IDs from all node types (not just *Element)
- Exclude *Ref nodes from ID collection (ref id is a target, not an anchor)
- Reject unsupported --format values instead of silently falling through
@corylanou
corylanou merged commit 4d3fd33 into main Mar 16, 2026
3 checks passed
@corylanou
corylanou deleted the issue-79-feat-cli-add-hype-validate-command-for-document-integrity-ch branch March 16, 2026 03:57
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.

feat(cli): add hype validate command for document integrity checking

1 participant