nativeview-cli 0.1.0-rc.1

Developer CLI (`nv`) for Native View Engine: dev hot-reload, builds, pairing, SDK management, app scaffolding, and docs.
Documentation
//! Declarative `[docs]` section of `nativeview.toml` (`#[serde(deny_unknown_fields)]`) for
//! `nv docs check|build|dev` site package and content directory defaults.

use serde::Deserialize;

use super::{ManifestError, validate_non_empty_label, validate_rel_path_inner};

/// Validated `[docs]` section of `nativeview.toml`.
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct DocsSection {
    /// Cargo package name exposing the docs site binary (overridden by `--site-package`).
    pub site_package: Option<String>,
    /// Relative path to the docs content directory (overridden by `--content`).
    pub content: Option<String>,
}

#[derive(Debug, Default, Deserialize)]
#[serde(deny_unknown_fields)]
pub(super) struct RawDocsSection {
    site_package: Option<String>,
    content: Option<String>,
}

pub(super) fn parse_docs_section(
    raw: Option<RawDocsSection>,
) -> Result<Option<DocsSection>, ManifestError> {
    let Some(raw) = raw else {
        return Ok(None);
    };
    let site_package = raw
        .site_package
        .as_deref()
        .map(|v| validate_non_empty_label("docs.site_package", v))
        .transpose()?;
    let content = raw
        .content
        .as_deref()
        .map(|v| validate_rel_path_inner("docs.content", v, true))
        .transpose()?;
    Ok(Some(DocsSection {
        site_package,
        content,
    }))
}