base

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// WildCardLabel matches any label.
	WildCardLabel = Label(`__wildcard__`)
	// AnonLabel may be used as a label placeholder when a label is needed but not specified.
	AnonLabel = Label(`__anonymous__`)
	// SleepLabel indicates the author wants a sleep after the block in a test context
	// where there is no natural human-caused pause.
	SleepLabel = Label(`sleep`)
)

Variables

This section is empty.

Functions

func ExtractGithubRepoName

func ExtractGithubRepoName(n string) (string, string, error)

ExtractGithubRepoName parses strings like git@github.com:monopole/mdrip.git or https://github.com/monopole/mdrip, extracting the repository name and the path inside the repository.

func SmellsLikeGithubCloneArg

func SmellsLikeGithubCloneArg(arg string) bool

SmellsLikeGithubCloneArg returns true if the argument seems like it could be GitHub url or `git clone` argument.

Types

type BlockBase

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

BlockBase groups OpaqueCode with prose commentary.

func NewBlockBase

func NewBlockBase(p MdProse, c OpaqueCode) BlockBase

NewBlockBase is a ctor.

func (*BlockBase) Code

func (x *BlockBase) Code() OpaqueCode

Code from the block.

func (*BlockBase) Prose

func (x *BlockBase) Prose() MdProse

Prose from the block.

type DataSet

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

DataSet indicates the origin of multiple markdown sources.

func NewDataSet

func NewDataSet(fArgs []string) (*DataSet, error)

NewDataSet makes a dataset from the given args.

func (*DataSet) AsPaths

func (d *DataSet) AsPaths() []FilePath

AsPaths is an array of file paths representing the dataset.

func (*DataSet) FirstArg

func (d *DataSet) FirstArg() *DataSource

FirstArg is, uh, the first member of the dataset - sometimes special.

func (*DataSet) Size

func (d *DataSet) Size() int

Size is the dataset size.

func (*DataSet) String

func (d *DataSet) String() string

String is a string form for the dataset.

type DataSource

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

DataSource is where markdown came from.

func NewDataSource

func NewDataSource(arg string) (*DataSource, error)

NewDataSource ctor.

func (*DataSource) AbsPath

func (d *DataSource) AbsPath() FilePath

AbsPath is the absolute file system path of the datasource.

func (*DataSource) Display

func (d *DataSource) Display() string

Display is a string intended for display.

func (*DataSource) GithubCloneArg

func (d *DataSource) GithubCloneArg() string

GithubCloneArg returns the data source in a form suitable for `git clone`.

func (*DataSource) Href

func (d *DataSource) Href() string

Href returns a browser url compatible form of the datasource.

func (*DataSource) IsGithub

func (d *DataSource) IsGithub() bool

IsGithub is true if the datasource was GitHub.

func (*DataSource) Raw

func (d *DataSource) Raw() string

Raw form of the datasource.

func (*DataSource) RelPath

func (d *DataSource) RelPath() FilePath

RelPath is the relative file system path of the datasource.

func (*DataSource) SetAbsPath

func (d *DataSource) SetAbsPath(arg string)

SetAbsPath changes the path.

type FilePath

type FilePath string

FilePath holds a file path and offers mdrip specific methods on it.

func (FilePath) Base

func (n FilePath) Base() string

Base returns the last part of the file path, e.g. foo in /usr/local/foo.

func (FilePath) IsDesirableDir

func (n FilePath) IsDesirableDir() bool

IsDesirableDir returns true if the directory should be processed.

func (FilePath) IsDesirableFile

func (n FilePath) IsDesirableFile() bool

IsDesirableFile returns true if the filepath seems like markdown.

func (FilePath) IsEmpty

func (n FilePath) IsEmpty() bool

IsEmpty is true if the path is empty

func (FilePath) IsOrderFile

func (n FilePath) IsOrderFile() bool

IsOrderFile returns true if the file appears to be a "reorder" file specifying how to re-order the files in the directory in some fashion other than directory order.

func (FilePath) Join

func (n FilePath) Join(e os.DirEntry) FilePath

Join joins two file name parts using the OS-specific file path joiner.

func (FilePath) Read

func (n FilePath) Read() (string, error)

Read reads the file into a string.

func (FilePath) ReadDir

func (n FilePath) ReadDir() ([]os.DirEntry, error)

ReadDir treats the path as a directory name and reads it.

type Label

type Label string

Label is used to select code blocks, and group them into categories, e.g. run these blocks under test, run these blocks to do setup, etc.

func NoLabels

func NoLabels() []Label

NoLabels is easier to read than the literal empty array.

func (Label) String

func (l Label) String() string

String form of the label.

type MdProse

type MdProse []byte

MdProse is documentation (plain text or markdown) for OpaqueCode.

func NoProse

func NoProse() MdProse

NoProse is placeholder for no prose.

func (MdProse) Bytes

func (x MdProse) Bytes() []byte

Bytes of MdProse.

func (MdProse) String

func (x MdProse) String() string

String form of MdProse.

type OpaqueCode

type OpaqueCode string

OpaqueCode is an opaque, uninterpreted, unknown block of text that is presumably shell commands parsed from markdown. Fed into a shell interpreter, the entire thing either succeeds or fails.

func NoCode

func NoCode() OpaqueCode

NoCode is a constructor for NoCode - easy to search for usage.

func (OpaqueCode) Bytes

func (c OpaqueCode) Bytes() []byte

Bytes of the code.

func (OpaqueCode) String

func (c OpaqueCode) String() string

String form of OpaqueCode.

Jump to

Keyboard shortcuts

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