Skip to content

docs: SDK documentation cleanup and examples fix#753

Open
efiacor wants to merge 8 commits intokptdev:mainfrom
Nordix:docs/sdk-documentation-cleanup
Open

docs: SDK documentation cleanup and examples fix#753
efiacor wants to merge 8 commits intokptdev:mainfrom
Nordix:docs/sdk-documentation-cleanup

Conversation

@efiacor
Copy link
Copy Markdown
Contributor

@efiacor efiacor commented May 7, 2026

Summary

Documentation overhaul and examples fix for the SDK repository.

Changes

New documentation:

  • docs/tutorial.md — end-to-end function development workflow
  • docs/interfaces.md — Runner vs ResourceListProcessor with code examples
  • docs/testing.md — golden test patterns, WRITE_GOLDEN_OUTPUT, e2e testing pointers
  • docs/containerizing.md — Dockerfile patterns, building, running locally
  • CONTRIBUTING.md — DCO, copyright, code review, AI disclosure (aligned with kpt/catalog)

Removed:

  • Legacy docs/ directory (TypeScript API docs, Jekyll artifacts)

Fixed:

  • go/get-started/ — uses //go:embed + fn.WithDocs, added metadata.yaml
  • go/fn/examples/ — updated go.mod to compile against current SDK
  • Root README.md — rewritten with better flow, accurate descriptions, pkg.go.dev link

Other:

  • Renamed testdata/test1/testdata/noop-passthrough/
  • Updated gcr.io/kpt-fn/ghcr.io/kptdev/krm-functions-catalog/ across all files
  • Added replace directive comments in go.mod files

Dependencies

This PR is based on #752 (feat/asmain-help-doc-filemode) for the fn.WithDocs API.

AI Disclosure

I have used AI in the creation of this PR.

I have used the following AI tools:

  • Kiro for documentation generation, code fixes, and review iteration

efiacor added 8 commits May 7, 2026 13:59
Extend fn.AsMain with functional options to support:
- --help: renders human-readable docs from embedded README markers
- --doc: outputs machine-readable JSON for catalog tooling
- Standalone file mode: accepts positional file args for local debugging

New fn.WithDocs(readme, meta) option registers embedded content.
Existing callers with no options are unaffected (backward-compatible).

Adds internal/docs package with:
- ParseMarkers: extracts mdtogo Short/Long/Examples sections
- ParseMetadata: parses metadata.yaml content
- RenderHelp/RenderDoc: formats output for --help and --doc

Includes property-based tests (rapid) and unit tests for all new code.

Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
Mechanical changes from 'go fix ./...':
- interface{} → any (Go 1.18+ type alias)
- reflect.Ptr → reflect.Pointer (deprecated constant)
- strings.Index+slice → strings.Cut (Go 1.18+ idiom)

Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
- --help now always takes precedence over --doc regardless of arg order
- Updated AsMain doc comment to document all invocation modes
- Removed no-op strings.TrimPrefix in test assertion

Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
- Replace manual loops with slices.Contains for --help/--doc checks
  (matches what 'go fix' produces)
- Change test file permissions from 0644 to 0600 (gosec G306)

Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
…tches catalog READMEs)

The catalog functions use <- All existing tests continue tomdtogo--> (bare) as the section end marker,
not <- All existing tests continue tomdtogo:End-->. Updated the parser and all tests to match the
real-world README format.

Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
- Delete legacy docs/ directory (TypeScript API docs, Jekyll artifacts)
- Add docs/tutorial.md — end-to-end function development workflow
- Add docs/interfaces.md — Runner vs ResourceListProcessor guide
- Add docs/testing.md — golden test patterns with testhelpers
- Add docs/containerizing.md — Dockerfile patterns and local testing
- Add CONTRIBUTING.md aligned with kpt/catalog conventions
- Rewrite README.md with better flow and accurate descriptions
- Fix go/get-started/ to use //go:embed + fn.WithDocs
- Fix go/fn/examples/ go.mod
- Rename testdata/test1/ to testdata/noop-passthrough/
- Update gcr.io/kpt-fn/ references to ghcr.io/kptdev/krm-functions-catalog/
- Add replace directive comments in go.mod files
- Update .gitignore for compiled binary

Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
Copilot AI review requested due to automatic review settings May 7, 2026 22:09
@efiacor efiacor requested a review from CsatariGergely May 7, 2026 22:09
@efiacor efiacor self-assigned this May 7, 2026
@efiacor efiacor added documentation Improvements or additions to documentation go Pull requests that update Go code labels May 7, 2026
Copy link
Copy Markdown

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants