Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Formatter for Gherkin language

Project description

Reformat-gherkin

Build Status   Build Status   Coverage Status

Maintainability   Codacy Badge

License: MIT   PyPI   Code style: black

Table of Contents

About

This tool is a formatter for Gherkin files. It ensures consistent look regardless of the project and authors.

reformat-gherkin can be used either as a command-line tool, or a pre-commit hook.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

Installing

  1. Clone this repository

    git clone https://github.com/ducminh-phan/reformat-gherkin.git
    
  2. Install dependencies

    cd reformat-gherkin
    poetry install
    

Usage

Usage: reformat-gherkin [OPTIONS] [SRC]...

  Reformat the given Gherkin files and all files in the given directories
  recursively.

Options:
  --check                       Don't write the files back, just return the
                                status. Return code 0 means nothing would
                                change. Return code 1 means some files would
                                be reformatted. Return code 123 means there
                                was an internal error.
  -a, --alignment [left|right]  Specify the alignment of step keywords (Given,
                                When, Then,...). If specified, all statements
                                after step keywords are left-aligned, spaces
                                are inserted before/after the keywords to
                                right/left align them. By default, step
                                keywords are left-aligned, and there is a
                                single space between the step keyword and the
                                statement.
  -n, --newline [LF|CRLF]       Specify the line separators when formatting
                                files inplace. If not specified, line
                                separators are preserved.
  --fast / --safe               If --fast given, skip the sanity checks of
                                file contents. [default: --safe]
  --config FILE                 Read configuration from FILE.
  --version                     Show the version and exit.
  --help                        Show this message and exit.

Config file

The tool is able to read project-specific default values for its command line options from a .reformat-gherkin.yaml file.

By default, reformat-gherkin looks for the config file starting from the common base directory of all files and directories passed on the command line. If it's not there, it looks in parent directories. It stops looking when it finds the file, or a .git directory, or a .hg directory, or the root of the file system, whichever comes first.

Example config file

check: False
alignment: left

Pre-commit hook

Once you have installed pre-commit, add this to the .pre-commit-config.yaml in your repository:

repos:
  - repo: https://github.com/ducminh-phan/reformat-gherkin
    rev: stable
    hooks:
      - id: reformat-gherkin

Then run pre-commit install and you're ready to go.

Acknowledgements

This project is inspired by black. Some functions are taken from black's source code.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for reformat-gherkin, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size reformat_gherkin-1.0.0-py3-none-any.whl (23.0 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size reformat-gherkin-1.0.0.tar.gz (17.2 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page