Skip to main content

Crate gdck_config

Crate gdck_config 

Source
Expand description

Configuration for gdck.

Defaults come from the GDScript style guide, so a project with no configuration file at all gets style-guide behaviour.

§Reading a project’s settings

resolve walks up from a directory and returns the settings in force there, along with the files they came from:

let loaded = gdck_config::resolve(std::path::Path::new("."))?;
println!("{} columns", loaded.config.format.line_length);

The nearest gdck.toml wins outright. Failing that, gdtoolkit’s own gdformatrc and gdlintrc are read, so a project already using gdformat and gdlint keeps its line length and its disabled rules without writing anything new. See docs/CONFIG.md for the schema and the precedence.

§Two file formats, two approaches

gdck.toml is read by the toml crate, and validated here for the things a deserialiser cannot know — ranges, and settings that only mean something alongside another.

The gdtoolkit files are read by yaml_serde into an untyped mapping rather than into a struct, because a gdlintrc holds dozens of settings gdck has no equivalent for and each should be skipped with a note rather than failing the file. A file that cannot be parsed at all is an error: none of its settings would apply, and a project formatted by rules it had written down and rejected is the outcome worse than not running.

Modules§

naming
Naming patterns from the style guide’s conventions table.

Structs§

Config
The full configuration for a run.
Error
A configuration file that could not be used.
FormatConfig
Formatting options.
LintConfig
Lint options.
Loaded
Settings, and where they came from.
Note
Something a configuration file asked for that gdck cannot honour.

Enums§

ClassDeclaration
How a file-level class_name and its extends are laid out.
CodeOrderFix
How aggressively gdck fix may reorder class members.
DeclarationGroup
The groups a project may put in an order of its own.
FileNameCase
Which convention the file-name rule holds a file to.
IndentStyle
Indentation style. The style guide mandates tabs; spaces are available because some existing projects have already committed to them.

Constants§

CONFIG_FILE_NAMES
Config file names searched for, in priority order, walking up from the working directory.
DEFAULT_EXCLUDED_DIRS
Directories skipped when collecting .gd files.
GDFORMAT_FILE_NAMES
gdformat’s configuration file, read for compatibility.
GDLINT_FILE_NAMES
gdlint’s configuration file, read for compatibility.

Functions§

discover
Find the nearest gdck.toml, searching start and then each ancestor.
discover_named
Find the nearest file with one of names, searching start and then each ancestor.
load
Read one configuration file, whatever kind it is.
resolve
The settings in force in a directory.