Documentation
¶
Overview ¶
Package project turns the paths a user names — files, directories and glob patterns — into the model files to load, in a deterministic order.
Index ¶
- Constants
- func Dependencies(files []string, known func(name string) bool) []string
- func DependenciesOf(sources []Source, known func(name string) bool) []string
- func Expand(inputs []string) ([]string, error)
- func IsLoadable(path string) bool
- func IsModelFile(path string) bool
- func IsStdin(path string) bool
- func ModelFiles(dir string) ([]string, error)
- func ReadFile(path string) (string, []byte, error)
- type Source
Constants ¶
const Stdin = "-"
Stdin is the path that names standard input, by the convention that a lone "-" is read from the stream rather than from a file of that name. A file really called "-" is named as "./-".
const StdinName = "<stdin>"
StdinName is what a model read from standard input is called in diagnostics.
Variables ¶
This section is empty.
Functions ¶
func Dependencies ¶
Dependencies returns the model files, beside or below the named ones, that declare a root namespace an import of the named files begins with and none of them declares, then the files those imports lead to in turn. known reports the names another source declares — the standard library's root packages — so an import of one is not searched for. A named file that cannot be read or is standard input contributes nothing; the loader reports the former. The result is ordered as it was found and holds no file already named.
func DependenciesOf ¶ added in v0.10.0
DependenciesOf is Dependencies over sources already read, so a notebook's cells, or a file converted from another notation, are searched from as the model text they load as. Standard input contributes nothing.
func Expand ¶
Expand turns the paths named on a command line (or at a %load prompt) into the sources to load: a directory contributes every model file and notebook under it, a pattern contributes the model files and notebooks among its matches, and any other path is taken as named. Files come back in a deterministic order — the inputs in the order given, each directory walk and each pattern match sorted by path — and duplicates are dropped, so naming a file twice loads it once.
func IsLoadable ¶ added in v0.10.0
IsLoadable reports whether path names a source a load reads: a model file or a notebook, whose code cells are the model.
func IsModelFile ¶
IsModelFile reports whether path names a SysML or KerML model file.
func ModelFiles ¶
ModelFiles walks dir and returns every .sysml/.kerml file and .ipynb notebook under it, sorted by path. Hidden directories are skipped, so a repository's .git or a build cache under a dot-directory contributes nothing. Symlinked directories are walked — a project may keep a shared library as a link — each at most once, so a cycle terminates.