fs

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fs is the working tree source adapter ("fs"): it walks a directory, or reads one file, and emits each regular file as one chunk. A .ipynb file is emitted as one chunk per notebook cell source and cell outputs (see Source.notebook). It reads plain files only (no archive expansion), skips .git at any depth and never follows symlinks inside the tree; an explicitly named root path is followed.

Inside a git work tree, with git available, it reads what git would commit (tracked files plus untracked files that are not ignored) instead of walking, unless Spec.IncludeIgnored is set.

Index

Constants

View Source
const Name = "fs"

Name is the adapter name.

Variables

View Source
var ErrNoPath = errors.New("fs source: no path")

ErrNoPath is returned for a spec without a path.

Functions

func New

func New(spec source.Spec) (source.Source, error)

New returns the fs source for spec.Path. With spec.FS set, that file system is the target root and spec.Path is only the display name. Otherwise a directory path is the root, and a file path is read alone with its parent directory as the root.

func RepoTarget

func RepoTarget(root string) (model.Target, error)

RepoTarget returns the target the fs source gives the working tree at the directory root, so other sources that read project files report the same repo.

Types

type Source

type Source struct {
	// contains filtered or unexported fields
}

Source walks one directory tree, or reads one file, under a target root.

func (*Source) BinarySkipped

func (s *Source) BinarySkipped() int

BinarySkipped returns how many files were skipped as binary (a NUL byte in the first 8 KiB). It is safe to call while Scan runs.

func (*Source) Name

func (s *Source) Name() string

Name returns the path as given, with forward slashes.

func (*Source) PathPrefix added in v0.3.0

func (s *Source) PathPrefix() string

PathPrefix returns the slash path of the root relative to the enclosing git top level ("" at the top level, outside git or for a Spec.FS tree). Location paths are relative to the root; joining the prefix gives the repository path.

func (*Source) Scan

func (s *Source) Scan(ctx context.Context, emit func(candidate.Chunk) bool, warn func(model.Warning)) error

Scan emits every regular file under the root as one chunk (a notebook as chunks per cell).

func (*Source) Target

func (s *Source) Target() model.Target

Target returns the repo target.

Jump to

Keyboard shortcuts

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