Giter VIP home page Giter VIP logo

codeimagegenerator's Introduction

CodeImageGenerator

Tests Codacy Badge

CodeImageGenerator is a Python script, which converts Java or Python files/functions to images. This includes a rough custom syntax highlighting with Pygments.

I personally use this to convert short code snippets for empirical research on program comprehension (see Brains on Code). This means the script is very personalized to my usage, and probably not directly useful to you without changes.

Features

The main feature is to read all files from a directory, attempting to add syntax highlighting, and finally creating matching images.

Implemented so far:

  • Reads all files from a directory, and parses one at a time
  • Extracts just the function code from the file (and ignores the class, comments, etc around it)
  • Uses Pygments to create syntax highlighting for the code
  • Parses Pygments syntax highlighting to fit on the image
  • Dynamically reduces font size if the code doesn't fit the screen
  • Option to either strip boilerplate code and reduce to single method (or use full file)
  • Rough support for Java and Python functions
  • Rough image creation

Limitations/Roadmap

Things I may add in the future:

  • Better and cleaner (Python) code...
  • Better configuration (in particular the output color scheme)
  • Command line support
  • Allow functions besides public int, public String, public boolean, and a couple of other static ones
  • Only read Java files
  • Support for more languages than just Java and Python

Font

The text is generated with the Inconsolata font. The font licence is here: Inconsolata licence.

Setup

The project should run in any Python environment. It was developed and tested with PyCharms.

Contributing

Do you want to fix my horrible Python code? Feel free to create a pull request :)

Thank you!

License

MIT License

Copyright (c) 2018 Norman Peitek

codeimagegenerator's People

Contributors

peitek avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.