📝 Update details syntax with new pymdown extensions format (#713)

This commit is contained in:
Sebastián Ramírez
2023-11-28 23:12:33 +01:00
committed by GitHub
parent be464fba69
commit 799d0aa7a6
37 changed files with 409 additions and 614 deletions

View File

@@ -26,14 +26,13 @@ Let's see how that works by writing an **incomplete** version first, without `ba
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/relationship_attributes/back_populates/tutorial001.py!}
```
</details>
///
## Read Data Objects
@@ -49,14 +48,13 @@ As you already know how this works, I won't separate that in a select `statement
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/relationship_attributes/back_populates/tutorial001.py!}
```
</details>
///
/// tip
@@ -76,14 +74,13 @@ Now, let's print the current **Spider-Boy**, the current **Preventers** team, an
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/relationship_attributes/back_populates/tutorial001.py!}
```
</details>
///
Up to this point, it's all good. 😊
@@ -117,14 +114,13 @@ Now let's update **Spider-Boy**, removing him from the team by setting `hero_spi
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/relationship_attributes/back_populates/tutorial001.py!}
```
</details>
///
The first important thing is, we *haven't committed* the hero yet, so accessing the list of heroes would not trigger an automatic refresh.
@@ -176,14 +172,13 @@ Now, if we commit it and print again:
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/relationship_attributes/back_populates/tutorial001.py!}
```
</details>
///
When we access `preventers_team.heroes` after the `commit`, that triggers a refresh, so we get the latest list, without **Spider-Boy**, so that's fine again:
@@ -221,14 +216,13 @@ Let's add it back:
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/relationship_attributes/back_populates/tutorial002.py!}
```
</details>
///
And we can keep the rest of the code the same:
@@ -244,14 +238,13 @@ And we can keep the rest of the code the same:
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/relationship_attributes/back_populates/tutorial002.py!}
```
</details>
///
/// tip
@@ -290,14 +283,13 @@ It's quite simple code, it's just a string, but it might be confusing to think e
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/relationship_attributes/back_populates/tutorial002.py!}
```
</details>
///
The string in `back_populates` is the name of the attribute *in the other* model, that will reference *the current* model.
@@ -313,14 +305,13 @@ So, in the class `Team`, we have an attribute `heroes` and we declare it with `R
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/relationship_attributes/back_populates/tutorial002.py!}
```
</details>
///
The string in `back_populates="team"` refers to the attribute `team` in the class `Hero` (the other class).
@@ -336,14 +327,13 @@ So, the string `"heroes"` refers to the attribute `heroes` in the class `Team`.
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/relationship_attributes/back_populates/tutorial002.py!}
```
</details>
///
/// tip
@@ -376,11 +366,10 @@ So, `back_populates` would most probably be something like `"hero"` or `"heroes"
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/relationship_attributes/back_populates/tutorial003.py!}
```
</details>
///

View File

@@ -14,14 +14,13 @@ Let's check the old code we used to create some heroes and teams:
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/connect/insert/tutorial001.py!}
```
</details>
///
There are several things to **notice** here.
@@ -49,14 +48,13 @@ Now let's do all that, but this time using the new, shiny `Relationship` attribu
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/relationship_attributes/define_relationship_attributes/tutorial001.py!}
```
</details>
///
Now we can create the `Team` instances and pass them directly to the new `team` argument when creating the `Hero` instances, as `team=team_preventers` instead of `team_id=team_preventers.id`.
@@ -84,14 +82,13 @@ The same way we could assign an integer with a `team.id` to a `hero.team_id`, we
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/relationship_attributes/create_and_update_relationships/tutorial001.py!}
```
</details>
///
## Create a Team with Heroes
@@ -111,14 +108,13 @@ We could also create the `Hero` instances first, and then pass them in the `hero
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/relationship_attributes/create_and_update_relationships/tutorial001.py!}
```
</details>
///
Here we create two heroes first, **Black Lion** and **Princess Sure-E**, and then we pass them in the `heroes` argument.
@@ -146,14 +142,13 @@ Let's create some more heroes and add them to the `team_preventers.heroes` list
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/relationship_attributes/create_and_update_relationships/tutorial001.py!}
```
</details>
///
The attribute `team_preventers.heroes` behaves like a list. But it's a special type of list, because when we modify it adding heroes to it, **SQLModel** (actually SQLAlchemy) **keeps track of the necessary changes** to be done in the database.

View File

@@ -47,14 +47,13 @@ Up to now, we have only used the `team_id` column to connect the tables when que
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/connect/insert/tutorial001.py!}
```
</details>
///
This is a **plain field** like all the others, all representing a **column in the table**.
@@ -68,14 +67,13 @@ First, import `Relationship` from `sqlmodel`:
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/relationship_attributes/define_relationship_attributes/tutorial001.py!}
```
</details>
///
Next, use that `Relationship` to declare a new attribute in the model classes:
@@ -85,14 +83,13 @@ Next, use that `Relationship` to declare a new attribute in the model classes:
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/relationship_attributes/define_relationship_attributes/tutorial001.py!}
```
</details>
///
## What Are These Relationship Attributes

View File

@@ -18,14 +18,13 @@ First, add a function `select_heroes()` where we get a hero to start working wit
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/relationship_attributes/read_relationships/tutorial001.py!}
```
</details>
///
## Select the Related Team - Old Way
@@ -41,14 +40,13 @@ With what we have learned **up to now**, we could use a `select()` statement, th
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/relationship_attributes/read_relationships/tutorial001.py!}
```
</details>
///
## Get Relationship Team - New Way
@@ -68,14 +66,13 @@ So, the highlighted block above, has the same results as the block below:
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/relationship_attributes/read_relationships/tutorial001.py!}
```
</details>
///
/// tip
@@ -97,14 +94,13 @@ And the same way, when we are working on the **many** side of the **one-to-many*
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/relationship_attributes/read_relationships/tutorial002.py!}
```
</details>
///
That would print a list with all the heroes in the Preventers team:

View File

@@ -16,14 +16,13 @@ We can remove the relationship by setting it to `None`, the same as with the `te
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/relationship_attributes/read_relationships/tutorial002.py!}
```
</details>
///
And of course, we should remember to add this `update_heroes()` function to `main()` so that it runs when we call this program from the command line:
@@ -35,14 +34,13 @@ And of course, we should remember to add this `update_heroes()` function to `mai
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/relationship_attributes/read_relationships/tutorial002.py!}
```
</details>
///
## Recap

View File

@@ -8,14 +8,13 @@ In the first Relationship attribute, we declare it with `List["Hero"]`, putting
# Code below omitted 👇
```
<details>
<summary>👀 Full file preview</summary>
/// details | 👀 Full file preview
```Python
{!./docs_src/tutorial/relationship_attributes/define_relationship_attributes/tutorial001.py!}
```
</details>
///
What's that about? Can't we just write it normally as `List[Hero]`?