Skip to content

Add Sequence documentation - #52

Merged
delacry merged 1 commit into
0.2.xfrom
feature/sequence-docs
Oct 10, 2026
Merged

delacry merged 1 commit into
0.2.xfrom
feature/sequence-docs

Conversation

@delacry

@delacry delacry commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

Documents Sequence, the last remaining item from #23.

New pages

  • Guide (/collection/sequence):
    • creating one with asSequence(), sequenceOf() or generateSequence()
    • eager vs lazy, shown with a call trace
    • when to use a sequence and when not
    • intermediate vs terminal operations, which terminals stop early, onEach() vs forEach(), and memory use
    • what happens on a second pass for each source type, and constrainOnce
    • why there's no sorted()
    • use cases: reading files, paginated APIs, Doctrine cursors, processing in batches
  • API reference (/collection/api/sequence): every method, how much of the
    source each one pulls, and a "Not available on Sequence" table with the
    materialize-first equivalents

Updated pages

  • Getting Started: Sequence in the architecture tree, and an asSequence() tip
    in Transforming
  • Lazy Init, Best Practices (materializing sequences you read twice, constrainOnce),
    Design (new "No Hidden Materialization" section), FAQ (2 entries), Extending
    (SequenceLogic), Cheatsheet, Factory Functions, Map API
  • Homepage: a "Lazy Sequences" tile in place of "Expressive API", a showcase
    section, and Sequence<E> in the hero image
  • README: feature bullet, architecture line, a Sequences section

Search

Searching "lazy collections" used to land on Lazy Initialization. The FAQ now has
"Are there lazy collections, like Laravel's LazyCollection?", and a page can set
searchTitle in its frontmatter to change its title in the search index only (a
small _render hook in config.mts). The Sequence guide is indexed as
"Sequence — Lazy Collections" and is now the first result.

Terminology

The docs no longer use "lazy collection" for lazy initialization. Lazy
initialization defers when a collection is loaded; a sequence changes how a
chain runs. In PHP, "lazy collection" usually means Laravel's LazyCollection,
which is the equivalent of our Sequence.

Also fixed

  • elementAt(), elementAtOrNull() and asSequence() were missing from the
    Collection API page
  • README links pointed to the non-existent /collection/lazy-collections
  • design.md named operation classes that don't exist (SortOperation,
    MapOperation)

Verification

  • Every example and // result comment was run against 0.2.x
  • All 63 Sequence methods are documented, and their signatures match the interface
  • Documented behavior (how much each operation pulls, exceptions, replay rules)
    checked with scripts against the implementation
  • vitepress build passes and all internal links resolve

Checking the examples against the code turned up a bug: distinct() dropped
distinct objects when they were streamed, because a freed object's ID gets
reused. It's fixed in #50, with regression tests in #51.

Reviewing

Most of the content is in docs/collection/sequence.md, the guide; read that one
in full. The API page is reference material that you can skim. The rest are short
additions, plus mechanical "lazy collection" → "lazy initialization" renames.

Closes #23

@codecov

codecov Bot commented Oct 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@nikophil nikophil left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

maybe add "Sequence" to the image?

https://noctud.dev/hero-dark.svg

Comment thread docs/.vitepress/config.mts
Comment thread docs/collection/sequence.md
Comment thread docs/collection/sequence.md Outdated
Comment thread docs/collection/best-practices.md
Comment thread docs/collection/api/sequence.md
@delacry
delacry force-pushed the feature/sequence-docs branch from 60344bb to 6dfea6f Compare October 9, 2026 20:07
@delacry
delacry marked this pull request as ready for review October 9, 2026 20:22
@delacry
delacry requested a review from nikophil October 9, 2026 20:23
@delacry

delacry commented Oct 10, 2026

Copy link
Copy Markdown
Member Author

Thanks for the review and for all the work you did on Sequences! I'm preparing to do last 0.1.x release so it's easier to upgrade to 0.2 when released, but before that I would like to also resolve #49, since it introduces some BC breaks, after that is merged I'll play around with the 0.2.x for a bit to test it all as a whole, and maybe next week I'll tag it.

@delacry
delacry merged commit a82caff into 0.2.x Oct 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants