Documentation
¶
Overview ¶
github.go implements GitHub repository sources.
local.go implements local directory sources.
Package source resolves and prepares book content sources. mdpress can read from local directories and GitHub repositories through the Source interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GitHubSource ¶
type GitHubSource struct {
// contains filtered or unexported fields
}
GitHubSource clones content from a GitHub repository.
func NewGitHubSource ¶
func NewGitHubSource(owner, repo string, opts Options) *GitHubSource
NewGitHubSource creates a GitHub source.
func (*GitHubSource) Cleanup ¶
func (s *GitHubSource) Cleanup() error
Cleanup removes the temporary clone directory.
func (*GitHubSource) Prepare ¶
func (s *GitHubSource) Prepare() (string, error)
Prepare clones the GitHub repository into a temporary directory.
func (*GitHubSource) RepoName ¶
func (s *GitHubSource) RepoName() string
RepoName returns the full repository name.
type LocalSource ¶
type LocalSource struct {
// contains filtered or unexported fields
}
LocalSource reads content directly from the local filesystem.
func NewLocalSource ¶
func NewLocalSource(path string, opts Options) *LocalSource
NewLocalSource creates a local source.
func (*LocalSource) Cleanup ¶
func (s *LocalSource) Cleanup() error
Cleanup is a no-op for local sources.
func (*LocalSource) Prepare ¶
func (s *LocalSource) Prepare() (string, error)
Prepare validates the local directory and returns its path.
type Options ¶
type Options struct {
Branch string // Branch override for remote repository sources.
SubDir string // Subdirectory to use inside the source.
}
Options configures source resolution.
type ReadableSource ¶
type ReadableSource interface {
Source
// ReadFile reads a file relative to the source root.
ReadFile(path string) ([]byte, error)
// ListFiles lists files matching a glob pattern relative to the source root.
ListFiles(pattern string) ([]string, error)
// Resolve normalizes a relative path inside the source.
Resolve(base, rel string) string
}
ReadableSource extends Source with file-level access APIs for future use cases.
type Source ¶
type Source interface {
// Prepare returns a local readable directory for the source content.
Prepare() (string, error)
// Cleanup releases temporary resources such as cloned repositories.
Cleanup() error
// Type returns the source type identifier, for example "local" or "github".
Type() string
}
Source is the shared interface implemented by all source providers.