Snippets is a code snippets static repository generator. It is like Jekyll/Pelican/etc. for blog, but for code snippets.
- Write code snippets with your favorite editor in plain text.
- Moderate incoming snippets using pull requests and awesome GitHub's code review features.
- Generate site using only one command.
- Highlight code with Pygments.
- Theme site with Jinja2.
Create directory with code snippets. For example:
./snippets/ example.py example.js
And
example.py
is like:# !title: How to print `Hello, World!` in Python # !date: 2012-04-01 # !tags: Python, hello print 'Hello, World!'
When
example.js
is like:/* * !title: How to print `Hello, World!` in JavaScript * !date: 2012-04-01 * !tags: JavaScript, hello */ console.log("Hello, World!");
In header comments you can write some metadata to use it in templates. Every metadata param must begin with bang (
!
) and must contain key and value. All metadata are optional, excepttitle
anddate
.Create a theme for your site. Theme is a directory with three Jinja templates:
index.html
;snippet.html
;tag.html
.
Run
snippets
command for this directory:$ snippets -s snippets -o output -t theme
Open
output/index.html
in your browser or deploy wholeoutput
directory to the remote server.
See example repository here.
Feel free to fork, send pull requests or report bugs and issues on github.