Skip to main content

Inline seamless code generation

Project description

Stubble

A native, inline code-generation tool

The Problem

One of the most difficult aspects of code generation is integrating generated code into existing codebases. Templating systems typically require full ownership of files or whole directories.

The solution

Stubble aims to solve this by allowing you to provide comment-based "stubs" in your existing codebase, to allow for injection of additional code. Your templates can be written in your native language and will be valid code on their own in their native language.

Example

Let's say you have a python file. You can easily add a stub that stubble will find and replace:

... before your code
def main():
	do_something()
	do_something_else()
	# {{replace_this}}

Getting Started

The easiest way to install stubble is via pip:

pip install stubble

From the command-line

And then it can be invoked as a command-line tool:

python3 -m stubble --template my_file.cpp --json replacements.json

By default, stubble produces code in a generated folder in the same location as it is in invoked.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stubbles-0.4.0.tar.gz (6.8 kB view hashes)

Uploaded Source

Built Distribution

stubbles-0.4.0-py3-none-any.whl (8.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page