Skip to content

docs: improve Python SDK API reference with field descriptions and fix doc generator#1312

Open
ytallo wants to merge 2 commits intomainfrom
docs/python-sdk-griffe
Open

docs: improve Python SDK API reference with field descriptions and fix doc generator#1312
ytallo wants to merge 2 commits intomainfrom
docs/python-sdk-griffe

Conversation

@ytallo
Copy link
Contributor

@ytallo ytallo commented Mar 15, 2026

Summary

Improves the auto-generated Python SDK API reference (sdk-python.mdx) by adding field-level descriptions to all public types and fixing the doc generator to extract them.

Before: 34 type fields showed "-" (no description) in the API reference tables.
After: 1 remaining (a method param, not a type field).

Changes

Python SDK docstrings (iii.py, iii_types.py, iii_constants.py)

  • Added Attributes: section (Google-style) to 13 Pydantic model docstrings — griffe extracts these for the API reference
  • Improved 7 method docstrings: register_function, trigger, create_channel, on_functions_available, register_trigger, register_trigger_type, register_service
  • Cleaned up register_function example (removed mixed prose/code)

Doc generator (parse-griffe.mts)

  • extractAttributeDescriptions() — new function that parses Attributes: sections from class docstrings as fallback when griffe doesn't populate individual field docs
  • register_worker alias resolution — resolves from iii.iii submodule when the root-level re-export has no metadata
  • extractDocstring() — now strips all Google-style sections (Returns:, Raises:, Note:, etc.) from descriptions
  • extractExamples() — better cleanup of >>> / ... doctest prefixes
  • Import example — updated from from iii import III, register_worker to from iii import register_worker, InitOptions

Generated output (sdk-python.mdx)

  • Initialization section now shows register_worker with description and example
  • All type tables populated with field descriptions
  • Logger section with all 4 methods documented
  • Clean code examples without doctest artifacts

Test plan

  • cd sdk/packages/python/iii && uv run pytest tests/ -x — verify no regressions
  • cd sdk/packages/python/iii && uv run griffe dump iii -d google 2>/dev/null > api-docs.json && cd ../../docs && pnpm tsx scripts/generate-api-docs.mts — regenerate and verify output
  • Review rendered sdk-python.mdx in docs preview

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced register_worker as the new primary entry point for Python and Rust SDK initialization
    • Added InitOptions configuration object for customizable worker setup
    • New telemetry and reconnection configuration options for enhanced observability
  • Documentation

    • Expanded API reference with comprehensive field descriptions
    • Enhanced method documentation and examples across Python and Rust SDKs
    • Updated initialization examples to reflect current best practices

ytallo added 2 commits March 14, 2026 21:34
…cumentation

- Refactored SDK initialization to use `register_worker` across examples.
- Updated method signatures and documentation for clarity and consistency.
- Enhanced docstrings with attribute descriptions for better understanding.
- Improved example formatting in documentation for better readability.
- Eliminated references to the async `greet_async` function in both the documentation and code examples for clarity.
- Streamlined the `greet` function example by removing unnecessary lines, enhancing readability.
@vercel
Copy link
Contributor

vercel bot commented Mar 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
iii-docs Ready Ready Preview, Comment Mar 15, 2026 1:07am
iii-website Ready Ready Preview, Comment Mar 15, 2026 1:07am
motia-docs Ready Ready Preview, Comment Mar 15, 2026 1:07am

Request Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 15, 2026

📝 Walkthrough

Walkthrough

This PR updates documentation, type definitions, and parsing logic to reflect API migration from class-based initialization (III) to function-based patterns (register_worker) with InitOptions, and converts trigger/function registration from positional arguments to dictionary-based inputs across Python and Rust SDKs.

Changes

Cohort / File(s) Summary
Documentation References
docs/content/api-reference/iii-sdk.mdx, docs/content/api-reference/sdk-python.mdx
Updated examples and type documentation to reflect new initialization pattern (register_worker with InitOptions), dictionary-based function/trigger registration APIs, and clarified field descriptions across HttpInvocationConfig, RegisterFunctionInput, RegisterTriggerInput, and related types.
Documentation Parser
docs/scripts/parsers/parse-griffe.mts
Added extractAttributeDescriptions() helper for parsing Attributes sections from docstrings; enhanced extractDocstring() and extractExamples() to handle Google-style sections and doctest prefixes; improved register_worker resolution logic and updated importExample metadata from III to register_worker/InitOptions.
Python SDK Docstrings
sdk/packages/python/iii/src/iii/iii.py, sdk/packages/python/iii/src/iii/iii_constants.py
Expanded method docstrings in register_trigger_type, register_trigger, register_function, and related functions with clarified types and usage examples; extended TelemetryOptions class docstring with documentation for language, project_name, framework, and amplitude_api_key attributes.
Python SDK Type Definitions
sdk/packages/python/iii/src/iii/iii_types.py
Added Field() descriptors with descriptions across HttpAuthHmac, HttpAuthBearer, HttpAuthApiKey, and HttpInvocationConfig; enhanced RegisterTriggerTypeInput, RegisterTriggerInput, RegisterServiceInput, RegisterFunctionFormat, RegisterFunctionInput, TriggerRequest, FunctionInfo, TriggerInfo, WorkerInfo, and StreamChannelRef with expanded docstrings and Field metadata for better schema introspection.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • iii-hq/iii#1294 — Modifies SDK and documentation with the same public API changes (register_worker/InitOptions initialization pattern and dictionary-based trigger/function registration).
  • iii-hq/iii#1310 — Introduces the same Python SDK public-API changes (register_worker, InitOptions, OtelConfig types, and dict-based input patterns).
  • iii-hq/iii#1309 — Applies the same concrete API changes in the Rust SDK (register_worker + InitOptions pattern replacing III::new/connect).

