Python preprocessor example is ignorant of part titles
Problem
I am using mdBook in my Python libary project. The docs have a nice snippet of code for making a preprocessor in Python (thanks for that btw). However, I kept getting a KeyError saying that Chapter is not a valid key in the section. I couldn't even debug this since printing the output of the json would just be eaten by mdBook.
That is until today; instead of running print(book) I ran logging.error(book) which thankfully showed the entire json structure.
The reason for the KeyError was because the first entry was a part title.
Here's a small snippet of the JSON:
{
"sections": [
{"PartTitle": "User Guide"},
{
"Chapter": {
"name": "Introduction",
"content": "stuff",
"number": [1],
"sub_items": [],
"path": "readme.md",
"source_path": "readme.md",
"parent_names": [],
}
},
# more entries
]
}
Proposed Solution
The JSON structure should be mentioned along with the preprocessor snippet.
And this code just doesn't work unless you change the index. https://github.com/rust-lang/mdBook/blob/01778fc90a8909ad8a51571816f2e236d0e13099/guide/src/for_developers/preprocessors.md?plain=1#L118-L119
Notes
No response