source

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	Source Reference

	Contents map[string]string

	// Metadata is metadata retrieved from the source
	Metadata map[string]any

	// BrowserURL is URL that accesible with web browser
	BrowserURL *url.URL

	FetchError error

	// FetchedAt is the time when the data was retrieved
	FetchedAt time.Time

	// RelatedSources are sources related to this data
	RelatedSources []RelatedReference
}

Data is a structure that represents data retrieved from a specific source

type ErrorCode added in v0.0.12

type ErrorCode string

Error codes for repository detection

type Reference

type Reference struct {
	Type Type
	Path string
}

Reference represents a source reference with its type and path

type RelatedReference

type RelatedReference struct {
	// Type represents the source type (e.g., SourceTypeGoPkgDev) or SourceType*
	Type Type

	Path string

	// URL represents the complete URL to the documentation
	URL string

	// From indicates how this source was discovered: "api", or "document"
	From string
}

RelatedReference represents a related documentation source found in content or API responses

func (RelatedReference) ToSourceReference

func (s RelatedReference) ToSourceReference() Reference

type Type

type Type string

Type represents the type of documentation source

const (
	// Documentation source types
	TypeGoPkgDev      Type = "pkg.go.dev"
	TypeJSR           Type = "jsr.io"
	TypeNPM           Type = "npmjs.com"
	TypeCratesIO      Type = "crates.io"
	TypeRubyGems      Type = "rubygems.org"
	TypePyPI          Type = "pypi.org"
	TypePackagist     Type = "packagist.org"
	TypeGitHub        Type = "github.com"
	TypeGitLab        Type = "gitlab.com"
	TypeDocumentation Type = "documentation"
	TypeHomepage      Type = "homepage"
	TypeUnknown       Type = ""
)

func DetectSourceTypeFromURL

func DetectSourceTypeFromURL(url string) Type

detectSourceTypeFromURL detects the source type from a URL

func SourceTypeFromString

func SourceTypeFromString(s string) Type

SourceTypeFromString creates a SourceType from a string

func (Type) ContainRepositoryURL

func (s Type) ContainRepositoryURL() bool

func (Type) IsDocumentation

func (s Type) IsDocumentation() bool

func (Type) IsRegistry

func (s Type) IsRegistry() bool

IsRegistry returns true if the source type is a package registry

func (Type) IsRepository

func (s Type) IsRepository() bool

IsRepository returns true if the source type is a code repository

func (Type) String

func (s Type) String() string

String returns the string representation of the SourceType

Jump to

Keyboard shortcuts

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