Skip to content

Add YAML emission presentation controls #63

Description

Context

YAML 1.2.2 offers multiple presentation styles for the same representation graph. The module currently emits a deterministic subset, while users need more control over scalar quoting, flow/block style, sequence indentation, and JSON-compatible output.

Official YAML 1.2.2 references:

Current State

Emission is deterministic and YAML-compatible, but presentation controls are limited. Strings and mapping keys are emitted double-quoted, collections use block style, and JSON-compatible emission is not exposed as a dedicated mode.

Objective

Expose idiomatic PowerShell controls for YAML presentation while keeping deterministic, safe output and preserving current defaults until a deliberate major-version change.

PowerShell Design Considerations

  • Use validated parameters for style choices instead of switches that can combine into invalid states.
  • Use parameter sets or validation to prevent conflicting presentation modes, especially JSON-compatible output versus YAML-specific style controls.
  • Preserve pipeline behavior where multiple input records become a predictable document shape.
  • Emit rich, classified errors when a requested presentation cannot represent the input graph.

Tasks

  • Add scalar style controls for plain, double-quoted, and single-quoted output.
  • Add collection style controls for block and flow output.
  • Add indentation control for nested block sequences.
  • Add JSON-compatible emission mode with clear incompatibility errors.
  • Preserve deterministic output and idempotent re-emission for each option set.
  • Document PowerShell examples for common pipeline and object scenarios.

Benefits

  • Produces YAML that better matches user and tool expectations.
  • Enables JSON-compatible output from the same value model.
  • Keeps existing automation stable while allowing explicit presentation choices.

Acceptance Criteria

  • Plain scalar emission quotes only when needed to preserve type and content.
  • Double-quoted and single-quoted scalar modes behave predictably for keys and values.
  • Flow-style output parses back to an equal representation graph.
  • JSON mode emits valid JSON or rejects incompatible values with classified errors.
  • Conflicting presentation options are rejected before output is written.

Related

  • Spec folder: spec/Emission-Presentation.md

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions