Skip to content

zkneupper/codecolor

Repository files navigation

codecolor

https://raw.githubusercontent.com/zkneupper/codecolor/master/docs/_static/code_color_logo.png

https://circleci.com/gh/zkneupper/codecolor.svg?style=shield Documentation Status

master branch ci status:

https://circleci.com/gh/zkneupper/codecolor/tree/master.svg?style=shield

develop branch ci status:

https://circleci.com/gh/zkneupper/codecolor/tree/develop.svg?style=shield

Inspect python object code with colorful syntax highlighting!

Codecolor adds color when inspecting source code of python objects. It applies syntax highlighting to object source code.

The primary function of the codecolor module is the printsource function. The printsource(obj, style="default") function prints the syntax-highlighted source code for the python object obj.

Codecolor combines the code inspection functionality of inspect.getsource() and syntax highlighting functionality of the pygments package.

Example

How does the pytorch relu function work under the hood? You can easily inspect the source code of the pytorch relu function by using codecolor.printsource(relu) to to print the source code of the relu function with syntax highlighting.

from codecolor import printsource

from torch.nn.functional import relu

printsource(relu)
# prints the source code of the relu function with syntax highlighting

https://raw.githubusercontent.com/zkneupper/codecolor/master/docs/_static/codecolor-demo.gif

Functions:

  • printsource(obj, style="default")
  • getsource(obj, style="default")
  • highlight_code(code, style="default")
  • get_all_styles()

To-Do

  • Add pytest unit tests

  • Flesh out readme

    • Example usage
    • Motivation
    • Installation
    • Center logo image
  • Deploy to pypi

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

About

Codecolor adds color when inspecting source code of python objects.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published