Skip to content

docs: expand prelude documentation#9710

Open
Princetimix69 wants to merge 3 commits into
starkware-libs:mainfrom
Princetimix69:docs/expand-prelude
Open

docs: expand prelude documentation#9710
Princetimix69 wants to merge 3 commits into
starkware-libs:mainfrom
Princetimix69:docs/expand-prelude

Conversation

@Princetimix69

Copy link
Copy Markdown
Contributor

Summary

Expands the prelude documentation by adding a comprehensive list of all items automatically imported from the standard library prelude, organized by category, with usage examples.


Type of change

Please check one:

  • Bug fix (fixes incorrect behavior)
  • New feature
  • Performance improvement
  • Documentation change with concrete technical impact
  • Style, wording, formatting, or typo-only change

Why is this change needed?

The previous prelude documentation was only 10 lines and explained what a prelude is, but did not list which items are actually included. This left users unclear about what types, traits, and functions are automatically available without explicit imports.

For a reference documentation page, listing the complete contents of the prelude is essential information that users need to look up regularly.


What was the behavior or documentation before?

The documentation only contained:

  • A brief definition of what a prelude is
  • Mention that it's based on crate edition (e.g., core::prelude::v2024_07)
  • A note that items like Option and Result are available without imports

It did not list which specific items are included or provide usage examples.


What is the behavior or documentation after?

The expanded documentation now includes:

  1. Complete item listing organized by category:

    • Basic types (bool, felt252, integers, etc.)
    • Collection types (Array, Span, ByteArray, etc.)
    • Option and Result types
    • Common traits (Copy, Clone, Drop, etc.)
    • Arithmetic traits (Add, Sub, Mul, etc.)
    • Other types and traits (Box, Iterator, etc.)
    • Panic functions
  2. Usage examples showing how prelude items work without explicit imports

  3. Explicit imports section explaining that items can still be imported explicitly if desired

  4. Edition-specific preludes explaining the version-based prelude system

All items listed are verified against corelib/src/prelude/v2024_07.cairo.


Related issue or discussion (if any)

This follows the same pattern as PR #9627 (panic documentation expansion), #9626 (integer types), #9612 (boolean types),and #9615 (felt252 type) - expanding thin reference documentation to provide complete,
useful information.


Additional context

This change is important because:

  • The prelude is fundamental to Cairo programming - every Cairo file implicitly uses it
  • Users frequently need to know "what's available by default" vs. "what needs importing"
  • Reference documentation should be comprehensive, not just conceptual
  • Similar documentation in other languages (e.g., Rust) provides complete prelude listings

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

@orizi orizi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@orizi made 3 comments.
Reviewable status: 0 of 1 files reviewed, 3 unresolved discussions (waiting on Princetimix69).


docs/reference/src/components/cairo/modules/language_constructs/pages/prelude.adoc line 12 at r1 (raw file):

which is why you can use types like `Option`, `Result`, and common traits without importing them.

== Items Included in the Prelude

not sure this is actually interesting - just pointing at the files sounds more reasonable.


docs/reference/src/components/cairo/modules/language_constructs/pages/prelude.adoc line 14 at r1 (raw file):

== Items Included in the Prelude

The prelude includes commonly used types, traits, and functions that are essential for Cairo programming.

limit lines to 100 chars.


docs/reference/src/components/cairo/modules/language_constructs/pages/prelude.adoc line 19 at r1 (raw file):

=== Basic Types

* `bool` — Boolean type

finish all sentences with ..

@cursor

cursor Bot commented Jun 3, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
AsciiDoc reference edits only; no compiler, runtime, or API behavior changes.

Overview
Updates the Edition-based Preludes bullets to use consistent AsciiDoc list formatting (leading - and trailing periods on each edition line).

Adds a Prelude Source Files section that points readers to corelib paths (prelude.cairo and the per-edition v2024_07, v2023_10, v2023_01 modules) so they can see the exact exported items instead of duplicating long lists in the reference page.

Reviewed by Cursor Bugbot for commit 2ef8f78. Bugbot is set up for automated code reviews on this repo. Configure here.

@Princetimix69

Copy link
Copy Markdown
Contributor Author

@orizi Done.

@orizi orizi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@orizi made 1 comment and resolved 1 discussion.
Reviewable status: 0 of 1 files reviewed, 3 unresolved discussions (waiting on Princetimix69).


docs/reference/src/components/cairo/modules/language_constructs/pages/prelude.adoc line 25 at r2 (raw file):

Each successive prelude is more conservative, exporting only the most commonly needed items.

== Prelude Source Files

if you do it - make as links - note other instances in the adoc files.

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.

3 participants