vxml_pipeline

Orchestrates VXML transformation pipelines and file-oriented renderers.

This module owns pipeline execution, monitors, renderer stages, feedback, renderer options, and command-line integration.

Types

Assembles an input path into blamed source lines and optional feedback.

pub type Assembler(assembler_error) =
  fn(String) -> Result(
    #(List(io_lines.InputLine), Feedback),
    assembler_error,
  )

Errors produced by the shared command-line and maintenance workflow.

pub type CLIError {
  CommandLineArgumentError(CommandLineError)
  DotLastCommandReadError(String)
  DotLastCommandDecodeError(String)
  DotLastCommandWriteError(String)
  MaintenanceError(String)
  ClientSideError(String)
}

Constructors

  • CommandLineArgumentError(CommandLineError)
  • DotLastCommandReadError(String)
  • DotLastCommandDecodeError(String)
  • DotLastCommandWriteError(String)
  • MaintenanceError(String)
  • ClientSideError(String)
pub opaque type CommandLineError

Converts one VXML fragment into blamed, indented output lines.

pub type Emitter(fragment_classifier, emitter_error) =
  fn(OutputFragment(fragment_classifier, vxml.VXML)) -> Result(
    #(
      OutputFragment(
        fragment_classifier,
        List(io_lines.OutputLine),
      ),
      Feedback,
    ),
    emitter_error,
  )

Distinguishes an emitter failure from a writer failure for one fragment.

pub type EmitterOrWriterError(emitter_error, writer_error) {
  EmitterError(emitter_error)
  WriterError(writer_error)
}

Constructors

  • EmitterError(emitter_error)
  • WriterError(writer_error)

Optional stage- or monitor-owned feedback.

A stage that has nothing to report returns NoFeedback. Each block in SomeFeedback retains its own margin policy and, in interactive monitor mode, constitutes one independently acknowledged output block.

pub type Feedback {
  NoFeedback
  SomeFeedback(List(FeedbackBlock))
}

Constructors

One independently presented group of feedback lines.

pub type FeedbackBlock {
  FeedbackBlock(lines: List(String), margin: FeedbackMargin)
}

Constructors

Placement of one feedback block in terminal output.

pub type FeedbackMargin {
  AtRunnerMargin
  Verbatim
}

Constructors

  • AtRunnerMargin

    Indent the block to the renderer or pipeline runner’s configured margin.

  • Verbatim

    Print the block exactly as supplied, beginning at column zero.

Filters parsed VXML before the desugaring pipeline runs.

pub type Filterer(filterer_error) =
  fn(vxml.VXML) -> Result(#(vxml.VXML, Feedback), filterer_error)

Metadata retained after a fragment has been written and its payload is no longer needed.

pub type GhostOfOutputFragment(fragment_classifier) {
  GhostOfOutputFragment(
    classifier: fragment_classifier,
    path: String,
  )
}

Constructors

  • GhostOfOutputFragment(
      classifier: fragment_classifier,
      path: String,
    )

A desugaring error annotated with its pipeline step and desugarer.

pub type InSituDesugaringError {
  InSituDesugaringError(
    desugarer: core.Desugarer,
    step_no: Int,
    message: String,
    blame: blame.Blame,
  )
}

Constructors

A desugaring warning annotated with its pipeline step and desugarer.

pub type InSituDesugaringWarning {
  InSituDesugaringWarning(
    desugarer: core.Desugarer,
    step_no: Int,
    message: String,
    blame: blame.Blame,
  )
}

Constructors

An opaque stateful observer run at every pipeline-step boundary.

pub opaque type Monitor

A deferred monitor specification created while parsing command-line arguments.

Factories are resolved against the completed pipeline so that named and relative step selections can be validated before execution.

pub opaque type MonitorFactory

A monitor error annotated with its monitor name and pipeline step.

pub type MonitorFailure {
  MonitorFailure(
    monitor_name: String,
    step_no: Int,
    message: String,
  )
}

Constructors

  • MonitorFailure(
      monitor_name: String,
      step_no: Int,
      message: String,
    )

A path-addressed unit of data moving through splitting, emitting, and writing.

classifier carries application-defined metadata while payload changes type between renderer stages.

pub type OutputFragment(fragment_classifier, payload) {
  OutputFragment(
    classifier: fragment_classifier,
    path: String,
    payload: payload,
  )
}

Constructors

  • OutputFragment(
      classifier: fragment_classifier,
      path: String,
      payload: payload,
    )

Parsed standard VXML Pipeline options and uninterpreted application options.

Values belonging to keys supplied by the application are grouped in user_args; the library does not assign them semantics.

pub type ParsedCLIArguments {
  ParsedCLIArguments(
    help: Bool,
    esoteric: Bool,
    track_help: Bool,
    renumber: Bool,
    generate: Bool,
    desugarers: Bool,
    desugarer_tests: option.Option(List(String)),
    input_dir: option.Option(String),
    output_dir: option.Option(String),
    only_paths: List(String),
    only_key_vals: List(#(String, String)),
    only_path_key_vals: List(#(String, String, String)),
    prettier: option.Option(PrettifierMode),
    tracking_monitor_factory: option.Option(MonitorFactory),
    dump_monitor_factory: option.Option(MonitorFactory),
    vxml_validation_monitor_factory: option.Option(MonitorFactory),
    monitor_interactive_mode: Bool,
    table: option.Option(Bool),
    table_columns: option.Option(
      #(
        option.Option(Int),
        option.Option(Int),
        option.Option(Int),
      ),
    ),
    times: option.Option(
      #(option.Option(Int), option.Option(Int)),
    ),
    verbose: option.Option(Bool),
    artifacts: option.Option(Bool),
    warnings: option.Option(Bool),
    dump_assembled: Bool,
    dump_parsed: Bool,
    dump_filtered: Bool,
    splitter_fragment_path_matches: option.Option(List(String)),
    emitter_fragment_path_matches: option.Option(List(String)),
    user_args: dict.Dict(String, List(String)),
  )
}

Constructors

Parses assembled input lines into one VXML root and optional feedback.

Parser errors carry the blame location at which parsing failed.

pub type Parser(parser_error) =
  fn(List(io_lines.InputLine)) -> Result(
    #(vxml.VXML, Feedback),
    #(blame.Blame, parser_error),
  )

A failure or user cancellation produced while running a pipeline.

pub type PipelineExecutionError {
  PipelineUserExit(UserExit)
  PipelineDesugaringError(InSituDesugaringError)
  PipelineMonitorError(MonitorFailure)
}

Constructors

Describes the boundary between two pipeline steps.

Monitors receive step zero before any desugarer runs and one subsequent context after every completed desugarer. At step zero there is no previous desugarer; after the final step there is no next desugarer.

pub type PipelineStepContext {
  PipelineStepContext(
    step_no: Int,
    previous_desugarer: option.Option(core.Desugarer),
    next_desugarer: option.Option(core.Desugarer),
  )
}

Constructors

Terminal presentation and interaction settings for run_pipeline.

pub type PipelineUXOptions {
  PipelineUXOptions(
    monitor_interactive_mode: Bool,
    report_long_running_desugarers: Bool,
    feedback_margin: Int,
  )
}

Constructors

  • PipelineUXOptions(
      monitor_interactive_mode: Bool,
      report_long_running_desugarers: Bool,
      feedback_margin: Int,
    )

Optionally checks or rewrites one previously written fragment.

Returning None means that the prettifier does not apply to the fragment.

pub type Prettifier(fragment_classifier) =
  fn(
    String,
    GhostOfOutputFragment(fragment_classifier),
    option.Option(String),
  ) -> option.Option(PrettifierFeedback)

Warnings and errors reported by a prettifier invocation.

pub type PrettifierFeedback {
  PrettifierFeedback(
    warnings: List(String),
    errors: List(String),
  )
}

Constructors

  • PrettifierFeedback(warnings: List(String), errors: List(String))

Determines whether and where renderer output is prettified.

pub type PrettifierMode {
  PrettifierOff
  PrettifierOverwriteOutputDir
  PrettifierToBespokeDir(option.Option(String))
}

Constructors

  • PrettifierOff
  • PrettifierOverwriteOutputDir
  • PrettifierToBespokeDir(option.Option(String))

Wires source ingress, parsing, filtering, desugaring, splitting, emitting, writing, and optional prettification.

pub type Renderer(assembler_error, parser_error, filterer_error, splitter_error, emitter_error, writer_error, fragment_classifier) {
  Renderer(
    assembler: fn(String) -> Result(
      #(List(io_lines.InputLine), Feedback),
      assembler_error,
    ),
    parser: fn(List(io_lines.InputLine)) -> Result(
      #(vxml.VXML, Feedback),
      #(blame.Blame, parser_error),
    ),
    filterer: fn(vxml.VXML) -> Result(
      #(vxml.VXML, Feedback),
      filterer_error,
    ),
    pipeline: List(core.Desugarer),
    splitter: fn(vxml.VXML) -> Result(
      #(
        List(OutputFragment(fragment_classifier, vxml.VXML)),
        Feedback,
      ),
      splitter_error,
    ),
    emitter: fn(OutputFragment(fragment_classifier, vxml.VXML)) -> Result(
      #(
        OutputFragment(
          fragment_classifier,
          List(io_lines.OutputLine),
        ),
        Feedback,
      ),
      emitter_error,
    ),
    writer: fn(
      String,
      OutputFragment(fragment_classifier, String),
    ) -> Result(
      #(GhostOfOutputFragment(fragment_classifier), Feedback),
      writer_error,
    ),
    prettifier: fn(
      String,
      GhostOfOutputFragment(fragment_classifier),
      option.Option(String),
    ) -> option.Option(PrettifierFeedback),
  )
}

