Skip to content

Commit

Permalink
docs: add python to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
benfdking committed Nov 24, 2024
1 parent fc3297d commit 5ae6fa3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ name = "ui_with_python"
harness = false

[features]
codegen-docs = ["clap-markdown", "minijinja", "serde"]
python = ["sqruff-lib/python"]
codegen-docs = ["clap-markdown", "minijinja", "serde", "python"]

[dependencies]
sqruff-lib.workspace = true
Expand All @@ -55,4 +55,4 @@ serde = { version = "1.0.214", features = ["derive"], optional = true }
[dev-dependencies]
assert_cmd = "2.0.16"
expect-test = "1.5.0"
tempfile = "3.14.0"
tempfile = "3.14.0"
29 changes: 29 additions & 0 deletions docs/templaters.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Sqruff comes with the following templaters out of the box:

- [raw](raw)
- [placeholder](placeholder)
- [python](python)

## Details

Expand Down Expand Up @@ -117,3 +118,31 @@ N.B. quotes around param_regex in the config are interpreted literally by the te
the named parameter param_name will be used as the key to replace, if missing, the parameter is assumed to be positional and numbers are used instead.

Also consider making a pull request to the project to have your style added, it may be useful to other people and simplify your configuration.

### python

**Note:** This templater currently does not work by default in the CLI and needs custom set up to work.

The Python templater uses native Python f-strings. An example would be as follows:

```sql
SELECT * FROM {blah}
```

With the following config:

```
[sqruff]
templater = python
[sqruff:templater:python:context]
blah = foo
```

Before parsing the sql will be transformed to:

```sql
SELECT * FROM foo
```

At the moment, dot notation is not supported in the templater.

0 comments on commit 5ae6fa3

Please sign in to comment.