Skip to main content

Reproducible report generation tool.

Project description

Stitch

Build Status

Documentation Status

A knitr-like library, in Python.

Note: You might want to consider knitpy instead. It’s probably more mature at this point. However, I wanted to see if there was a simpler way of doing things.

The high-level goal of this type of library is to make writing reproducible reports easier.

Documentation is available on readthedocs.

Examples

See the project’s website for a side-by-side comparison of input markdown and stitched HTML.

More complex examples are linked to from there as well.

Install

At the moment stitch can be installed from pip via

pip install knotr

I know, it’s confusing. I’ve filed a claim for stitch on PyPI, but I think the people working that support queue are over-worked. Once that gets processed, I’ll put it up on conda-forge as well. If you need a mnemonic, it’s “I want knitr, but not the one written in R.” Also I wanted to confuse R users. And knots are kind of like a buggy version of knits.

Design

The goal was to keep stitch itself extremely simple by reusing existing libraries. A high level overview of our tasks is

  1. Command-line Interface

  2. Parse markdown file

  3. Execute code chunks, capturing the output

  4. Collate execution output into the document

  5. Render to final output

Fortunately the building blocks are all there.

We reuse

  • pandoc via pypandoc for parsing markdown and rendering the final output

  • jupyter for language kernels, executing code, and collecting the output

  • Use pandocfilters to collate the execution output into the document

So all stitch has to do is to provide a command-line interface, scan the document for code chunks, manage some kernels, hand the code to the kernels, pass the output to an appropriate pandocfilter.

The biggest departure from knitpy is the use of pandoc’s JSON AST. This is what you get from pandoc -t json input.md

This saves us from having do any kind of custom parsing of the markdown. The only drawback so far is somewhat inscrutable Haskell exceptions if stitch happens to produce a bad document.

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

knotr-0.3.2.tar.gz (25.6 kB view details)

Uploaded Source

Built Distribution

knotr-0.3.2-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file knotr-0.3.2.tar.gz.

File metadata

  • Download URL: knotr-0.3.2.tar.gz
  • Upload date:
  • Size: 25.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for knotr-0.3.2.tar.gz
Algorithm Hash digest
SHA256 2a0e4c402a1d66e1b44c62aab2c2f6b4ad189f7bab607c8743d3bf5f3b84b941
MD5 7aef9c9f17792549e1ed08c5f4ae6cb0
BLAKE2b-256 0b51fdd9c2d71b023fea4f4769267c42cdd662c0855d976091fdd83fb2be13cd

See more details on using hashes here.

Provenance

File details

Details for the file knotr-0.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for knotr-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ba8bee999deb063e566688c1dedcfd69d3871ed8b3024c7286e5d3bfea1bda83
MD5 a40605c643aaa622f32c4bad6d7c0a5e
BLAKE2b-256 e0008c69e9e933b9ac31c851ce9f10ab6444443189be30940e84c68002295dd4

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page