Skip to content

Commit 16b8381

Browse files
docs: 💄 use rich for pretty output in guide docs (#259)
# Description Needs a quick review Closes #238 Make output easier to read, esp larger objects like dictionaries. This adds both coloring and formatting. See commit messages for more details. ## Checklist - [x] Ran `just run-all` - I'm seeing some failure checking typos on a JS method in an HTML file, but that is probably not related to this PR... (maybe the built doc pages are not properly excluded from the typo check?) Co-authored-by: Luke W. Johnston <lwjohnst86@users.noreply.github.com>
1 parent 5a4af76 commit 16b8381

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

docs/guide/check.qmd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ jupyter: python3
55
order: 1
66
---
77

8+
{{< include ../includes/_pretty_repr.qmd >}}
9+
810
The purpose of `check-datapackage` is to make sure a Data Package's
911
metadata---stored in its `datapackage.json` file---complies with the
1012
[Data Package standard](https://datapackage.org). This standard defines
@@ -48,11 +50,9 @@ format. The example looks like this (from the
4850

4951
```{python}
5052
import check_datapackage as cdp
51-
import pprint
52-
5353
5454
package_properties = cdp.example_package_properties()
55-
pprint.pp(package_properties)
55+
package_properties
5656
```
5757

5858
When we call `check()` on these properties, it returns an empty list:

docs/guide/config.qmd

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ jupyter: python3
55
order: 3
66
---
77

8+
{{< include ../includes/_pretty_repr.qmd >}}
9+
810
You can pass a [`Config`](/docs/reference/Config.qmd) object to
911
[`check()`](/docs/reference/check.qmd) to customise the checks done on
1012
your Data Package's properties. The following configuration options are
@@ -40,7 +42,6 @@ the `required` check by defining an `Exclusion` object with this `type`:
4042

4143
```{python}
4244
from textwrap import dedent
43-
import pprint
4445
import check_datapackage as cdp
4546
4647
exclusion_required = cdp.Exclusion(type="required")
@@ -90,7 +91,7 @@ package_properties = cdp.example_package_properties()
9091
package_properties["name"] = 123
9192
package_properties["created"] = "not-a-date"
9293
package_properties["resources"][0]["path"] = "\\not/a/path"
93-
pprint.pp(package_properties)
94+
package_properties
9495
```
9596

9697
When we run `check()` on these properties, we get the three expected issues:

docs/guide/issues.qmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ jupyter: python3
55
order: 2
66
---
77

8+
{{< include ../includes/_pretty_repr.qmd >}}
9+
810
## The `Issue` class
911

1012
One `Issue` corresponds to one failed check on one field in the

docs/includes/_pretty_repr.qmd

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!-- Make output representation of code objects easier to read-->
2+
3+
```{python}
4+
#| include: false
5+
from rich import pretty
6+
7+
pretty.install()
8+
```

0 commit comments

Comments
 (0)