Skip to main content

srcgen

Srcgen is a semantic code generation framework. Being semantic means that the code generator and the generated code bear similar structure, as well ; for instance, the body of an if statement is indented both in the generating and generated code. Here’s a short example:

>>> from srcgen.python import PythonModule
>>>
>>> m = PythonModule("foo")
>>> m.import_("sys")
>>> m.import_("os")
>>> m.sep()
>>> m.stmt("x = 5")
>>> with m.if_("x > 8"):
...     m.stmt("print 'oh no'")
...
>>> with m.else_():
...     m.stmt("print 'oh yes'")
...
>>> print m
import sys
import os

x = 5
if x > 8:
    print 'oh no'
else:
    print 'oh yes'

You can nest deeper, of course, as well as extract common pieces of code into functions:

m = PythonModule("foo")
with m.class_("MyClass"):
    with m.method("__init__", "

Languages

At the moment Srcgen supports:

  • C

  • Python

  • Cython

  • HTML/XML

More languages will be added per public demand (you’re welcome to join the effort!)

Metadata

Release files for srcgen 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distributions (sdists)

Source distribution for srcgen 1.1.0
File Size Uploaded
srcgen-1.1.0.zip 14.2 kB Details
srcgen-1.1.0.tar.gz 10.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for srcgen 1.1.0
File Interpreter ABI Platform
srcgen-1.1.0.win32.exe Details

Total release size: 233.2 kB

Release files / srcgen-1.1.0.zip

Download URL srcgen-1.1.0.zip
Size 14.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a4137c1b5c63df186c08774a08549c7658dea43e50457c32869c5de03e91b688
BLAKE2b-256 checksum
How to use checksums
c16dcbb58f9c01b7b01b6a5745a433120efbe8a9cb111dc3db3be898477d419d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / srcgen-1.1.0.tar.gz

Download URL srcgen-1.1.0.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
bccf614dbcbbd735e15cf189bee519a3219350a955b10ca2f2e5383d6a33918c
BLAKE2b-256 checksum
How to use checksums
da6ec17bee1caeeaf32bb6ee0f148de1f379b50a165e5314bbf8a7e26c2c9b41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / srcgen-1.1.0.win32.exe

Download URL srcgen-1.1.0.win32.exe
Size 208.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1d7fd88058145fd0f0fd4fd4e53f0537ec28d142dd4b132d6531f39c1923ada7
BLAKE2b-256 checksum
How to use checksums
68b5e4d565e57d2ae4616939fd8582907959acb6472e81d814b4f43fc9bb330c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.1.0 This release

3 release files

1.0.0

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page