Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/topic/bbannier/readme-updates'
Browse files Browse the repository at this point in the history
  • Loading branch information
bbannier committed Sep 4, 2023
2 parents 37eda70 + 079ac4d commit e1c56ee
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
MD013:
code_blocks: false
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ repos:
hooks:
- id: pyupgrade
args: ["--py37-plus"]

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.33.0
hooks:
- id: markdownlint-fix
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
1.2.4-3 | 2023-09-04 09:57:52 +0200

* Add languages to README code blocks (Benjamin Bannier, Corelight)

* Mention pre-commit hook now that we got a release (Benjamin Bannier, Corelight)

1.2.4 | 2023-09-01 09:50:15 +0200

* Fix mutilated f-strings (Benjamin Bannier, Corelight)
Expand Down
44 changes: 32 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ in depth and feedback is welcome.)

To install our ready-made Python wheels, say:

$ pip install zeekscript
```console
pip install zeekscript
```

For a full list of available builds, you can check out the
[PyPI downloads](https://pypi.org/project/zeekscript/#files) or take a look at our
Expand All @@ -40,9 +42,12 @@ If our build matrix doesn't cover your platform and Python version, or if you'd
simply like to build and install the `zeekscript` package yourself, you need to
provide two dependencies:

* The [tree-sitter Python bindings](https://pypi.org/project/tree-sitter/), available via
* The [tree-sitter Python bindings](https://pypi.org/project/tree-sitter/),
available via

$ pip install tree_sitter
```console
pip install tree_sitter
```

* A C compiler, such as `gcc` or `clang`.

Expand All @@ -53,7 +58,9 @@ releases are tagged in `git`.

For installation from local sources, say:

$ pip install .
```console
pip install .
```

The `zeekscript` package doesn't implement the Zeek grammar compilation itself,
it outsources it to the `tree-sitter` Python bindings, which provide this
Expand All @@ -65,7 +72,9 @@ the package build. See our

The package comes with a testsuite. To run it, say

$ make
```console
make
```

from the toplevel. For details on the tests, take a look at the `tests`
directory.
Expand All @@ -79,7 +88,7 @@ scripts. Our philosophy is similar to `gofmt` and the opposite of
`clang-format`: there is only one way to layout Zeek scripts, and this tool
provides it. Accordingly, it features zero options for tweaking the formatting:

```
```console
$ zeek-format --help
usage: zeek-format [-h] [--version] [--inplace] [--recursive] [FILES ...]

Expand All @@ -101,7 +110,7 @@ formatting in the presence of errors. When it encounters parser errors,
`zeek-format` exits with a non-zero exit code and reports the trouble it
encountered to stderr.

```
```console
$ echo 'event foo( a:count ) {print "hi" ; }' | zeek-format
event foo(a: count)
{
Expand All @@ -112,7 +121,7 @@ event foo(a: count)
To format entire directory trees, combine `--inplace` and `--recursive`, and
point it at a directory:

```
```console
$ cd zeek
$ zeek-format -ir scripts
430 files processed successfully
Expand All @@ -124,7 +133,7 @@ The `zeek-script` command is the Swiss army knife in the toolbox: it provides
access to a range of script-processing tools (including formatting) via
subcommands. (Okay, so far "range" == two, but expect that to grow in the future.)

```
```console
$ zeek-script --help
usage: zeek-script [-h] [--version] {format,parse} ...

Expand All @@ -144,7 +153,7 @@ The `parse` command renders its script input as a parse tree. It resembles
`tree-sitter parse`, but shows more context about the relevant snippets of
content, including parsing errors.

```
```console
$ echo 'event zeek_init() { }' | zeek-script parse
source_file (0.0,1.0) 'event zeek_init() { }\n'
decl (0.0,0.21) 'event zeek_init() { }'
Expand All @@ -163,7 +172,7 @@ source_file (0.0,1.0) 'event zeek_init() { }\n'

Here's a syntax error:

```
```console
$ echo 'event zeek_init)() { }' | zeek-script parse
source_file (0.0,1.0) [error] 'event zeek_init)() { }\n'
decl (0.0,0.22) [error] 'event zeek_init)() { }'
Expand Down Expand Up @@ -205,7 +214,7 @@ for script formatting and parse tree inspection via keyboard shortcuts.

The following snippet hooks up `zeek-format` to format the current script:

```
```vim
function RunZeekScript()
" Create a new undo block for reverting formatting without changing cursor
" position. https://github.com/rhysd/vim-clang-format/pull/55
Expand All @@ -217,3 +226,14 @@ endfunction
nnoremap <silent><buffer> <leader>cf :call RunZeekScript()<CR>
```

## Using `zeek-format` with [pre-commit](https://pre-commit.com/)

Add this to your [`.pre-commit-config.yaml`](https://pre-commit.com/#adding-pre-commit-plugins-to-your-project):

```yaml
- repo: https://github.com/zeek/zeekscript
rev: '' # Use the SHA/tag you want to point at.
hooks:
- id: zeek-format
```
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.4
1.2.4-3
2 changes: 1 addition & 1 deletion zeekscript/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Wrapper around more low-level tests."""
__version__ = "1.2.4"
__version__ = "1.2.4-3"
__all__ = ["cli", "error", "formatter", "node", "output", "parser", "script"]

from .cli import *
Expand Down

0 comments on commit e1c56ee

Please sign in to comment.