parser

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package parser

This package provides functions to parse Quadlet files or whole directories.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dropin

type Dropin struct {
	Directory string // Name of directory where dropin put
	FileName  string // Name of the file in dropin directory

	Properties map[string][]QuadletProperty // Content of the file
	SourceFile string                       // Original content of the file
}

Dropin directory to override settings from Quadlet files

type ParseQuadletConfig

type ParseQuadletConfig struct {
	FileName       string // Name of the file (with extenstion) what should be parsed
	RootDirectory  string // Directory where the Quadlet files are located
	CollectDropins bool   // Want to collect dropins information too?
	DirLevel       int    // How deep in the tree dropins shoold searched
}

ParseQuadletConfig Configuration for ParseQuadlet function

type Quadlet

type Quadlet struct {
	Name        string                       // Name of the Quadlet file
	FullPath    string                       // Full path from the root directory
	References  []string                     // Which other Quadlet it reference (e.g.: Network=foo.network)
	PartOf      []string                     // Which other quadlet refer to this Quadlet
	DisabledQSR []string                     // Disabled Quadlet Syntax Rules
	Properties  map[string][]QuadletProperty // Properties for each sections in the file
	Dropins     []Dropin                     // Properties in drop in directories, list in precedence: latest is the effective
	Header      []string                     // The comment lines at the beginning of the file, ignored in dropins
	HeaderHTML  string                       // Converted from markdown to HTML
	SourceFile  string                       // Original content of the file
}

Quadlet Represent a Quadlet file including its dropins

func ParseQuadlet

func ParseQuadlet(c ParseQuadletConfig) (Quadlet, error)

ParseQuadlet This function parse Quadlet file, including its dropins

type QuadletDirectory

type QuadletDirectory struct {
	Quadlets      map[string]Quadlet // Map about Quadlets in the directory
	DisabledQSR   []string           // Globally disabled Quadlet Syntax Rules
	OprhanDropins []Dropin           // Those dropin directories that has no existsing Quadlet
}

QuadletDirectory Represent a directory with Quadlets

func ParseQuadletDir

func ParseQuadletDir(rootDir string, dirLevel int) (QuadletDirectory, error)

ParseQuadletDir List all files in the directory and if found any Quadlet then parse it.

type QuadletProperty

type QuadletProperty struct {
	Property string // Name of the property
	Value    string // Value of the property
}

QuadletProperty Key-value pair in Quadlet file

Jump to

Keyboard shortcuts

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