readme

package
v2.937.11 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileUploadOpPredicate

func FileUploadOpPredicate(
	_ *ast.SDK,
	op *ast.Operation,
) bool

func GenerateTableOfContents

func GenerateTableOfContents(contents string, minLevel, maxLevel int, exclude []string) string

Generates a Table of Contents from a markdown string.

Arguments: - contents: The markdown contents. - minLevel: The minimum heading level to include in the TOC. - maxLevel: The maximum heading level to include in the TOC. - exclude: The list of headers to exclude from the TOC.

Returns: - string: The generated Table of Contents.

func GenerateTableOfContentsEntry

func GenerateTableOfContentsEntry(header string, level, minLevel int, slug *string) string

Generates a Table of Contents entry for a given header.

Arguments: - header: The heading content. - level: The heading level. - slug (optional): The heading slug.

Returns: - string: The TOC entry formatted as "* [header](#slug)".

func GrabDefaultUsageExample

func GrabDefaultUsageExample(s *ast.SDK) *ast.UsageContext

GrabDefaultUsageExample finds the first main usage example.

func IsBlockDisabled

func IsBlockDisabled(prefix, title, id, suffix, contents string) bool

Checks if a block is marked as "No Action", meaning the contents contain:

{prefix} No {title} [{id}] {suffix}

or using the legacy format:

{prefix} No {title} {suffix}.

e.g.

<!-- No SDK Installation [installation] -->
The installation block is marked as "No Action".
It is disabled and should not get updated.

Arguments: - prefix: The block boundary prefix, e.g. `<!--`. - title: The block title (used in "legacy mode" only). - id: The block ID. - suffix: The block boundary suffix, e.g. `-->`. - contents: The README markdown contents.

Returns: - bool: True if the block is marked as "No Action", false otherwise.

func OperationsForUsageSnippets

func OperationsForUsageSnippets(
	s *ast.SDK,
	operationIds []string,
	namespace string,
	rootExample bool,
	all bool,
	exampleRequestBodyJSON string,
	paramToExampleValues map[string]string,
) ([]ast.UsageContext, error)

OperationsForUsageSnippets returns usage example operations that match any of the given criteria.

The operationId will select any operation with a matching operationId as an example.

The namespace will select all operations within a given namespace.

The rootExample will select the first main usage example.

The all flag will select all available usage examples, overriding the operationId and namespace parameters.

func ParseBlockIDs

func ParseBlockIDs(prefix, suffix, contents string) string

Retrieves section IDs from all Start block boundaries found inside the README.

Arguments: - prefix: The block boundary prefix, e.g. `<!--`. - suffix: The block boundary suffix, e.g. `-->`. - contents: The README markdown contents.

Returns: - string: A comma-separated list of all section IDs found.

func ParseBlockWithID

func ParseBlockWithID(prefix, id, suffix, contents string) string

Retrieves the content of the block associated with a given ID.

Arguments: - prefix: The block boundary prefix, e.g. `<!--`. - id: The ID of the block to be parsed. - suffix: The block boundary suffix, e.g. `-->`. - contents: The README markdown contents.

Returns: - string: The content of the block associated with the specified ID.

func ReplaceBlock

func ReplaceBlock(prefix, title, id, suffix, contents, newTitle, newContents string) (string, bool)

Replaces the content inside a block

Arguments: - prefix: The block boundary prefix, e.g. `<!--`. - title: The block title (used in "legacy mode" only). - id: The block ID. - suffix: The block boundary suffix, e.g. `-->`. - contents: The README markdown contents. - newTitle: The title that should be placed in the block boundary. - newContents: The new content that should be placed inside the block.

Returns: - string: The updated readme with the block contents replaced.

func SelectExampleOperations

func SelectExampleOperations(
	sdk *ast.SDK,
	scopes []ast.UsageExampleScope,
	limit int,
	isMainExample bool,
	shouldIncludeServerSelection bool,
) []ast.UsageContext

SelectExampleOperations first collects a pool of "possible" usage examples that satisfy all of the requirements associated with the `OpFilter` tags passed inside `scopes` (see getOperationPredicate for more details). If `scopes` is an empty slice, all available usage examples will be collected.

Then, we look for "preferred" usage examples by checking the tags registered under the `x-speakeasy-usage-example` extension. An operation is considered preferred if it contains all the `OpFilter` tags passed inside `scopes`. If scopes is an empty slice, examples tagged as `usage` as well as all *untagged* examples will be grabbed instead.

The limit parameter indicates that searching should stop after at least `limit` preferred examples have been found and caps the amount of usage examples returned. If not enough preferred examples were found compared to the given limit, additional operations will be picked from the pool of possible usage examples to try and reach the limit.

Limit has a couple special values:

  • if limit is set to -1, all *possible* examples will be returned.
  • if limit is set to 0, all *preferred* examples will be returned. If none are found (e.g. the x-speakeasy-usage-example extension hasn't been used at all), then *one* of the possible usage examples will be returned.

Types

This section is empty.

Jump to

Keyboard shortcuts

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