Skip to content

docs(internal): document ProcessBuffer and continuation-state helper invariants #366

Description

@lodyai

Background

Several intricate private state-machine helpers carry no /// documentation,
contrary to the AGENTS.md guidance to comment the why (assumptions, edge
cases, trade-offs):

  • ProcessBuffer methods in src/process.rs:63-161flush, push_verbatim,
    handle_fence_line, handle_table_line.
  • Continuation-state helpers in src/wrap/continuation.rs
    reopen_pending_span (:113), join_pending_continuation (:210),
    suppresses_join_space_after_nested_open_paren (:280),
    unclosed_parenthesis_depth (:292).

Problem

These functions encode non-obvious invariants (fence-width edge cases,
CommonMark soft-break semantics, parenthesis-depth tracking). Without doc
comments stating what each maintains and which edge case it exists for, a future
maintainer must reverse-engineer the intent from the control flow.

Objective

Add a short /// doc comment to each listed function (and method) stating:

  • the invariant it maintains over the shared state, and
  • the specific edge case or rule (e.g. CommonMark soft-break behaviour, fence
    width comparison) that justifies its existence.

Comments must follow the project's en-GB-oxendict spelling convention and
explain why, not restate what the code does.

Acceptance criteria

  • Every function/method listed above has a /// doc comment.
  • make lint/doc gates pass.

References

  • AGENTS.md — "Comment why, not what."
  • Requested by @leynos

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions