Skip to content

Commit 70b1053

Browse files
committed
docs: stubs and high level api reference
1 parent 2f493e0 commit 70b1053

28 files changed

+695
-161
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ cov.xml
5151
*.mo
5252
*.pot
5353

54-
# Sphinx documentation
54+
# Documentation
5555
docs/_build/
56+
site/
5657

5758
# PyBuilder
5859
target/

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
- Added support for function extensions.
88
- Added the built-in `length()` function.
9-
- Added the built-in `count()` function. `count()` is an alias for `length()`
9+
- Added the built-in `count()` function. `count()` is an alias for `length()`.
1010
- Support filters without parentheses.
1111
- Adhere to IETF JSONPath draft escaping in quoted property selectors.
1212
- Handle UTF-16 surrogate pairs in quoted property selectors.

docs/advanced.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Advanced
2+
3+
TODO

docs/api.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# API Reference
2+
3+
::: jsonpath.JSONPathEnvironment
4+
handler: python
5+
6+
::: jsonpath.JSONPathMatch
7+
handler: python
8+
9+
::: jsonpath.JSONPath
10+
handler: python
11+
12+
::: jsonpath.CompoundJSONPath
13+
handler: python

docs/async.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Async
2+
3+
TODO

docs/css/style.css

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* Indentation. */
2+
div.doc-contents:not(.first) {
3+
padding-left: 25px;
4+
border-left: .05rem solid var(--md-typeset-table-color);
5+
}
6+
7+
/* Mark external links as such. */
8+
a.autorefs-external::after {
9+
/* https://primer.style/octicons/arrow-up-right-24 */
10+
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="rgb(0, 0, 0)" d="M18.25 15.5a.75.75 0 00.75-.75v-9a.75.75 0 00-.75-.75h-9a.75.75 0 000 1.5h7.19L6.22 16.72a.75.75 0 101.06 1.06L17.5 7.56v7.19c0 .414.336.75.75.75z"></path></svg>');
11+
content: ' ';
12+
13+
display: inline-block;
14+
position: relative;
15+
top: 0.1em;
16+
margin-left: 0.2em;
17+
margin-right: 0.1em;
18+
19+
height: 1em;
20+
width: 1em;
21+
border-radius: 100%;
22+
background-color: var(--md-typeset-a-color);
23+
}
24+
a.autorefs-external:hover::after {
25+
background-color: var(--md-accent-fg-color);
26+
}
27+

docs/custom_api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Low Level API Reference
2+
3+
TODO

docs/exceptions.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Exceptions
2+
3+
::: jsonpath.JSONPathError

docs/index.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Python JSONPath
2+
3+
JSONPath is a mini language for selecting objects from data formatted in JavaScript Object Notation, or equivalent Python objects, like dictionaries and lists.
4+
5+
## Install
6+
7+
Install Python JSONPath using [pip](https://pip.pypa.io/en/stable/getting-started/):
8+
9+
```console
10+
pip install python-jsonpath
11+
```
12+
13+
Or [Pipenv](https://pipenv.pypa.io/en/latest/):
14+
15+
```console
16+
pipenv install python-jsonpath
17+
```
18+
19+
## Example
20+
21+
```python
22+
import jsonpath
23+
24+
example_data = {
25+
"categories": [
26+
{
27+
"name": "footwear",
28+
"products": [
29+
{
30+
"title": "Trainers",
31+
"description": "Fashionable trainers.",
32+
"price": 89.99,
33+
},
34+
{
35+
"title": "Barefoot Trainers",
36+
"description": "Running trainers.",
37+
"price": 130.00,
38+
},
39+
],
40+
},
41+
{
42+
"name": "headwear",
43+
"products": [
44+
{
45+
"title": "Cap",
46+
"description": "Baseball cap",
47+
"price": 15.00,
48+
},
49+
{
50+
"title": "Beanie",
51+
"description": "Winter running hat.",
52+
"price": 9.00,
53+
},
54+
],
55+
},
56+
],
57+
"price_cap": 10,
58+
}
59+
60+
products = jsonpath.findall("$..products.*", example_data)
61+
print(products)
62+
```
63+
64+
Which results in a list of all products from all categories:
65+
66+
```json
67+
[
68+
{
69+
"title": "Trainers",
70+
"description": "Fashionable trainers.",
71+
"price": 89.99
72+
},
73+
{
74+
"title": "Barefoot Trainers",
75+
"description": "Running trainers.",
76+
"price": 130.0
77+
},
78+
{
79+
"title": "Cap",
80+
"description": "Baseball cap",
81+
"price": 15.0
82+
},
83+
{
84+
"title": "Beanie",
85+
"description": "Winter running hat.",
86+
"price": 9.0
87+
}
88+
]
89+
```
90+
91+
Or, reading data from a JSON formatted file:
92+
93+
```python
94+
import jsonpath
95+
96+
with open("some.json") as fd:
97+
products = jsonpath.findall("$..products.*", fd)
98+
99+
print(products)
100+
```
101+
102+
## Next Steps
103+
104+
Have a read through the [Quick Start](quickstart.md) and [High Level API Reference](api.md).
105+
106+
If you're interested in customizing JSONPath, take a look at [Advanced Usage](advanced.md) and the [Low Level API Reference](custom_api.md).

docs/quickstart.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Quick start
2+
3+
TODO

0 commit comments

Comments
 (0)