Documentation ¶
Overview ¶
File code.go contains helpers to parse, or generate code for different languages.
File parser.go contains high level functions for: parsing a source file or a folder with source files, and converting a source file to scripts, or a folder with source files to scripts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var CodeBlocks = map[string]CodeType{
"js": {"Javascript", "node", "//"},
"mjs": {"Javascript", "node", "//"},
"py": {"Python", "python3", "#"},
"sh": {"Bash", "bash", "#"},
"zsh": {"ZSH", "zsh", "#"},
}
All known code block types
Functions ¶
func ConvertFolder ¶
ConvertFolder finds all candidate code-files from a folder, and generates source code. The original text files are not changed.
func ParseBlocks ¶
ParseBlocks extracts all code blocks from text The result will be in the form: {language => content}
Types ¶
type CodeFile ¶
type CodeFile struct { FrontMatter Path string Ctime time.Time Mtime time.Time Blocks map[string]string }
func ParseFile ¶
ParseFile accepts a candidate code-file and returns a structure. The structure contains ID, Path, Creation time and a list of blocks of code. If the file can't be accessed or parsed, the returned structure will be incomplete.
func ParseFolder ¶
ParseFolder finds all candidate code-files from a folder, and extracts useful info about them.
type FrontMatter ¶
type FrontMatter struct { Enabled bool `yaml:"spinal" json:"spinal"` ID string `yaml:"id" json:"id"` Db bool `yaml:"db,omitempty" json:"db,omitempty"` Log bool `yaml:"log,omitempty" json:"log,omitempty"` Cwd string `yaml:"cwd,omitempty" json:"cwd,omitempty"` Env []string `yaml:"env,omitempty" json:"env,omitempty"` DelayStart uint `yaml:"delayStart,omitempty" json:"delayStart,omitempty"` RetryTimes uint `yaml:"retryTimes,omitempty" json:"retryTimes,omitempty"` Meta MetaData `yaml:"meta" json:"meta"` }
type StringToString ¶
StringToString is a helper map
func ConvertFile ¶
func ConvertFile(codFile CodeFile, force bool) (StringToString, error)
ConvertFile generates 1 or more code files, from one code file. Force=true will convert a file without checking the header.