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.4.10.tar.gz (11.8 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.4.10-py2.7.egg (42.2 kB view details)

Uploaded Egg

txt2boil-0.4.10-1.src.rpm (20.4 kB view details)

Uploaded Source

txt2boil-0.4.10-1.noarch.rpm (31.9 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for txt2boil-0.4.10.tar.gz
Algorithm Hash digest
SHA256 aa97f3e457e1fefb37f2da5bd249621e5656642cba4a1ef10c53cc975e16bfb8
MD5 1660376ddcc91e79a8b3abd0ca65c6bd
BLAKE2b-256 3baf62dd587552a4c03c3c416d6c69e34a65b87e411bd3add78a2e64235ea55c

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for txt2boil-0.4.10-py2.7.egg
Algorithm Hash digest
SHA256 7d8a59d32717aa8f77b60e5f2e59a602ee9411ccf1d88f6f8c21556424ed97cc
MD5 57be4b474cde8b4642df4322abd3e08d
BLAKE2b-256 9087a1182bff4b598e08c7049d20fd6024993fce4fb90f2c42ce39d974363957

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for txt2boil-0.4.10-1.src.rpm
Algorithm Hash digest
SHA256 b02301f853f4c35051f509b76836967b5dc3dd65e5a1eb0029184ac915f127e3
MD5 4595afca9ba0fc2b1b4ac89b02286567
BLAKE2b-256 fb40ed2d4237e0ab8540e038c099d13fca786b3ec4700d2ced81781f34ad005c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for txt2boil-0.4.10-1.noarch.rpm
Algorithm Hash digest
SHA256 03de235d1105fb138d2ea48cf1dbf4d5440465e573747e0451642eb13e677e09
MD5 f00baf8bccdaf4ecb33b190f0d691c90
BLAKE2b-256 e606b1de99ce990b395bfa8c06750b4313da8e9214618d89a7afc78bf1a6827b

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