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.
- Format
Config - Formatting options.
- Lint
Config - Lint options.
- Loaded
- Settings, and where they came from.
- Note
- Something a configuration file asked for that
gdckcannot honour.
Enums§
- Class
Declaration - How a file-level
class_nameand itsextendsare laid out. - Code
Order Fix - How aggressively
gdck fixmay reorder class members. - Declaration
Group - The groups a project may put in an order of its own.
- File
Name Case - Which convention the
file-namerule holds a file to. - Indent
Style - 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
.gdfiles. - 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, searchingstartand then each ancestor. - discover_
named - Find the nearest file with one of
names, searchingstartand then each ancestor. - load
- Read one configuration file, whatever kind it is.
- resolve
- The settings in force in a directory.