docs

package
v1.43.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package docs provides an HTTP client for interacting with docs.stripe.com. It supports fetching documentation pages, searching, and browsing content with built-in filesystem caching and configurable TTL-based eviction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Get(key string) (data []byte, cachedAt time.Time, ok bool, err error)
	Set(key string, data []byte) error
}

Cache defines the interface for storing and retrieving page content.

type CacheOption

type CacheOption func(*FSCache)

CacheOption configures an FSCache.

func WithClock

func WithClock(now func() time.Time) CacheOption

WithClock overrides the time source used for TTL checks.

func WithFS

func WithFS(fs afero.Fs) CacheOption

WithFS sets the filesystem implementation. Defaults to the real OS filesystem.

func WithTTL

func WithTTL(ttl time.Duration) CacheOption

WithTTL sets the cache entry time-to-live. Defaults to 1 hour.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client fetches documentation pages and calls endpoints on docs.stripe.com.

func NewClient

func NewClient(_ string) *Client

NewClient creates a Client configured to talk to docs.stripe.com.

func (*Client) FetchPage

func (c *Client) FetchPage(ctx context.Context, ref *url.URL) (Page, error)

FetchPage retrieves a documentation page as plain text, using cache when available.

page, err := c.FetchPage(ctx, &url.URL{Path: "/payments/accept-a-payment", RawQuery: "api_version=2024-06-30"})

func (*Client) Search

func (c *Client) Search(ctx context.Context, query string) (*SearchResponse, error)

Search sends the request to docs search endpoint and returns a list of search results.

response, err := c.Search(ctx, "payment methods")

func (*Client) WithOptions

func (c *Client) WithOptions(opts ...ClientOption) *Client

WithOptions applies the given options and returns the Client for chaining.

type ClientOption

type ClientOption func(*Client)

ClientOption configures a Client.

func WithBaseURL

func WithBaseURL(u string) ClientOption

WithBaseURL overrides the default docs.stripe.com base URL.

func WithCache

func WithCache(cache Cache) ClientOption

WithCache enables response caching for FetchPage.

func WithHTTPClient

func WithHTTPClient(hc *http.Client) ClientOption

WithHTTPClient sets a custom http.Client.

func WithLogger

func WithLogger(logger *log.Entry) ClientOption

WithLogger sets a custom logger.

type FSCache

type FSCache struct {
	// contains filtered or unexported fields
}

FSCache implements Cache using the local filesystem with a TTL-based eviction policy. Entries older than the configured TTL are treated as misses and removed on access.

func NewFSCache

func NewFSCache(dir string, opts ...CacheOption) (*FSCache, error)

NewFSCache creates a filesystem-backed cache rooted at dir.

func (*FSCache) Get

func (c *FSCache) Get(key string) ([]byte, time.Time, bool, error)

Get retrieves a cached entry by key, returning the data, cache time, and whether the entry was found. Expired entries are removed on access.

func (*FSCache) Set

func (c *FSCache) Set(key string, data []byte) error

Set writes data to the cache under key.

type Hit

type Hit struct {
	Title string `json:"title"`
	URL   string `json:"url"`
}

Hit represents a single search hit from docs.stripe.com.

type Page

type Page struct {
	// Content is the raw page body returned by docs.stripe.com.
	Content []byte
	// URL is the fully resolved URL including query parameters.
	URL *url.URL
	// FetchedAt is when the content was originally retrieved from docs.stripe.com.
	FetchedAt time.Time
}

Page holds the content and metadata of a fetched documentation page.

type SearchResponse

type SearchResponse struct {
	Hits []Hit
}

SearchResponse represents the response from the docs search endpoint.

Directories

Path Synopsis
Package markdown provides markdown parsing and terminal rendering capabilities.
Package markdown provides markdown parsing and terminal rendering capabilities.
Package pager provides a writer that pipes output through a terminal pager (respecting $PAGER, defaulting to less) when stdout is a TTY.
Package pager provides a writer that pipes output through a terminal pager (respecting $PAGER, defaulting to less) when stdout is a TTY.
Package palette provides a command-palette bubble for Bubble Tea programs.
Package palette provides a command-palette bubble for Bubble Tea programs.
Package spinner provides a simple terminal spinner backed by Bubble Tea.
Package spinner provides a simple terminal spinner backed by Bubble Tea.
Package tui provides a Bubble Tea TUI for browsing Stripe documentation in a scrollable viewport with keyboard and mouse navigation.
Package tui provides a Bubble Tea TUI for browsing Stripe documentation in a scrollable viewport with keyboard and mouse navigation.
Package ui provides shared visual styles and components for the TUI.
Package ui provides shared visual styles and components for the TUI.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL