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 (*Client) FetchPage ¶
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 ¶
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.
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.
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. |