Skip to content

Add pkg.go.dev examples for all public APIs#5

Merged
aretw0 merged 3 commits intomainfrom
copilot/enrich-documentation-examples
Feb 15, 2026
Merged

Add pkg.go.dev examples for all public APIs#5
aretw0 merged 3 commits intomainfrom
copilot/enrich-documentation-examples

Conversation

Copy link
Contributor

Copilot AI commented Feb 15, 2026

The package lacks Go examples for pkg.go.dev, making API discovery and usage patterns unclear compared to sibling projects (lifecycle, loam, procio, trellis).

Changes

Added example_test.go with 11 testable examples covering:

Generic APIs (domain-agnostic)

  • Example() - Basic TypedWatcher usage and state observation
  • ExampleTreeDiagram() - Hierarchical structure visualization
  • ExampleComponentDiagram() - Component relationship diagrams
  • ExampleStateMachineDiagram() - State machine visualization
  • ExampleAggregateWatchers() - Multi-component state aggregation
  • ExampleNewWatcherAdapter() - TypedWatcher → StateSnapshot conversion
  • ExampleAggregateEvents() - Multi-source event aggregation
  • ExampleWithStyles() - Custom Mermaid styling

Legacy APIs (worker/signal domain)

  • ExampleWorkerTreeDiagram() - Worker hierarchy visualization
  • ExampleSignalStateMachine() - Signal handler state machine
  • ExampleSystemDiagram() - Combined signal/worker topology

Example Usage

// Define your domain state
type ServiceState struct {
    Name   string
    Status string
}

// Create a watcher
service := &MyService{state: ServiceState{Name: "API", Status: "Running"}}

// Watch for changes
ctx := context.Background()
changes := service.Watch(ctx)
for change := range changes {
    fmt.Printf("State: %s -> %s\n", change.OldState.Status, change.NewState.Status)
}

All examples are deterministic (pass -race detector) and use minimal, self-contained code. Helper types included for copy-paste usage.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 15, 2026 02:27
Co-authored-by: aretw0 <14055273+aretw0@users.noreply.github.com>
Co-authored-by: aretw0 <14055273+aretw0@users.noreply.github.com>
Copilot AI changed the title [WIP] Add examples to improve Go documentation Add pkg.go.dev examples for all public APIs Feb 15, 2026
Copilot AI requested a review from aretw0 February 15, 2026 02:32
@aretw0 aretw0 marked this pull request as ready for review February 15, 2026 02:39
@aretw0 aretw0 merged commit 69ed9a6 into main Feb 15, 2026
1 check passed
@aretw0 aretw0 deleted the copilot/enrich-documentation-examples branch February 15, 2026 03:06
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.

2 participants