Skip to content

Commit fe1f7eb

Browse files
committed
docs: added some documentation
1 parent a5a5aa4 commit fe1f7eb

12 files changed

Lines changed: 332 additions & 311 deletions

File tree

docs/alternatives.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
inline-snapshot is not the only snapshot library for python.
1+
inline-snapshot is not the only snapshot testing library for python.
22
There are several others to:
33

44
* [syrupy](https://github.com/syrupy-project/syrupy)
@@ -13,7 +13,7 @@ If you miss a feature that is available in other libraries, please let me know.
1313
<iframe
1414
src="https://pypacktrends.com/embed?packages=inline-snapshot&packages=snapshottest&packages=syrupy&packages=pytest-snapshot&packages=pytest-insta&time_range=2years"
1515
width="100%"
16-
height="480"
16+
height="520"
1717
frameborder="0"
1818
>
1919
</iframe>

docs/configuration.md

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ default-flags=["report"]
77
default-flags-tui=["create", "review"]
88
format-command=""
99
show-updates=false
10+
default-storage="uuid"
1011

1112
[tool.inline-snapshot.shortcuts]
1213
review=["review"]
@@ -36,24 +37,45 @@ fix=["create","fix"]
3637
* **shortcuts:** allows you to define custom commands to simplify your workflows.
3738
`--fix` and `--review` are defined by default, but this configuration can be changed to fit your needs.
3839

39-
* **storage-dir:** allows you to define the directory where inline-snapshot stores data files such as external snapshots.
40+
* **storage-dir:** allows you to define the directory where inline-snapshot stores data files such as external snapshots stored with the `hash:` protocol.
4041
By default, it will be `<pytest_config_dir>/.inline-snapshot`,
4142
where `<pytest_config_dir>` is replaced by the directory containing the Pytest configuration file, if any.
4243
External snapshots will be stored in the `external` subfolder of the storage directory.
4344
* **format-command:[](){#format-command}** allows you to specify a custom command which is used to format the python code after code is changed.
44-
``` toml
45-
[tool.inline-snapshot]
46-
format-command="ruff format --stdin-filename {filename}"
47-
```
48-
The placeholder `{filename}` can be used to specify the filename if it is needed to find the correct formatting options for this file.
45+
46+
=== "ruff format"
47+
``` toml
48+
[tool.inline-snapshot]
49+
format-command="ruff format --stdin-filename {filename}"
50+
```
51+
52+
=== "ruff format & lint"
53+
``` toml
54+
[tool.inline-snapshot]
55+
format-command="ruff check --fix-only --stdin-filename {filename} | ruff format --stdin-filename {filename}"
56+
```
57+
58+
=== "black"
59+
``` toml
60+
[tool.inline-snapshot]
61+
format-command="black --stdin-filename {filename} -"
62+
```
63+
64+
=== "no command (default)"
65+
inline-snapshot will format only the snapshot values with black when you specified no format command but needs black installed with `inline-snapshot[black]`.
66+
67+
The placeholder `{filename}` can be used to specify the filename if it is needed to find the correct formatting options for this file.
4968

5069
!!! important
5170
The command should **not** format the file on disk. The current file content (with the new code changes) is passed to *stdin* and the formatted content should be written to *stdout*.
5271

53-
You can also use a `|` if you want to use multiple commands.
54-
``` toml
55-
[tool.inline-snapshot]
56-
format-command="ruff check --fix-only --stdin-filename {filename} | ruff format --stdin-filename {filename}"
57-
```
58-
5972
* **show-updates:**[](){#show-updates} shows updates in reviews and reports.
73+
74+
75+
* **default-storage:**[](){#default-storage} defines the default storage protocol to be used when creating snapshots without an explicit storage protocol (e.g. like `external()`).
76+
Possible values are `hash` and `uuid`.
77+
external snapshots created by `outsource()` do not currently support this setting due to some internal limitations and will always use the old `hash` protocol.
78+
79+
* **tests-dir:** can be used to define where your tests are located.
80+
The default is `<pytest_config_dir>/tests` if it exists or `<pytest_config_dir>` if you have no tests directory,
81+
where `<pytest_config_dir>` is replaced by the directory containing the Pytest configuration file, if any.

0 commit comments

Comments
 (0)