Skip to content

Add Python API documentation for DDM#739

Merged
joehendrix merged 5 commits intomainfrom
jhx/python-doc
Apr 3, 2026
Merged

Add Python API documentation for DDM#739
joehendrix merged 5 commits intomainfrom
jhx/python-doc

Conversation

@joehendrix
Copy link
Copy Markdown
Contributor

@joehendrix joehendrix commented Apr 2, 2026

Add documentation for the strata Python package so that developers can work with DDM concepts without reading Lean source code.

Changes

1. Python section in DDMDoc.lean

The DDM manual had no coverage of the Python API — developers had to read base.py source to understand how to create dialects, build programs, or serialize to Ion. The new section documents the strata.base module: Dialect, Program, Init, declarations (SynCatDecl, OpDecl, ArgDecl), AST node types, collections, source locations, and metadata. It maps Python types to their Lean generic AST counterparts (OperationOperationF, etc.) and notes gaps like the missing SpaceSepBy/SpacePrefixSepBy categories. Placed before the existing "Command Line Use" stub so it flows naturally after Lean integration.

2. Tools/Python/PythonDialect.md

The existing README covers CLI invocations but not how the Python dialect is structured or how to use the parser programmatically. The new Markdown file explains the dialect generation process (reflecting over CPython's ast module), the type mapping from Python AST to DDM categories, the Parser class and gen_dialect() API, and version compatibility across Python 3.11–3.14. Kept as Markdown rather than Verso since this is engineer-facing tooling documentation, not a formal manual.

3. Tools/Python/README.md pointer updates

Added cross-references to the DDM manual and PythonDialect.md so engineers landing in Tools/Python can find the right documentation quickly.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

joehendrix and others added 2 commits April 2, 2026 13:10
Document the strata.base Python API in DDMDoc.lean (Dialect, Program,
Init, declarations, AST node types, metadata) and create PythonDialect.md
for the auto-generated Python dialect, CLI commands, and Parser API.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verso's InlineLean elaboration interprets language-annotated code blocks
as Lean constants, causing "Unknown constant `python`" build errors.
Use bare code fences to match the rest of DDMDoc.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@joehendrix joehendrix marked this pull request as ready for review April 3, 2026 06:26
@joehendrix joehendrix requested a review from a team April 3, 2026 06:26
tautschnig
tautschnig previously approved these changes Apr 3, 2026
- Add missing `Init` import in "Adding Operators" code block
- Define `val` variable in OpDecl usage example (was `some_expr`)
- Add `decl_list` syncat and use defined variables in metadata example
- Add cross-reference to Building Programs section for context

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Pass tuples instead of lists to add_syncat in Init setup to match
the type signature `tuple[str, ...] | None`. Make the DDM Manual
reference in PythonDialect.md a relative link for GitHub navigation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
tautschnig
tautschnig previously approved these changes Apr 3, 2026
@joehendrix joehendrix enabled auto-merge April 3, 2026 19:12
Comment thread Tools/Python/README.md Outdated
Comment thread Tools/Python/PythonDialect.md Outdated
Comment thread docs/verso/DDMDoc.lean Outdated
Comment thread docs/verso/DDMDoc.lean
atomb
atomb previously approved these changes Apr 3, 2026
@atomb
Copy link
Copy Markdown
Contributor

atomb commented Apr 3, 2026

I like having this included in the DDM manual, and perhaps the Java API documentation (#694) should move there, too (though I'm inclined to merge that PR as-is and then possibly migrate it).

- Trim README CLI sections to a Quick Start with pointer to
  PythonDialect.md, avoiding duplicate maintenance (MikaelMayer)
- Link PythonDialect.md to deployed DDM Manual at
  strata-org.github.io instead of Lean source file (MikaelMayer)
- Link DDMDoc.lean PythonDialect.md reference to GitHub blob URL
  so it works in rendered HTML (MikaelMayer)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@joehendrix joehendrix dismissed stale reviews from atomb and tautschnig via 3990185 April 3, 2026 19:55
@joehendrix joehendrix added this pull request to the merge queue Apr 3, 2026
Merged via the queue into main with commit f068048 Apr 3, 2026
15 checks passed
@joehendrix joehendrix deleted the jhx/python-doc branch April 3, 2026 21:15
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.

4 participants