Constructors

Errors that can stop or partially fail an end-to-end renderer run.

pub type RendererError(assembler_error, parser_error, filterer_error, splitter_error, emitter_error, writer_error) {
  AssemblerError(assembler_error)
  ParserError(blame.Blame, parser_error)
  FiltererError(filterer_error)
  DesugarerNameNotFoundError(String)
  PipelineError(InSituDesugaringError)
  MonitorError(MonitorFailure)
  UserExitError(Int)
  SplitterError(splitter_error)
  EmittingOrWritingErrors(
    List(EmitterOrWriterError(emitter_error, writer_error)),
  )
}

Constructors

  • AssemblerError(assembler_error)
  • ParserError(blame.Blame, parser_error)
  • FiltererError(filterer_error)
  • DesugarerNameNotFoundError(String)
  • PipelineError(InSituDesugaringError)
  • MonitorError(MonitorFailure)
  • UserExitError(Int)
  • SplitterError(splitter_error)
  • EmittingOrWritingErrors(
      List(EmitterOrWriterError(emitter_error, writer_error)),
    )

Optional diagnostics, filtering, monitoring, and presentation behavior for one renderer run.

Begin with vanilla_options and use record update syntax for application defaults. amend_renderer_options_by_arguments can then apply parsed command-line overrides.

