Skip to content

Commit

Permalink
Update README. Bump version.
Browse files Browse the repository at this point in the history
  • Loading branch information
slomkowski committed Apr 26, 2021
1 parent 7ed2e7a commit e942e40
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 20 deletions.
37 changes: 27 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
# *nginx* config file formatter
# *nginx* config file formatter/beautifier

This Python script formats *nginx* configuration files in consistent way, described below:
*nginx* config file formatter/beautifier written in Python with no additional dependencies. It can be used as library or standalone script. It formats *nginx* configuration files in consistent way, described below:

* All lines are indented in uniform manner, with 4 spaces per level. Number of spaces is customizable.
* Neighbouring empty lines are collapsed to at most two empty lines.
* Curly braces placement follows Java convention.
* Whitespaces are collapsed, except in comments and quotation marks.

* all lines are indented in uniform manner, with 4 spaces per level
* neighbouring empty lines are collapsed to at most two empty lines
* curly braces placement follows Java convention
* whitespaces are collapsed, except in comments and quotation marks

## Installation

Python 3.4 or later is needed to run this program. The simplest form of installation would be copying `nginxfmt.py` to
your scripts directory.
Python 3.4 or later is needed to run this program. The easiest way is to download package from PyPI:

```bash
pip3 install nginxfmt
```


### Manual installation

The simplest form of installation would be copying `nginxfmt.py` to
your scripts directory. It has no 3-rd party dependencies.

You can also clone the repository and symlink the executable:

Expand All @@ -20,7 +30,11 @@ git clone https://github.com/slomkowski/nginx-config-formatter.git
ln -s ~/nginx-config-formatter/nginxfmt.py ~/bin/nginxfmt.py
```

## Usage

## Usage as standalone script

It can format one or several files. Result is by default saved to the original file, but can be redirected to *stdout*.
It can also function in piping mode, with `--pipe` switch.

```
usage: nginxfmt.py [-h] [-v] [-] [-p | -b] [-i INDENT] [config_files ...]
Expand All @@ -43,6 +57,7 @@ formatting options:
specify number of spaces for indentation
```


## Using as library

Main logic is within `Formatter` class, which can be used in 3rd-party code.
Expand Down Expand Up @@ -75,6 +90,7 @@ fo.indentation = 2 # 2 spaces instead of default 4
f = nginxfmt.Formatter(fo)
```


## Reporting bugs

Please create issue under https://github.com/slomkowski/nginx-config-formatter/issues. Be sure to add config snippets to
Expand All @@ -84,6 +100,7 @@ reproduce the issue, preferably:
* actual result with invalid formatting
* desired result


## Credits

Copyright 2021 Michał Słomkowski. License: Apache 2.0.
Copyright 2021 Michał Słomkowski. License: Apache 2.0. Previously published under https://github.com/1connect/nginx-config-formatter.
4 changes: 2 additions & 2 deletions nginxfmt.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""This Python script formats nginx configuration files in consistent way.
"""nginx config file formatter/beautifier with no additional dependencies.
Originally published under https://github.com/1connect/nginx-config-formatter,
then moved to https://github.com/slomkowski/nginx-config-formatter.
Expand All @@ -18,7 +18,7 @@

__author__ = "Michał Słomkowski"
__license__ = "Apache 2.0"
__version__ = "1.2.1"
__version__ = "1.2.2"


class FormatterOptions:
Expand Down
13 changes: 5 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
[tool.poetry]
name = "nginxfmt"
version = "1.2.1"
description = "nginx config file formatter with no additional dependencies."
authors = ["Michał Słomkowski"]
license = "Apache 2.0"
version = "1.2.2"
description = "nginx config file formatter/beautifier with no additional dependencies."
authors = ["Michał Słomkowski <[email protected]>"]
license = "Apache-2.0"
readme = "README.md"
homepage = "https://github.com/slomkowski/nginx-config-formatter"
repository = "https://github.com/slomkowski/nginx-config-formatter"
keywords = ["nginx", "formatter"]
include = [
"LICENSE",
]
keywords = ["nginx", "formatter", "formatting", "beautifier"]


[tool.poetry.dependencies]
Expand Down

0 comments on commit e942e40

Please sign in to comment.