Commit a8c4ecf
authored
docs: SDK documentation cleanup and examples fix (#753)
* feat(fn): add --help, --doc, and standalone file mode to AsMain
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>
* chore: apply go fix modernization
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>
* chore: gitignore rapid testdata failure files
Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
* fix: CI drift — use slices.Contains, fix file permissions
- 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>
* fix: use <- All existing tests continue tomdtogo--> as end marker (matches 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>
* fix: skip single-dash flags in file mode arg parsing
Go test runner passes -test.* flags via os.Args. The file mode arg
parser must skip all flag-like arguments (starting with -), not just
those starting with --.
Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
* docs: SDK documentation cleanup and examples fix
- 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>
* docs: address PR review comments for text improvements
Apply text suggestions from mpgreaves review:
- Expand contractions (we'd, you'll, shouldn't, it's, you've, doesn't)
- Add missing periods to sentence fragments
- Improve sentence structure and clarity
- Use more formal phrasing in documentation
Assisted-by: Kiro:Auto [code-editing]
Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
---------
Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>1 parent c3fd4dc commit a8c4ecf
43 files changed
Lines changed: 1069 additions & 2840 deletions
File tree
- docs
- api
- assets
- classes
- interfaces
- go
- fn
- examples
- internal/docs
- get-started
- testdata/noop-passthrough
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | | - | |
| 6 | + | |
6 | 7 | | |
7 | | - | |
| 8 | + | |
8 | 9 | | |
9 | | - | |
| 10 | + | |
10 | 11 | | |
11 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
12 | 53 | | |
13 | | - | |
| 54 | + | |
14 | 55 | | |
15 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
16 | 60 | | |
17 | | - | |
| 61 | + | |
18 | 62 | | |
19 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
20 | 66 | | |
21 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
22 | 91 | | |
23 | 92 | | |
24 | 93 | | |
25 | 94 | | |
26 | 95 | | |
27 | | - | |
28 | 96 | | |
29 | 97 | | |
30 | 98 | | |
31 | 99 | | |
32 | | - | |
| 100 | + | |
33 | 101 | | |
34 | 102 | | |
35 | 103 | | |
36 | 104 | | |
37 | | - | |
| 105 | + | |
38 | 106 | | |
39 | | - | |
| 107 | + | |
40 | 108 | | |
41 | 109 | | |
42 | 110 | | |
43 | | - | |
| 111 | + | |
This file was deleted.
This file was deleted.
This file was deleted.
0 commit comments