Skip to main content

Generate boilerplate from source code comments.

Project description

This is a boilerplate generator that generates code based on the comments it finds in source code.

Motivation

The motivation is that ordinary boilerplate generators either require you to hack the build system you’re using (to build the source code on the fly) or you statically generate the boiler plate (and are then unable to modify it or generate more without pulling together the script that first generated it).

The original use of this was to generate definitions of constants in homework assignments done in the Racket programming language. So as an example of writing a test code for rational number data-type:

;; Constant Gen: r([0-9]+)/([0-9]+) (make-rational \1 \2)

(check-expect (rational-add r7/9 r5/6) r29/18)

Would become:

;; Constant Gen: r([0-9]+)/([0-9]+) (make-rational \1 \2)
(define r29/18 (make-rational 29 18))
(define r5/6 (make-rational 5 6))
(define r7/9 (make-rational 7 9))

(check-expect (rational-add r7/9 r5/6) r29/18)

And no matter how many times you run the program on the source file, it will only generate the same output, or add/remove boilerplate according to how the source file changed.

With this, one can keep the boilerplate in VCS and use txt2boil to update it whenever they need to.

Installation

The preferred way to install this is using pip:

pip install txt2boil

Although if you’re not a regular pip user or are not used to using pip then the alternative is to just download the repository with git:

git clone https://github.com/kcolford/txt2boil.git
cd txt2boil

Or you can download the tar package from the PyPi website by clicking here and then clicking on the big green Download icon. Alternatively you can use wget (or curl if you prefer):

wget https://pypi.python.org/packages/source/t/txt2boil/txt2boil-x.x.x.tar.gz

Once you have the tar ball, unpack it and change to the directory containing it:

tar xf txt2boil-x.x.x.tar.gz
cd txt2boil-x.x.x

Once you’re in the source repository (regardless of how you got it) run the setup.py script:

python setup.py install

How To Use

In order to use txt2boil as in the example above, simply use:

txt2boil -i rational.rkt

The -i option specifies to update the file in place rather than outputting it on stdout.

Supported Languages

Language support all depends on what language the package’s core library has functionality for. The current languages that are supported are:

  • C

  • C++

  • Java

  • Python

  • Racket

Internet Presence

There are two significant web resources for txt2boil. The first is the source repository and the second is the PyPi page. Regardless of which one you go to, this document ought to be the main page found there.

The primary source repository can be found at Git Hub while the PyPi (Python Package Index) page can be found here.

While the Git Hub repository only has source code, the PyPi page has downloads for binary distributions. These binary distributions are provided by anyone generous enough to lend their computer to the task of compiling them and uploading them. Anyone who has privileges to upload to PyPi need only run either the shell script upload.sh or the batch script upload.bat.

License

Copyright (C) 2014 Kieran Colford

This file is part of txt2boil.

txt2boil is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

txt2boil is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with txt2boil. If not, see <http://www.gnu.org/licenses/>.

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

txt2boil-0.7.2.tar.gz (25.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

txt2boil-0.7.2-py2.7.egg (46.7 kB view details)

Uploaded Egg

txt2boil-0.7.2-1.src.rpm (33.6 kB view details)

Uploaded Source

txt2boil-0.7.2-1.noarch.rpm (29.0 kB view details)

Uploaded Source

File details

Details for the file txt2boil-0.7.2.tar.gz.

File metadata

  • Download URL: txt2boil-0.7.2.tar.gz
  • Upload date:
  • Size: 25.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for txt2boil-0.7.2.tar.gz
Algorithm Hash digest
SHA256 d92dc342e61a5631210e3c48d10b89ba3e2bf2e04666353958eaae5c126a7d64
MD5 0d2e6990997f2f13f4f4ed09b3c76e66
BLAKE2b-256 1d769235ddb74fdb83b8afd00dcd5607c9cd9a363491e7b3220b5dcbe7eabcbc

See more details on using hashes here.

File details

Details for the file txt2boil-0.7.2-py2.7.egg.

File metadata

  • Download URL: txt2boil-0.7.2-py2.7.egg
  • Upload date:
  • Size: 46.7 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for txt2boil-0.7.2-py2.7.egg
Algorithm Hash digest
SHA256 e4f51b7197a6dd4688d6325ce49c6094056e208d278b2929846f7209e6568bcb
MD5 c01460f1ccce313af4da95d6befe317a
BLAKE2b-256 e6f70e2d7d2c70b1f8451db0f884263b821399946afed1f591b2f6edc58bdc69

See more details on using hashes here.

File details

Details for the file txt2boil-0.7.2-1.src.rpm.

File metadata

  • Download URL: txt2boil-0.7.2-1.src.rpm
  • Upload date:
  • Size: 33.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for txt2boil-0.7.2-1.src.rpm
Algorithm Hash digest
SHA256 c8cf04b7d035788fd2792947cfd551f1f9a15f4bcf0f7fef0a53c030a30415a7
MD5 bf9816e66c4396c2527ceb61acf46c68
BLAKE2b-256 cefd29658719262484bcff99a833e7d9ab91e47e657cdd90b3e2a2d6fa5ac745

See more details on using hashes here.

File details

Details for the file txt2boil-0.7.2-1.noarch.rpm.

File metadata

File hashes

Hashes for txt2boil-0.7.2-1.noarch.rpm
Algorithm Hash digest
SHA256 dca15db34907bc5c6a31e7077b193e5dcef2c2c814b8e909e0a5608e2dacf082
MD5 552d691a577a3c7916d312d5f72d3113
BLAKE2b-256 14a7a9141d515c84995b42be37effcb49047223bd2d31ce365cd27fb334232b5

See more details on using hashes here.

Supported by

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