Skip to main content

Snyp is a command line utility that streamlines the process of creating text based documentation and programming tutorials in Markdown.

Project description

Snyp

Snyp is a command line utility that streamlines the process of creating text based documentation and programming tutorials in Markdown.

Snyp extracts specified code snippets from a source file, formats them to enable syntax highlighting in Github Flavored Markdown and prefixes them with a comment exactly specifying where the snippet was extracted from, i.e.:

```python
# snippet from example.py lines 1-2
print('Hey there!')
print('This is an example')
```

Which would be rendered like this:

# snippet from example.py lines 1-2
print('Hey there!')
print('This is an example')

Installation:

pip install snyp

Usage: snyp --help

Usage: snyp.py [OPTIONS] [LINES]...

  Use this tool to extract code snippets from a source file (src) and append
  them to a markdown file (dest)  with proper Github Flavored Markdown
  formatting.

  You can use 0, 1 or 2 'lines' arguments:

  With 0 arguments, the entire source file will be extracted

  With 1 argument, the entire source file starting at lines[0] will be
  extracted

  With 2 arguments, lines lines[0] to lines[1] (inclusively) will be
  extracted from the source file

  Use snip --config to view and update the configuration

Options:
  -s, --src TEXT   The source file from which to extract the code snippet
  -d, --dest TEXT  The destination file to which to append the formatted
                   snippet. "-" for stdout
  -l, --lang TEXT  The language specific formatting to be applied to the code
                   snippet
  -c, --config     Edit the configuration, i.e. to change defaults, add
                   languages, etc.
  --help           Show this message and exit.

Configuration snyp --config

The above command will open Snyp's configuration file in your default editor. It's the easiest way to view and update the configuration.

Section [default]

# snippet from snyp.ini lines 1-5 
[default]
default = python
src = snyp.py
dest = README.md
  • default: the default language profile to use if -l, --lang is not provided
  • src: relative path to the default source file if -s, --src is not provided
  • dest: relative path to the default destination file if -d, --dest is not provided

Language sections: [python], etc.

# snippet from snyp.ini lines 16-19 
[html]
lang = html
commentStart = <!--
commentEnd = -->
  • lang: name of the language. Is used for the prefix that determines syntax highlighting
  • commentStart: How a comment starts in lang
  • commentEnd (optional): How a comment ends in lang

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

snyp-0.1.9.tar.gz (3.5 kB view details)

Uploaded Source

File details

Details for the file snyp-0.1.9.tar.gz.

File metadata

  • Download URL: snyp-0.1.9.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

File hashes

Hashes for snyp-0.1.9.tar.gz
Algorithm Hash digest
SHA256 e650c01eea96d0f4044a88c719787e449e8815f275b25d95994239b59cfb92ae
MD5 565909091daed408621fffa2d7bbb640
BLAKE2b-256 58269e207a36ef44a0d084f9b96aad9f30607af044d383ee070f5e0cfb91d9b8

See more details on using hashes here.

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