api

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Documentation source types
	SourceTypeGoPkgDev = "go.pkg.dev"
	SourceTypeJSR      = "jsr.io"
	SourceTypeNPM      = "npmjs.com"
	SourceTypeCratesIO = "crates.io"
	SourceTypeRubyGems = "rubygems.org"
	SourceTypeGitHub   = "github.com"
	SourceTypeGitLab   = "gitlab.com"
	SourceTypeUnknown  = ""
)

Variables

View Source
var (
	Version       = "0.0.3"
	VersionCommit = ""
)

Version and VersionCommit hold the version information

Functions

func FetchCratesReadme

func FetchCratesReadme(pkgPath string) (string, error)

FetchCratesReadme fetches the README content from crates.io

func FetchDocumentation

func FetchDocumentation(docSource DocSource, forceUpdate bool) (string, error)

FetchDocumentation fetches documentation text for the given package from the specified source

func FetchGitHubReadme

func FetchGitHubReadme(pkgPath string) (string, error)

FetchGitHubReadme fetches the README content from a GitHub repository

func FetchGitLabReadme

func FetchGitLabReadme(pkgPath string) (string, error)

FetchGitLabReadme fetches the README content from a GitLab repository

func FetchNPMReadme

func FetchNPMReadme(pkgPath string) (string, error)

FetchNPMReadme fetches the README content from npm registry

func FetchRubyGemsReadme

func FetchRubyGemsReadme(pkgPath string) (string, error)

FetchRubyGemsReadme fetches the package information from RubyGems API

func GetDocumentationURL

func GetDocumentationURL(docSource DocSource) (*url.URL, error)

GetDocumentationURL returns the URL for viewing the package documentation in a browser. For unsupported sources, it returns the GitHub URL as a fallback.

func GetLanguageAliases

func GetLanguageAliases() map[string]string

GetLanguageAliases returns a map of language aliases to their documentation source types

Types

type DocSource

type DocSource struct {
	// Type represents the documentation source type (e.g., "go.pkg.dev", "npm", "jsr")
	Type string
	// PackagePath represents the processed package path for the documentation source
	PackagePath string
}

DocSource represents a documentation source

func DetectDocSource

func DetectDocSource(pkgPath string, explicitLang string) DocSource

DetectDocSource attempts to detect the documentation source from a package path If explicitLang is provided, it will be used as an explicit language hint

type ErrorCode

type ErrorCode string

ErrorCode defines error types for API operations

const (
	// ErrCratesREADMENotFound represents an error when README is not found
	ErrCratesREADMENotFound ErrorCode = "CratesREADMENotFound"
	// ErrCratesPackageNotFound represents an error when package is not found
	ErrCratesPackageNotFound ErrorCode = "CratesPackageNotFound"
)
const (
	// ErrGHCommandNotFound represents an error when the gh command is not found
	ErrGHCommandNotFound ErrorCode = "GHCommandNotFound"
	// ErrGHCommandFailed represents an error when the gh command fails
	ErrGHCommandFailed ErrorCode = "GHCommandFailed"
	// ErrREADMENotFound represents an error when README is not found
	ErrREADMENotFound ErrorCode = "READMENotFound"
)
const (
	// ErrGLabCommandNotFound represents an error when the glab command is not found
	ErrGLabCommandNotFound ErrorCode = "GLabCommandNotFound"
	// ErrGLabCommandFailed represents an error when the glab command fails
	ErrGLabCommandFailed ErrorCode = "GLabCommandFailed"
)
const (
	// ErrDocumentationFetch represents errors that occur during documentation fetching
	ErrDocumentationFetch ErrorCode = "DocumentationFetchError"
)
const (
	// ErrNPMREADMENotFound represents an error when README is not found
	ErrNPMREADMENotFound ErrorCode = "NPMREADMENotFound"
)
const (
	// ErrRubyGemsREADMENotFound represents an error when README is not found
	ErrRubyGemsREADMENotFound ErrorCode = "RubyGemsREADMENotFound"
)

func (ErrorCode) ErrorCode

func (c ErrorCode) ErrorCode() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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