Skip to content

Commit 4061f20

Browse files
authored
guide: bump to mdbook 0.5 (#5630)
* guide: bump to mdbook 0.5 * bump mdbook pins * fix mdbook warnings * use mdbook 0.5 admonitions * fix `rumdl` issues * fix heading id * remove warning div class
1 parent ea73342 commit 4061f20

File tree

12 files changed

+44
-28
lines changed

12 files changed

+44
-28
lines changed

.github/workflows/netlify-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Setup mdBook
3232
uses: taiki-e/install-action@v2
3333
with:
34-
tool: mdbook@0.4, mdbook-tabs@0.2, lychee
34+
tool: mdbook@0.5, mdbook-tabs@0.3, lychee
3535

3636
- name: Prepare tag
3737
id: prepare_tag

guide/book.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[book]
22
title = "PyO3 user guide"
33
description = "PyO3 user guide"
4-
author = "PyO3 Project and Contributors"
4+
authors = ["PyO3 Project and Contributors"]
55

66
[preprocessor.pyo3_version]
7-
command = "python3 guide/pyo3_version.py"
7+
command = "python3 pyo3_version.py"
88

99
[preprocessor.tabs]
1010

guide/pyo3_version.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
- {{#PYO3_CRATE_VERSION}} with a relevant toml snippet (e.g. 'version = "0.13.2"')
77
88
9-
Tested against mdbook 0.4.10.
9+
Tested against mdbook 0.5.0.
1010
"""
1111

1212
import json
@@ -28,26 +28,26 @@
2828
PYO3_CRATE_VERSION = f'version = "{version}"'
2929

3030

31-
def replace_section_content(section):
32-
if not isinstance(section, dict) or "Chapter" not in section:
31+
def replace_item_content(item):
32+
if not isinstance(item, dict) or "Chapter" not in item:
3333
return
3434

3535
# Replace raw and url-encoded forms
36-
section["Chapter"]["content"] = (
37-
section["Chapter"]["content"]
36+
item["Chapter"]["content"] = (
37+
item["Chapter"]["content"]
3838
.replace("{{#PYO3_VERSION_TAG}}", PYO3_VERSION_TAG)
3939
.replace("{{#PYO3_DOCS_URL}}", PYO3_DOCS_URL)
4040
.replace("{{#PYO3_DOCS_VERSION}}", PYO3_DOCS_VERSION)
4141
.replace("{{#PYO3_CRATE_VERSION}}", PYO3_CRATE_VERSION)
4242
)
4343

44-
for sub_item in section["Chapter"]["sub_items"]:
45-
replace_section_content(sub_item)
44+
for sub_item in item["Chapter"]["sub_items"]:
45+
replace_item_content(sub_item)
4646

4747

4848
for line in sys.stdin:
4949
if line:
5050
[context, book] = json.loads(line)
51-
for section in book["sections"]:
52-
replace_section_content(section)
51+
for item in book["items"]:
52+
replace_item_content(item)
5353
json.dump(book, fp=sys.stdout)

guide/src/building-and-distribution.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ See [the relevant section of this guide](./building-and-distribution/multiple-py
247247
PyO3 is only able to link your extension module to abi3 version up to and including your host Python version.
248248
E.g., if you set `abi3-py38` and try to compile the crate with a host of Python 3.7, the build will fail.
249249

250-
> Note: If you set more that one of these `abi3` version feature flags the lowest version always wins. For example, with both `abi3-py37` and `abi3-py38` set, PyO3 would build a wheel which supports Python 3.7 and up.
250+
> [!NOTE]
251+
> If you set more that one of these `abi3` version feature flags the lowest version always wins. For example, with both `abi3-py37` and `abi3-py38` set, PyO3 would build a wheel which supports Python 3.7 and up.
251252
252253
#### Building `abi3` extensions without a Python interpreter
253254

guide/src/class.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ mod my_module {
210210
}
211211
```
212212

213-
## Bound<T> and interior mutability
213+
## `Bound<T>` and interior mutability { #bound-and-interior-mutability }
214214

215215
It is often useful to turn a `#[pyclass]` type `T` into a Python object and access it from Rust code.
216216
The [`Py<T>`] and [`Bound<'py, T>`] smart pointers are the ways to represent a Python object in PyO3's API.
@@ -807,10 +807,12 @@ Python::attach(|py| {
807807
});
808808
```
809809

810-
> Note: if the method has a `Result` return type and returns an `Err`, PyO3 will panic during
810+
> [!NOTE]
811+
> If the method has a `Result` return type and returns an `Err`, PyO3 will panic during
811812
class creation.
812813

813-
> Note: `#[classattr]` does not work with [`#[pyo3(warn(...))]`](./function.md#warn) attribute.
814+
> [!NOTE]
815+
> `#[classattr]` does not work with [`#[pyo3(warn(...))]`](./function.md#warn) attribute.
814816
815817
If the class attribute is defined with `const` code only, one can also annotate associated constants:
816818

guide/src/class/object.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ This option also requires `eq`: According to the [Python docs](https://docs.pyth
181181
struct Number(i32);
182182
```
183183

184-
> **Note**: When implementing `__hash__` and comparisons, it is important that the following property holds:
184+
> [!NOTE]
185+
> When implementing `__hash__` and comparisons, it is important that the following property holds:
185186
>
186187
> ```text
187188
> k1 == k2 -> hash(k1) == hash(k2)

guide/src/class/protocols.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ The given signatures should be interpreted as follows:
8484
The implementations of Python's "rich comparison" operators `<`, `<=`, `==`, `!=`, `>` and `>=` respectively.
8585
8686
_Note that implementing any of these methods will cause Python not to generate a default `__hash__` implementation, so consider also implementing `__hash__`._
87+
8788
<details>
8889
<summary>Return type</summary>
90+
8991
The return type will normally be `bool` or `PyResult<bool>`, however any Python object can be returned.
9092
</details>
9193
@@ -100,6 +102,7 @@ The given signatures should be interpreted as follows:
100102
_Note that implementing `__richcmp__` will cause Python not to generate a default `__hash__` implementation, so consider implementing `__hash__` when implementing `__richcmp__`._
101103
<details>
102104
<summary>Return type</summary>
105+
103106
The return type will normally be `PyResult<bool>`, but any Python object can be returned.
104107
105108
If you want to leave some operations unimplemented, you can return `py.NotImplemented()`
@@ -135,7 +138,8 @@ The given signatures should be interpreted as follows:
135138
- `__getattribute__(<self>, object) -> object`
136139
137140
<details>
138-
<summary>Differences between `__getattr__` and `__getattribute__`</summary>
141+
<summary>Differences between <code>__getattr__</code> and <code>__getattribute__</code></summary>
142+
139143
As in Python, `__getattr__` is only called if the attribute is not found
140144
by normal attribute lookup. `__getattribute__`, on the other hand, is
141145
called for *every* attribute access. If it wants to access existing
@@ -440,7 +444,8 @@ Immutable references do not have to be cleared, as every cycle must contain at l
440444
- `__traverse__(<self>, pyo3::class::gc::PyVisit<'_>) -> Result<(), pyo3::class::gc::PyTraverseError>`
441445
- `__clear__(<self>) -> ()`
442446
443-
> Note: `__traverse__` does not work with [`#[pyo3(warn(...))]`](../function.md#warn).
447+
> [!NOTE]
448+
> `__traverse__` does not work with [`#[pyo3(warn(...))]`](../function.md#warn).
444449
445450
Example:
446451
@@ -471,7 +476,8 @@ impl ClassWithGCSupport {
471476
Usually, an implementation of `__traverse__` should do nothing but calls to `visit.call`.
472477
Most importantly, safe access to the interpreter is prohibited inside implementations of `__traverse__`, i.e. `Python::attach` will panic.
473478

474-
> Note: these methods are part of the C API, PyPy does not necessarily honor them. If you are building for PyPy you should measure memory consumption to make sure you do not have runaway memory growth. See [this issue on the PyPy bug tracker](https://github.com/pypy/pypy/issues/3848).
479+
> [!NOTE]
480+
> These methods are part of the C API, PyPy does not necessarily honor them. If you are building for PyPy you should measure memory consumption to make sure you do not have runaway memory growth. See [this issue on the PyPy bug tracker](https://github.com/pypy/pypy/issues/3848).
475481
476482
[`PySequence`]: {{#PYO3_DOCS_URL}}/pyo3/types/struct.PySequence.html
477483
<!-- rumdl-disable-next-line MD053 - false positive -->

guide/src/faq.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ Some ways to achieve this are:
219219
If the wrong DLL is linked it is possible that this happened because another program added itself and its own Python DLLs to `PATH`.
220220
Rearrange your `PATH` variables to give the correct DLL priority.
221221

222-
> **Note**: Changes to `PATH` (or any other environment variable) are not visible to existing shells. Restart it for changes to take effect.
222+
> [!NOTE]
223+
> Changes to `PATH` (or any other environment variable) are not visible to existing shells. Restart it for changes to take effect.
223224
224225
For advanced troubleshooting, [Dependency Walker](https://www.dependencywalker.com/) can be used to diagnose linking errors.

guide/src/features.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ It also provides the `py_run!` macro.
9191
These macros require a number of dependencies which may not be needed by users who just need PyO3 for Python FFI.
9292
Disabling this feature enables faster builds for those users, as these dependencies will not be built if this feature is disabled.
9393

94+
> [!NOTE]
9495
> This feature is enabled by default. To disable it, set `default-features = false` for the `pyo3` entry in your Cargo.toml.
9596
9697
### `multiple-pymethods`

guide/src/function/signature.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ num=-1 (was previously=44), py_args=(), name=World, py_kwargs=None
114114
num=44
115115
```
116116

117-
> Note: to use keywords like `struct` as a function argument, use "raw identifier" syntax `r#struct` in both the signature and the function definition:
117+
> [!NOTE]
118+
> To use keywords like `struct` as a function argument, use "raw identifier" syntax `r#struct` in both the signature and the function definition:
118119
>
119120
> ```rust,no_run
120121
> # #![allow(dead_code)]

0 commit comments

Comments
 (0)