Skip to content

[v0.2.0] Add godoc Example functions for top public APIs #70

Description

@neverDefined

Problem

examples/ was scoped out for v0.1.0, but pkg.go.dev surfaces godoc Example* functions prominently. With zero examples, the package looks bare on its public-facing doc page.

Proposal

Pick the 5 highest-traffic public APIs and add an Example function for each in a new example_test.go file (in the same anvil package, so they have access to internals if needed but consume only the public API):

  1. ExampleNewAnvilBuilder — full builder chain end-to-end.
  2. ExampleAnvil_MineBlock
  3. ExampleAnvil_SetBalance
  4. ExampleAnvil_Snapshot (paired with Revert).
  5. ExampleAnvil_Impersonate

Each example must:

  • Be runnable (go test ./... exercises them).
  • Have an // Output: comment so godoc shows the result.
  • Be short — 10-20 lines max.

Skip: ExampleNewAnvil if it would just duplicate ExampleNewAnvilBuilder.

Acceptance criteria

  • go doc -all . | grep '^func Example' shows the new examples.
  • pkg.go.dev renders them after a tag bump (verify on v0.2.0).
  • Examples compile in CI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:docsREADME, godoc, examples, contributingtype:choreHousekeeping, no user-visible change

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions