Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation about pre-commit-config files. #306

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions docs/using-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,25 @@ repos:
language: python
```

Alternatively, you could also create your own pre-commit hook. A sample `jupytext_hook.py` script could be

```python
import sys
import pathlib
import jupytext

nbfile = pathlib.Path(sys.argv[1])
mdfile = nbfile.with_suffix(".md")
Here is another `.pre-commit-config.yaml` example that uses the --pre-commit mode of Jupytext to convert all `.ipynb` notebooks to `py:light` representation and unstage the `.ipynb` files before committing.
```
repos:
-
repo: local
hooks:
-
id: jupytext
name: jupytext
entry: jupytext --from ipynb --to py:light --pre-commit
pass_filenames: false
language: python
-
id: unstage-ipynb
name: unstage-ipynb
entry: git reset HEAD **/*.ipynb
pass_filenames: false
language: system

nb = jupytext.read(nbfile)
jupytext.write(nb, mdfile)
```

## Testing the round-trip conversion
Expand Down