Skip to content

Instantly share code, notes, and snippets.

@wd15
Last active March 23, 2016 13:57
Show Gist options
  • Select an option

  • Save wd15/2b4ffbe5ce0d0ddb8a5b to your computer and use it in GitHub Desktop.

Select an option

Save wd15/2b4ffbe5ce0d0ddb8a5b to your computer and use it in GitHub Desktop.
Generate a SVG image for SWC Python function documentation

Python Function SVG Image for SWC

Instructions

To generate the image use

$ pygmentize -f svg -O style=colorful -l python -o test.svg code.py

to generate colorized code and then use draw.io to annotate the code. The HTML can be opened in draw.io and edited, see https://goo.gl/5khWp0 for the HTML.

The image is desinged to augment the SWC documenation for Creating Functions.

The idea for this image came from Introduction To Programming in Python.

Better Approach

The concern with using draw.io is that the approach in not very reproducible. The annotation could be achieved using some Javascript libraries for both highlighting code and annotating. However this would seem like an approach that is too web oriented for the static docs generated by SWC. An alternative, low-tech approach would be to write a filter for pygments that generates the background boxes, arrows and annotation text.

Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
def fahr_to_kelvin(temp):
return ((temp - 32) * (5/9)) + 273.15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment