Documentation
¶
Index ¶
- Constants
- Variables
- func FetchDocumentation(docSource *DocSource, forceUpdate bool) (string, error)
- func GetLanguageAliases() map[string]SourceType
- type DocSource
- func DetectDocSource(pkgPath string, explicitLang string) DocSource
- func FetchCratesReadme(pkgPath string) (string, *DocSource, error)
- func FetchGitHubReadme(pkgPath string) (string, *DocSource, error)
- func FetchGitLabReadme(pkgPath string) (string, *DocSource, error)
- func FetchNPMReadme(pkgPath string) (string, *DocSource, error)
- func FetchPkgGoDevReadme(pkgPath string) (string, *DocSource, error)
- func FetchPyPIReadme(pkgPath string) (string, *DocSource, error)
- func FetchRubyGemsReadme(pkgPath string) (string, *DocSource, error)
- func (docSource DocSource) GetDocument() (*url.URL, error)
- func (docSource DocSource) GetHomepage() (*url.URL, error)
- func (docSource DocSource) GetRegistry() (*url.URL, error)
- func (docSource DocSource) GetRepository() (*url.URL, error)
- func (docSource DocSource) GetURL() *url.URL
- func (docSource DocSource) OtherLinks() ([]RelatedSource, error)
- type DocumentationResult
- type ErrCode
- type ErrorCode
- type GoMetadata
- type RelatedSource
- type RelatedSourceType
- type SourceType
Constants ¶
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" // EnvGLabCommand is the environment variable name for specifying glab command path EnvGLabCommand = "MIRU_GLAB_BIN" // DefaultGLabCommand is the default command name for GitLab CLI DefaultGLabCommand = "glab" )
Variables ¶
var ( Version = "0.0.9" VersionCommit = "" )
Version and VersionCommit hold the version information
Functions ¶
func FetchDocumentation ¶
FetchDocumentation fetches documentation text for the given package from the specified source
func GetLanguageAliases ¶
func GetLanguageAliases() map[string]SourceType
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., "pkg.go.dev", "npm", "jsr")
Type SourceType
// PackagePath represents the processed package path for the documentation source
PackagePath string
// RelatedSources contains links to related documentation sources
RelatedSources []RelatedSource
// Homepage represents the package's homepage URL
Homepage string
}
DocSource represents a documentation source with related sources and homepage
func DetectDocSource ¶
DetectDocSource attempts to detect the documentation source from a package path If explicitLang is provided, it will be used as an explicit language hint
func FetchCratesReadme ¶
FetchCratesReadme fetches the README content from crates.io Returns the content, DocSource with related sources, and any error
func FetchGitHubReadme ¶
FetchGitHubReadme fetches the README content from a GitHub repository Returns the content, DocSource with related sources, and any error
func FetchGitLabReadme ¶
FetchGitLabReadme fetches the README content from a GitLab repository Returns the content, DocSource with related sources, and any error
func FetchNPMReadme ¶
FetchNPMReadme fetches the README content from npm registry Returns the content, DocSource with related sources, and any error
func FetchPkgGoDevReadme ¶ added in v0.0.7
FetchPkgGoDevReadme fetches the README file from pkg.go.dev or the source repository
func FetchPyPIReadme ¶ added in v0.0.9
FetchPyPIReadme fetches the README content from PyPI registry Returns the content, DocSource with related sources, and any error
func FetchRubyGemsReadme ¶
FetchRubyGemsReadme fetches the package information from RubyGems API Returns the formatted documentation and DocSource containing related sources
func (DocSource) GetDocument ¶ added in v0.0.6
func (DocSource) GetHomepage ¶ added in v0.0.6
GetHomepage returns the homepage URL for the package. It first checks RelatedSources for a homepage URL, then falls back to the Homepage field, and finally uses the registry URL as a last resort.
func (DocSource) GetRegistry ¶ added in v0.0.6
GetRegistry returns the package registry URL. It first checks RelatedSources for a registry URL, then generates one based on the source type.
func (DocSource) GetRepository ¶ added in v0.0.6
GetRepository returns the repository URL for the package. It first checks RelatedSources for a repository URL, then generates one from the package path.
func (DocSource) GetURL ¶ added in v0.0.6
GetURL returns the URL for viewing the package documentation in a browser. For unsupported sources, it returns the GitHub URL as a fallback.
func (DocSource) OtherLinks ¶ added in v0.0.6
func (docSource DocSource) OtherLinks() ([]RelatedSource, error)
OtherLinks returns a list of related URLs that are not homepage, repository, or registry URLs.
type DocumentationResult ¶ added in v0.0.6
DocumentationResult represents the result of a documentation fetch operation
type ErrorCode ¶
type ErrorCode string
ErrorCode defines error types for API operations
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" // EnvGHCommand is the environment variable name for specifying gh command path EnvGHCommand = "MIRU_GH_BIN" // DefaultGHCommand is the default command name for GitHub CLI DefaultGHCommand = "gh" )
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 (
ErrPkgGoDevREADMENotFound ErrorCode = "ErrPkgGoDevREADMENotFound"
)
const ( // ErrPyPIREADMENotFound represents an error when README is not found ErrPyPIREADMENotFound ErrorCode = "PyPIREADMENotFound" )
const ( // ErrRubyGemsREADMENotFound represents an error when README is not found ErrRubyGemsREADMENotFound ErrorCode = "RubyGemsREADMENotFound" )
type GoMetadata ¶ added in v0.0.7
type GoMetadata struct {
Repository *url.URL // Repository URL from go-import meta tag
Homepage *url.URL // Homepage URL from go-source meta tag
}
GoMetadata contains metadata extracted from go-import and go-source meta tags
type RelatedSource ¶ added in v0.0.6
type RelatedSource struct {
// Type represents the source type (e.g., SourceTypeGoPkgDev) or RelatedSourceType*
Type RelatedSourceType
// URL represents the complete URL to the documentation
URL string
// From indicates how this source was discovered: "api", or "document"
From string
}
RelatedSource represents a related documentation source found in content or API responses
func ExtractRelatedSources ¶ added in v0.0.6
func ExtractRelatedSources(content, currentPackage string) []RelatedSource
ExtractRelatedSources finds related documentation sources in the given content by matching URLs and package installation commands. It returns a deduplicated list of RelatedSource entries that match the current package.
type RelatedSourceType ¶ added in v0.0.6
type RelatedSourceType string
const ( RelatedSourceTypeDocumentation RelatedSourceType = "documentation" RelatedSourceTypeHomepage RelatedSourceType = "homepage" )
func RelatedSourceTypeFromString ¶ added in v0.0.6
func RelatedSourceTypeFromString(s string) RelatedSourceType
RelatedSourceTypeFromString creates a SourceType from a string
func (RelatedSourceType) String ¶ added in v0.0.6
func (s RelatedSourceType) String() string
String returns the string representation of the RelatedSourceType
type SourceType ¶ added in v0.0.6
type SourceType string
SourceType represents the type of documentation source
const ( // Documentation source types SourceTypeGoPkgDev SourceType = "pkg.go.dev" SourceTypeJSR SourceType = "jsr.io" SourceTypeNPM SourceType = "npmjs.com" SourceTypeCratesIO SourceType = "crates.io" SourceTypeRubyGems SourceType = "rubygems.org" SourceTypePyPI SourceType = "pypi.org" SourceTypeGitHub SourceType = "github.com" SourceTypeGitLab SourceType = "gitlab.com" SourceTypeUnknown SourceType = "" )
func SourceTypeFromString ¶ added in v0.0.6
func SourceTypeFromString(s string) SourceType
SourceTypeFromString creates a SourceType from a string
func (SourceType) ContainRepositoryURL ¶ added in v0.0.6
func (s SourceType) ContainRepositoryURL() bool
func (SourceType) IsDocumentation ¶ added in v0.0.6
func (s SourceType) IsDocumentation() bool
func (SourceType) IsRegistry ¶ added in v0.0.6
func (s SourceType) IsRegistry() bool
IsRegistry returns true if the source type is a package registry
func (SourceType) IsRepository ¶ added in v0.0.6
func (s SourceType) IsRepository() bool
IsRepository returns true if the source type is a code repository
func (SourceType) String ¶ added in v0.0.6
func (s SourceType) String() string
String returns the string representation of the SourceType