Skip to content

Commit acd77b6

Browse files
committed
Simplify README: less is more
Drop most of the talk and get straight to business. Instead of describing the code, just expect the code to describe itself. Move the information about the non-NPM usage at the end of the README to get it out of the really useful information. Add a bit longer summary at the top to describe the purpose of the library in bit more detail.
1 parent 303f08d commit acd77b6

File tree

1 file changed

+30
-40
lines changed

1 file changed

+30
-40
lines changed

README.md

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,68 @@
11
# SQL Formatter [![NPM version](https://img.shields.io/npm/v/sql-formatter.svg)](https://npmjs.com/package/sql-formatter) [![Build Status](https://travis-ci.org/zeroturnaround/sql-formatter.svg?branch=master)](https://travis-ci.org/zeroturnaround/sql-formatter) [![Coverage Status](https://coveralls.io/repos/github/zeroturnaround/sql-formatter/badge.svg?branch=master)](https://coveralls.io/github/zeroturnaround/sql-formatter?branch=master)
22

3-
**SQL Formatter** is a whitespace formatter for different query languages.
3+
**SQL Formatter** is a JavaScript library for pretty-printing SQL queries.
4+
It started as a port of a [PHP Library][], but has since considerably diverged.
5+
It supports [Standard SQL][] and [Couchbase N1QL][] dialects.
46

5-
[See the demo](https://zeroturnaround.github.io/sql-formatter/).
7+
→ [Try the demo.](https://zeroturnaround.github.io/sql-formatter/)
68

7-
## Installation
9+
## Install
810

9-
To install the newest version from NPM:
11+
Get the latest version from NPM:
1012

1113
```
1214
npm install --save sql-formatter
1315
```
1416

15-
The SQL Formatter source code is written in ES2015 but we precompile both CommonJS and UMD builds to ES5 so they work in any modern browser.
16-
17-
If you don't use a module bundler then you can drop a file from `/dist` directory as a `<script>` tag on the page. This makes SQL Formatter available as a `window.sqlFormatter` global variable.
18-
19-
## Example usage
20-
21-
First we need to import our CommonJS module and then we can use it for formatting
22-
standard SQL query.
17+
## Usage
2318

2419
```js
2520
import sqlFormatter from "sql-formatter";
2621

27-
const formattedStandardSql = sqlFormatter.format("SELECT * FROM table1");
22+
console.log(sqlFormatter.format("SELECT * FROM table1"));
2823
```
2924

30-
The value of `formattedStandardSql` will look like this:
25+
This will output:
3126

32-
```sql
27+
```
3328
SELECT
3429
*
3530
FROM
3631
table1
3732
```
3833

39-
## Supported languages
40-
41-
### [Standard SQL](https://en.wikipedia.org/wiki/SQL:2011)
42-
43-
```js
44-
sqlFormatter.format("SELECT * FROM table1 WHERE foo = bar");
45-
```
46-
47-
### [N1QL](http://www.couchbase.com/n1ql)
34+
You can also pass in configuration options:
4835

4936
```js
50-
sqlFormatter.format("SELECT fname, email FROM tutorial USE KEYS ['dave', 'ian'];", {language: "n1ql"});
37+
sqlFormatter.format("SELECT *", {
38+
language: "n1ql" // Defaults to "sql"
39+
indent: " " // Defaults to two spaces
40+
});
5141
```
5242

53-
## Optional configuration
43+
Currently just two SQL dialects are supported:
5444

55-
Example below has default values.
45+
- **sql** - [Standard SQL][]
46+
- **n1ql** - [Couchbase N1QL][]
5647

57-
```js
58-
const cfg = {
59-
language: "sql" // Specific query language
60-
indent: " " // Value that is used for creating indentation levels
61-
};
48+
## Usage without NPM
6249

63-
sqlFormatter.format("SELECT *", cfg);
64-
```
50+
If you don't use a module bundler, clone the repository, run `npm install` and grab a file from `/dist` directory to use inside a `<script>` tag.
51+
This makes SQL Formatter available as a global variable `window.sqlFormatter`.
6552

6653
## Contributing
6754

68-
Simply `npm install` to install the dependencies, write your fix,
69-
ensure tests and linter are fine with `npm run check`,
70-
and you're ready to poke us with a pull request.
71-
72-
## Influence
55+
```bash
56+
# run linter and tests
57+
$ npm run check
58+
```
7359

74-
SQL Formatter core logic is influenced by a PHP version of [SQL Formatter by Jeremy Dorn](https://github.com/jdorn/sql-formatter).
60+
...and you're ready to poke us with a pull request.
7561

7662
## License
7763

7864
[MIT](https://github.com/zeroturnaround/sql-formatter/blob/master/LICENSE)
65+
66+
[PHP library]: https://github.com/jdorn/sql-formatter
67+
[Standard SQL]: https://en.wikipedia.org/wiki/SQL:2011
68+
[Couchbase N1QL]: http://www.couchbase.com/n1ql

0 commit comments

Comments
 (0)