pub type RendererOptions(fragment_classifier) {
  RendererOptions(
    verbose: Bool,
    artifacts: Bool,
    steps_table: Bool,
    pipeline_table_default_desugarer_name_columns: Int,
    pipeline_table_default_param_columns: Int,
    pipeline_table_default_outside_columns: Int,
    profiling_table: Bool,
    pipeline_timing_table_default_desugarer_name_columns: Int,
    pipeline_timing_table_default_duration_columns: Int,
    monitor_interactive_mode: Bool,
    warnings: Bool,
    report_long_running_desugarers: Bool,
    only_paths: List(String),
    only_key_vals: List(#(String, String)),
    only_path_key_vals: List(#(String, String, String)),
    monitors: List(Monitor),
    monitor_factories: List(MonitorFactory),
    vxml_table_default_comment_columns: Int,
    vxml_table_default_blame_columns: Int,
    dump_assembled_lines: Bool,
    dump_parsed_vxml: Bool,
    dump_filtered_vxml: Bool,
    dump_splitter_fragments: fn(
      OutputFragment(fragment_classifier, vxml.VXML),
    ) -> Bool,
    dump_emitter_fragments: fn(
      OutputFragment(
        fragment_classifier,
        List(io_lines.OutputLine),
      ),
    ) -> Bool,
  )
}

Constructors

  • RendererOptions(
      verbose: Bool,
      artifacts: Bool,
      steps_table: Bool,
      pipeline_table_default_desugarer_name_columns: Int,
      pipeline_table_default_param_columns: Int,
      pipeline_table_default_outside_columns: Int,
      profiling_table: Bool,
      pipeline_timing_table_default_desugarer_name_columns: Int,
      pipeline_timing_table_default_duration_columns: Int,
      monitor_interactive_mode: Bool,
      warnings: Bool,
      report_long_running_desugarers: Bool,
      only_paths: List(String),
      only_key_vals: List(#(String, String)),
      only_path_key_vals: List(#(String, String, String)),
      monitors: List(Monitor),
      monitor_factories: List(MonitorFactory),
      vxml_table_default_comment_columns: Int,
      vxml_table_default_blame_columns: Int,
      dump_assembled_lines: Bool,
      dump_parsed_vxml: Bool,
      dump_filtered_vxml: Bool,
      dump_splitter_fragments: fn(
        OutputFragment(fragment_classifier, vxml.VXML),
      ) -> Bool,
      dump_emitter_fragments: fn(
        OutputFragment(fragment_classifier, List(io_lines.OutputLine)),
      ) -> Bool,
    )

Required filesystem and prettifier settings for one renderer run.

pub type RendererParameters {
  RendererParameters(
    input_dir: String,
    output_dir: String,
    prettifier_behavior: PrettifierMode,
  )
}

Constructors

  • RendererParameters(
      input_dir: String,
      output_dir: String,
      prettifier_behavior: PrettifierMode,
    )

Splits one transformed VXML root into path-addressed VXML fragments.

pub type Splitter(fragment_classifier, splitter_error) =
  fn(vxml.VXML) -> Result(
    #(
      List(OutputFragment(fragment_classifier, vxml.VXML)),
      Feedback,
    ),
    splitter_error,
  )

Reports that interactive monitor processing was cancelled at step_no.

pub type UserExit {
  UserExit(step_no: Int)
}

Constructors

  • UserExit(step_no: Int)

Writes one rendered string fragment beneath an output directory.

pub type Writer(fragment_classifier, writer_error) =
  fn(String, OutputFragment(fragment_classifier, String)) -> Result(
    #(GhostOfOutputFragment(fragment_classifier), Feedback),
    writer_error,
  )

Values

pub fn advanced_cli_usage(header: String) -> Nil

Prints advanced command-line help followed by header.

pub fn amend_renderer_options_by_arguments(
  options: RendererOptions(fragment_classifier),
  arguments: ParsedCLIArguments,
) -> RendererOptions(fragment_classifier)

Applies parsed diagnostic, filtering, monitoring, and dump arguments to renderer options.

pub fn amend_renderer_parameters_by_arguments(
  parameters: RendererParameters,
  arguments: ParsedCLIArguments,
) -> RendererParameters

Applies parsed input, output, and prettifier arguments to renderer parameters.

pub fn basic_cli_usage(header: String) -> Nil

Prints the ordinary command-line help followed by header.

pub fn cli_error_message(error: CLIError) -> String

Converts a shared command-line error into a user-facing message.

pub fn default_file_assembler(
  path: String,
) -> Result(
  #(List(io_lines.InputLine), Feedback),
  simplifile.FileError,
)

Reads one input file without producing feedback.

pub fn default_filterer(
  vxml: vxml.VXML,
  options: RendererOptions(fragment_classifier),
  saving: List(String),
) -> Result(#(vxml.VXML, Feedback), String)

Applies the path and attribute selectors in RendererOptions.

Tags listed in saving are retained while otherwise-unselected ancestors are reduced around matching content.

pub const default_html_parser: fn(List(io_lines.InputLine)) -> Result(
  #(vxml.VXML, Feedback),
  #(blame.Blame, String),
)

Alias of default_xml_parser for HTML-oriented renderer configurations.

pub fn default_prettier_prettifier(
  output_dir: String,
  ghost: GhostOfOutputFragment(fragment_classifier),
  prettier_dir: option.Option(String),
) -> option.Option(PrettifierFeedback)

Runs Prettier for .html and .tsx fragments.

Without a bespoke destination it checks the written file. With a destination it copies the file there and rewrites that copy, unless the destination resolves to the original output path.

pub fn default_writer(
  output_dir: String,
  fragment: OutputFragment(fragment_classifier, String),
) -> Result(
  #(GhostOfOutputFragment(fragment_classifier), Feedback),
  String,
)

Writes a fragment to output_dir/fragment.path, creating parent directories as needed.

pub fn default_xml_parser(
  lines: List(io_lines.InputLine),
) -> Result(#(vxml.VXML, Feedback), #(blame.Blame, String))

Parses assembled lines as VXML’s XML subset.

pub fn empty_prettifier(
  arg: String,
  arg: GhostOfOutputFragment(fragment_classifier),
  arg: option.Option(String),
) -> option.Option(PrettifierFeedback)

A no-op prettifier that applies to every fragment and reports no messages.

pub fn empty_text_node_monitor() -> Monitor

Builds a monitor that rejects empty VXML text nodes.

Unlike vxml_validation_monitor, this monitor does not validate tags, attributes, or text-line contents.

pub fn handle_help_requests(
  arguments: ParsedCLIArguments,
  local_cli_usage: fn() -> String,
) -> Result(Bool, CLIError)

Print requested help sections.

Each requested help section is printed at most once. local_cli_usage is evaluated and appended only when --help is present.

pub fn handle_maintenance_requests(
  arguments: ParsedCLIArguments,
  local_desugarer_tests: List(
    fn() -> testing.AssertiveTestCollection,
  ),
) -> Result(Bool, CLIError)

Run requested local-desugarer maintenance.

Each operation runs at most once. --desugarers requests blame renumbering, local-library generation, and all local desugarer tests.

pub const help_message_margin: Int

Indentation used by the package’s built-in command-line help text.

pub fn new_monitor(
  name: String,
  state: state,
  update: fn(vxml.VXML, state, PipelineStepContext) -> Result(
    #(state, Feedback),
    String,
  ),
) -> Monitor

Constructs a stateful pipeline monitor.

update is called before the first desugarer and after each completed desugarer. It returns the state for the next call and optional feedback. An error stops pipeline execution and is reported with the monitor name and current step number.

pub fn process_command_line_arguments(
  arguments: List(String),
  user_keys: List(String),
) -> Result(ParsedCLIArguments, CLIError)

Parses standard VXML Pipeline arguments and declared application arguments.

Each string in user_keys declares an application-owned -- option. Its following values are collected in ParsedCLIArguments.user_args until the next option. The library records those values but does not interpret them.

pub fn read_from_dot_last_command(
  arguments: List(String),
) -> Result(List(String), CLIError)

Replace the lone --last-command option with the arguments saved in .last-command. All other argument lists are returned unchanged.

pub fn run_pipeline(
  vxml: vxml.VXML,
  pipeline: List(core.Desugarer),
  monitors: List(Monitor),
  ux_options: PipelineUXOptions,
) -> Result(
  #(
    vxml.VXML,
    List(InSituDesugaringWarning),
    List(duration.Duration),
  ),
  PipelineExecutionError,
)

Runs an ordered VXML transformation pipeline.

Monitors observe the initial VXML at step zero and the result after every desugarer. The returned durations correspond positionally to the supplied pipeline. Terminal interaction and long-running-step reports are controlled by ux_options.

pub fn run_renderer(
  renderer: Renderer(
    assembler_error,
    parser_error,
    filterer_error,
    splitter_error,
    emitter_error,
    writer_error,
    fragment_classifier,
  ),
  parameters: RendererParameters,
  options: RendererOptions(fragment_classifier),
) -> Result(
  List(String),
  RendererError(
    assembler_error,
    parser_error,
    filterer_error,
    splitter_error,
    emitter_error,
    writer_error,
  ),
)

Runs every configured renderer stage and returns the paths written.

The stages run in assembler, parser, filterer, pipeline, splitter, emitter, writer, and optional prettifier order. The function owns a trailing blank line after any renderer output.

pub fn stub_html_emitter(
  fragment: OutputFragment(fragment_classifier, vxml.VXML),
) -> Result(
  #(
    OutputFragment(fragment_classifier, List(io_lines.OutputLine)),
    Feedback,
  ),
  emitter_error,
)

Emits the children of a fragment root inside minimal illustrative HTML boilerplate.

pub fn stub_jsx_emitter(
  fragment: OutputFragment(fragment_classifier, vxml.VXML),
) -> Result(
  #(
    OutputFragment(fragment_classifier, List(io_lines.OutputLine)),
    Feedback,
  ),
  emitter_error,
)

Emits the children of a fragment root inside minimal illustrative JSX component boilerplate.

pub fn stub_splitter(
  suffix: String,
) -> fn(vxml.VXML) -> Result(
  #(List(OutputFragment(Nil, vxml.VXML)), Feedback),
  Nil,
)

Constructs a splitter that emits one fragment.

The fragment path is the root VXML tag followed by suffix; for example, a Book root and ".html" produce "Book.html".

pub fn track_cli_usage(header: String) -> Nil

Prints detailed help for the --track monitor.

pub fn vanilla_options() -> RendererOptions(fragment_classifier)

Returns quiet renderer options with no filtering or explicit monitors.

pub fn vxml_validation_monitor(
  warn_about_leading_attribute_whitespace: Bool,
) -> Monitor

Builds a monitor that validates VXML before and after every pipeline step.

Invalid VXML stops the pipeline. When warn_about_leading_attribute_whitespace is True, the monitor also emits feedback for attribute values with leading whitespace. Leading whitespace is valid VXML and is not otherwise rejected.

pub fn write_to_dot_last_command(
  arguments: List(String),
) -> Result(Nil, CLIError)

Overwrite .last-command with an unambiguous encoding of arguments.

Search Document