Skip to content

plissken-core::config

Rust

Configuration for plissken projects

pub

Derives: Debug, Clone, Serialize

Configuration warning (non-fatal issue)

Name Type Description
field String The config field that triggered the warning
message String Human-readable warning message
hint Option<String> Optional hint for resolution

pub

fn new(field: impl Into<String>, message: impl Into<String>) -> Self

Create a new warning

Source
pub fn new(field: impl Into<String>, message: impl Into<String>) -> Self {
Self {
field: field.into(),
message: message.into(),
hint: None,
}
}

pub

fn with_hint(mut self, hint: impl Into<String>) -> Self

Add a hint to the warning

Source
pub fn with_hint(mut self, hint: impl Into<String>) -> Self {
self.hint = Some(hint.into());
self
}

pub

Derives: Debug

Result of configuration validation

Name Type Description
valid bool Whether validation passed (no errors)
warnings Vec<ConfigWarning> Validation warnings (non-fatal)

pub

Derives: Debug, Clone, Serialize, Deserialize

Root configuration from plissken.toml

Name Type Description
project ProjectConfig
output OutputConfig
rust Option<RustConfig>
python Option<PythonConfig>
links LinksConfig
quality QualityConfig

pub

fn from_file(path: &std::path::Path) -> crate::error::Result<Self>

Load configuration from a plissken.toml file.

Errors:

Returns PlisskenError::ConfigNotFound if the file doesn’t exist, PlisskenError::ConfigParse if the TOML is invalid.

Source
pub fn from_file(path: &std::path::Path) -> crate::error::Result<Self> {
use crate::error::PlisskenError;
let content = std::fs::read_to_string(path).map_err(|e| {
if e.kind() == std::io::ErrorKind::NotFound {
PlisskenError::ConfigNotFound {
path: path.to_path_buf(),
}
} else {
PlisskenError::Io {
context: format!("failed to read config file '{}'", path.display()),
source: e,
}
}
})?;
let config: Config = toml::from_str(&content).map_err(|e| PlisskenError::ConfigParse {
message: e.to_string(),
source: Some(e),
})?;
Ok(config)
}

pub

fn with_inferred_defaults(mut self, project_root: &Path) -> Self

Apply inferred defaults from manifest files (Cargo.toml, pyproject.toml).

Infers project metadata from existing manifest files and fills in missing configuration values. Explicit configuration always takes precedence over inferred values.

Inferred values

  • project.name - From pyproject.toml [project].name or Cargo.toml [package].name
  • rust.crates - From Cargo.toml [workspace].members or single crate root
  • rust.entry_point - From Cargo.toml [package].name
  • python.package - From pyproject.toml [project].name (with dash-to-underscore)
  • python.source - From pyproject.toml [tool.maturin].python-source

Parameters:

Name Type Description
project_root &Path The directory containing manifest files
Source
pub fn with_inferred_defaults(mut self, project_root: &Path) -> Self {
use crate::manifest::InferredConfig;
let inferred = InferredConfig::from_directory(project_root);
// Fill in project name if empty
if self.project.name.is_empty()
&& let Some(name) = inferred.project_name
{
self.project.name = name;
}
// Fill in Rust config if present but incomplete
if let Some(ref mut rust) = self.rust {
// Fill in crates if empty
if rust.crates.is_empty()
&& let Some(crates) = inferred.rust_crates
{
rust.crates = crates;
}
// Fill in entry_point if not set
if rust.entry_point.is_none() {
rust.entry_point = inferred.rust_entry_point;
}
}
// Fill in Python config if present but incomplete
if let Some(ref mut python) = self.python {
// Fill in package name if empty
if python.package.is_empty()
&& let Some(pkg) = inferred.python_package
{
python.package = pkg;
}
// Fill in source if not set
if python.source.is_none() {
python.source = inferred.python_source;
}
}
self
}

pub

fn validate(
&self,
project_root: &Path,
) -> Result<ValidationResult, ConfigError>

Validate configuration semantically.

Performs validation beyond TOML parsing:

  • At least one language section must be configured
  • version_from source file must exist
  • Configured paths must exist

Returns Ok(ValidationResult) with any warnings if validation passes, or Err(ConfigError) if validation fails.

Parameters:

Name Type Description
project_root &Path The directory containing the plissken.toml file
Source
pub fn validate(&self, project_root: &Path) -> Result<ValidationResult, ConfigError> {
let mut warnings = Vec::new();
// Must have at least one language configured
if self.rust.is_none() && self.python.is_none() {
return Err(ConfigError::NoLanguageConfigured);
}
// Validate version_from source exists
self.validate_version_source(project_root)?;
// Validate Rust configuration
if let Some(ref rust_config) = self.rust {
self.validate_rust_config(rust_config, project_root, &mut warnings)?;
}
// Validate Python configuration
if let Some(ref python_config) = self.python {
self.validate_python_config(python_config, project_root, &mut warnings)?;
}
Ok(ValidationResult {
valid: true,
warnings,
})
}

pub

Derives: Debug, Clone, Serialize, Deserialize

Project metadata

Name Type Description
name String
version_from VersionSource

pub

Derives: Debug, Clone, Serialize, Deserialize

Output configuration

Name Type Description
format String
path PathBuf
template Option<String>

pub

Derives: Debug, Clone, Serialize, Deserialize

Rust source configuration

Name Type Description
crates Vec<PathBuf>
entry_point Option<String>
include_private bool Document items that are not pub (default: only the public API; PyO3 bindings are documented either way)

pub

Derives: Debug, Clone, Serialize, Deserialize

Python source configuration

Name Type Description
package String The Python package name
source Option<PathBuf> Source directory containing Python files (defaults to package name)
auto_discover bool Automatically discover Python modules by walking the filesystem
modules HashMap<String, ModuleSourceType> Explicit module mappings (overrides auto-discovered modules)
include_private bool Document names that start with _ (default: only public names; __dunder__ methods are public)

pub

Derives: Debug, Clone, Serialize, Deserialize, Default

Linking configuration

Name Type Description
dependencies DependencySource
docs_rs_base String

pub

Derives: Debug, Clone, Serialize, Deserialize, Default

Quality/linting configuration

Name Type Description
require_docstrings bool
min_coverage Option<f64>
fail_on_broken_links bool

pub

Configuration validation error

  • NoLanguageConfigured
  • VersionSourceNotFound
  • RustCrateNotFound
  • PythonSourceNotFound
  • GitRepoNotFound

pub

Where to get version information

  • Git
  • Cargo
  • Pyproject

pub

Source type for a Python module

  • Pyo3
  • Python

pub

Where to get dependency versions

  • CargoLock
  • CargoToml
  • None
Name Type Value Description
DEFAULT_OUTPUT_FORMAT &str "markdown" Default output format for documentation
DEFAULT_OUTPUT_PATH &str "docs/api" Default output path for generated documentation
DEFAULT_DOCS_RS_URL &str "https://docs.rs" Default docs.rs base URL for external links
DEFAULT_TEMPLATE &str "mkdocs-material" Default SSG template name
VERSION_SOURCE_CARGO &str "cargo" Version source identifier for Cargo.toml
VERSION_SOURCE_PYPROJECT &str "pyproject" Version source identifier for pyproject.toml
CARGO_MANIFEST &str "Cargo.toml" Cargo manifest filename
PYPROJECT_MANIFEST &str "pyproject.toml" Python project manifest filename
PLISSKEN_CONFIG &str "plissken.toml" Plissken configuration filename
TEMPLATE_MKDOCS_MATERIAL &str "mkdocs-material" MkDocs Material template name
TEMPLATE_MDBOOK &str "mdbook" mdBook template name
TEMPLATE_STARLIGHT &str "starlight" Astro Starlight template name
DEFAULT_STARLIGHT_OUTPUT_PATH &str "docs/src/content/docs/reference/api" Default output path for the Starlight template: a folder of the Starlight content collection
DEFAULT_CRATES &str "." Default crates configuration value