Suggested reviewers

  • guibeira
  • sergiofilhowz

Poem

🐰 From classes old to functions new,
InitOptions bloom in every view,
Dicts replace the args we knew,
Documentation's shining through!
Metadata springs forth with care,
A refactored SDK so fair!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main changes: improving Python SDK API reference documentation with field descriptions and fixing the documentation generator to extract them.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch docs/python-sdk-griffe
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/content/api-reference/sdk-python.mdx`:
- Line 174: The docs show an incorrect type for the parameter named callback;
update the type to the correct signature Callable[[list[FunctionInfo]], None]
(as implemented in iii.py around line 1018) and fix the doc-generator logic in
parse-griffe.mts so it does not truncate callable signatures—ensure
parse-griffe.mts preserves parameterized Callable types when extracting
annotations so the rendered table entry for callback becomes
`Callable[[list[FunctionInfo]], None]`.

In `@sdk/packages/python/iii/src/iii/iii_types.py`:
- Around line 474-476: The Field description for the direction attribute in
iii_types.py is inconsistent with its type: the Literal is defined as "read" |
"write" but the description says "reader" or "writer"; update the description on
the direction Field (symbol: direction) to accurately state "read or write" (or
alternatively change the Literal values to "reader"/"writer" if those are the
intended values) so the docstring matches the actual type.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 667412c7-eb86-4f8e-a2e6-adc1b287a911

📥 Commits

Reviewing files that changed from the base of the PR and between 152fa39 and 8de4fce.

📒 Files selected for processing (6)
  • docs/content/api-reference/iii-sdk.mdx
  • docs/content/api-reference/sdk-python.mdx
  • docs/scripts/parsers/parse-griffe.mts
  • sdk/packages/python/iii/src/iii/iii.py
  • sdk/packages/python/iii/src/iii/iii_constants.py
  • sdk/packages/python/iii/src/iii/iii_types.py

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `callback` | `Callable[None]` | Yes | Receives the current list of ``FunctionInfo`` objects each time availability changes. |
| `callback` | `Callable[None]` | Yes | - |
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Incorrect callback type signature.

The type Callable[None] is incorrect. Per the source code in iii.py line 1018, the actual signature is Callable[[list[FunctionInfo]], None]. The doc generator appears to be truncating the callable type.

📝 Proposed fix
-| `callback` | `Callable[None]` | Yes | - |
+| `callback` | `Callable[[list[FunctionInfo]], None]` | Yes | Receives the current list of ``FunctionInfo`` objects each time availability changes. |

Note: This may require a fix in the doc generator (parse-griffe.mts) to properly extract callable type signatures.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
| `callback` | `Callable[None]` | Yes | - |
| `callback` | `Callable[[list[FunctionInfo]], None]` | Yes | Receives the current list of ``FunctionInfo`` objects each time availability changes. |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/content/api-reference/sdk-python.mdx` at line 174, The docs show an
incorrect type for the parameter named callback; update the type to the correct
signature Callable[[list[FunctionInfo]], None] (as implemented in iii.py around
line 1018) and fix the doc-generator logic in parse-griffe.mts so it does not
truncate callable signatures—ensure parse-griffe.mts preserves parameterized
Callable types when extracting annotations so the rendered table entry for
callback becomes `Callable[[list[FunctionInfo]], None]`.

Comment on lines +474 to +476
direction: Literal["read", "write"] = Field(
description="Channel direction (``reader`` or ``writer``)."
)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix description mismatch for direction field.

The description says "reader or writer" but the actual Literal type values are "read" and "write".

📝 Proposed fix
     direction: Literal["read", "write"] = Field(
-        description="Channel direction (``reader`` or ``writer``)."
+        description="Channel direction (``read`` or ``write``)."
     )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
direction: Literal["read", "write"] = Field(
description="Channel direction (``reader`` or ``writer``)."
)
direction: Literal["read", "write"] = Field(
description="Channel direction (``read`` or ``write``)."
)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sdk/packages/python/iii/src/iii/iii_types.py` around lines 474 - 476, The
Field description for the direction attribute in iii_types.py is inconsistent
with its type: the Literal is defined as "read" | "write" but the description
says "reader" or "writer"; update the description on the direction Field
(symbol: direction) to accurately state "read or write" (or alternatively change
the Literal values to "reader"/"writer" if those are the intended values) so the
docstring matches the actual type.

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.

1 participant