Skip to content

Commit

Permalink
Add language selection for docs, and Add UI py typer
Browse files Browse the repository at this point in the history
  • Loading branch information
KaniKim committed Jan 10, 2023
1 parent 7b3148c commit df84ec2
Show file tree
Hide file tree
Showing 161 changed files with 1,068 additions and 605 deletions.
Empty file added docs/en/data/external_links.yml
Empty file.
Empty file.
Empty file added docs/en/data/people.yml
Empty file.
Empty file added docs/en/data/sponsors.yml
Empty file.
Empty file added docs/en/data/sponsors_badge.yml
Empty file.
12 changes: 6 additions & 6 deletions docs/advanced/decimal.md → docs/en/docs/advanced/decimal.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ When you use `condecimal()` you can specify the number of digits and decimal pla
Let's say that each hero in the database will have an amount of money. We could make that field a `Decimal` type using the `condecimal()` function:

```{.python .annotate hl_lines="12" }
{!./docs_src/advanced/decimal/tutorial001.py[ln:1-12]!}
{!../../docs_src/advanced/decimal/tutorial001.py[ln:1-12]!}
# More code here later 👇
```
Expand All @@ -45,7 +45,7 @@ Let's say that each hero in the database will have an amount of money. We could
<summary>👀 Full file preview</summary>

```Python
{!./docs_src/advanced/decimal/tutorial001.py!}
{!../../docs_src/advanced/decimal/tutorial001.py!}
```

</details>
Expand Down Expand Up @@ -82,7 +82,7 @@ When creating new models you can actually pass normal (`float`) numbers, Pydanti
```Python hl_lines="4-6"
# Code above omitted 👆

{!./docs_src/advanced/decimal/tutorial001.py[ln:25-35]!}
{!../../docs_src/advanced/decimal/tutorial001.py[ln:25-35]!}

# Code below omitted 👇
```
Expand All @@ -91,7 +91,7 @@ When creating new models you can actually pass normal (`float`) numbers, Pydanti
<summary>👀 Full file preview</summary>

```Python
{!./docs_src/advanced/decimal/tutorial001.py!}
{!../../docs_src/advanced/decimal/tutorial001.py!}
```

</details>
Expand All @@ -103,7 +103,7 @@ Then, when working with Decimal types, you can confirm that they indeed avoid th
```Python hl_lines="15-16"
# Code above omitted 👆

{!./docs_src/advanced/decimal/tutorial001.py[ln:38-51]!}
{!../../docs_src/advanced/decimal/tutorial001.py[ln:38-51]!}

# Code below omitted 👇
```
Expand All @@ -112,7 +112,7 @@ Then, when working with Decimal types, you can confirm that they indeed avoid th
<summary>👀 Full file preview</summary>

```Python
{!./docs_src/advanced/decimal/tutorial001.py!}
{!../../docs_src/advanced/decimal/tutorial001.py!}
```

</details>
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/contributing.md → docs/en/docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Many of the tutorials have blocks of code.

In most of the cases, these blocks of code are actual complete applications that can be run as is.

In fact, those blocks of code are not written inside the Markdown, they are Python files in the `./docs_src/` directory.
In fact, those blocks of code are not written inside the Markdown, they are Python files in the `../../docs_src/` directory.

And those Python files are included/injected in the documentation when generating the site.

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ But the same `id` field actually **can be `None`** in the Python code, so we dec
```Python hl_lines="4"
# Code above omitted 👆

{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:6-10]!}
{!../../docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:6-10]!}

# Code below omitted 👇
```
Expand All @@ -18,7 +18,7 @@ But the same `id` field actually **can be `None`** in the Python code, so we dec
<summary>👀 Full file preview</summary>

```Python
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py!}
{!../../docs_src/tutorial/automatic_id_none_refresh/tutorial001.py!}
```

</details>
Expand All @@ -34,7 +34,7 @@ When we create a new `Hero` instance, we don't set the `id`:
```Python hl_lines="3-6"
# Code above omitted 👆

{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:23-26]!}
{!../../docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:23-26]!}

# Code below ommitted 👇
```
Expand All @@ -43,7 +43,7 @@ When we create a new `Hero` instance, we don't set the `id`:
<summary>👀 Full file preview</summary>

```Python
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py!}
{!../../docs_src/tutorial/automatic_id_none_refresh/tutorial001.py!}
```

</details>
Expand Down Expand Up @@ -77,7 +77,7 @@ We can confirm that by printing our heroes before adding them to the database:
```Python hl_lines="9-11"
# Code above omitted 👆

{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:23-31]!}
{!../../docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:23-31]!}

# Code below omitted 👇
```
Expand All @@ -86,7 +86,7 @@ We can confirm that by printing our heroes before adding them to the database:
<summary>👀 Full file preview</summary>

```Python
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py!}
{!../../docs_src/tutorial/automatic_id_none_refresh/tutorial001.py!}
```

</details>
Expand Down Expand Up @@ -123,7 +123,7 @@ We can verify by creating a session using a `with` block and adding the objects.
```Python hl_lines="19-21"
# Code above omitted 👆

{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:23-41]!}
{!../../docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:23-41]!}

# Code below ommitted 👇
```
Expand All @@ -132,7 +132,7 @@ We can verify by creating a session using a `with` block and adding the objects.
<summary>👀 Full file preview</summary>

```Python
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py!}
{!../../docs_src/tutorial/automatic_id_none_refresh/tutorial001.py!}
```

</details>
Expand Down Expand Up @@ -163,7 +163,7 @@ Then we can `commit` the changes in the session, and print again:
```Python hl_lines="13 16-18"
# Code above omitted 👆

{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:33-48]!}
{!../../docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:33-48]!}

# Code below omitted 👇
```
Expand All @@ -172,7 +172,7 @@ Then we can `commit` the changes in the session, and print again:
<summary>👀 Full file preview</summary>

```Python
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py!}
{!../../docs_src/tutorial/automatic_id_none_refresh/tutorial001.py!}
```

</details>
Expand Down Expand Up @@ -236,7 +236,7 @@ To confirm and understand how this **automatic expiration and refresh** of data
```Python hl_lines="21-23 26-28"
# Code above omitted 👆

{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:33-58]!}
{!../../docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:33-58]!}

# Code below ommitted 👇
```
Expand All @@ -245,7 +245,7 @@ To confirm and understand how this **automatic expiration and refresh** of data
<summary>👀 Full file preview</summary>

```Python
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py!}
{!../../docs_src/tutorial/automatic_id_none_refresh/tutorial001.py!}
```

</details>
Expand Down Expand Up @@ -333,7 +333,7 @@ You can do that too with `session.refresh(object)`:
```Python hl_lines="30-32 35-37"
# Code above omitted 👆

{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:33-67]!}
{!../../docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:33-67]!}

# Code below ommitted 👇
```
Expand All @@ -342,7 +342,7 @@ You can do that too with `session.refresh(object)`:
<summary>👀 Full file preview</summary>

```Python
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py!}
{!../../docs_src/tutorial/automatic_id_none_refresh/tutorial001.py!}
```

</details>
Expand Down Expand Up @@ -406,7 +406,7 @@ There are no surprises here, it still works:
```Python hl_lines="40-42"
# Code above omitted 👆

{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:33-72]!}
{!../../docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:33-72]!}

# Code below omitted 👇
```
Expand All @@ -415,7 +415,7 @@ There are no surprises here, it still works:
<summary>👀 Full file preview</summary>

```Python
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py!}
{!../../docs_src/tutorial/automatic_id_none_refresh/tutorial001.py!}
```

</details>
Expand Down Expand Up @@ -451,10 +451,10 @@ Now let's review all this code once again.
And as we created the **engine** with `echo=True`, we can see the SQL statements being executed at each step.

```{ .python .annotate }
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial002.py!}
{!../../docs_src/tutorial/automatic_id_none_refresh/tutorial002.py!}
```

{!./docs_src/tutorial/automatic_id_none_refresh/annotations/en/tutorial002.md!}
{!../../docs_src/tutorial/automatic_id_none_refresh/annotations/en/tutorial002.md!}

And here's all the output generated by running this program, all together:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ We can use these relative imports because, for example, in the file `app.py` (th
You could put all the database Models in a single Python module (a single Python file), for example `models.py`:

```Python
{!./docs_src/tutorial/code_structure/tutorial001/models.py!}
{!../../docs_src/tutorial/code_structure/tutorial001/models.py!}
```

This way, you wouldn't have to deal with circular imports for other models.
Expand All @@ -80,7 +80,7 @@ And then you could import the models from this file/module in any other file/mod
Then you could put the code creating the **engine** and the function to create all the tables (if you are not using migrations) in another file `database.py`:

```Python
{!./docs_src/tutorial/code_structure/tutorial001/database.py!}
{!../../docs_src/tutorial/code_structure/tutorial001/database.py!}
```

This file would also be imported by your application code, to use the shared **engine** and to get and call the function `create_db_and_tables()`.
Expand All @@ -90,7 +90,7 @@ This file would also be imported by your application code, to use the shared **e
Finally, you could put the code to create the **app** in another file `app.py`:

```Python hl_lines="3-4"
{!./docs_src/tutorial/code_structure/tutorial001/app.py!}
{!../../docs_src/tutorial/code_structure/tutorial001/app.py!}
```

Here we import the models, the engine, and the function to create all the tables and then we can use them all internally.
Expand Down Expand Up @@ -205,7 +205,7 @@ So, we can use it in an `if` block and import things inside the `if` block. And
Using that trick of `TYPE_CHECKING` we can "import" the `Team` in `hero_model.py`:

```Python hl_lines="1 5-6 16"
{!./docs_src/tutorial/code_structure/tutorial002/hero_model.py!}
{!../../docs_src/tutorial/code_structure/tutorial002/hero_model.py!}
```

Have in mind that now we *have* to put the annotation of `Team` as a string: `"Team"`, so that Python doesn't have errors at runtime.
Expand All @@ -215,7 +215,7 @@ Have in mind that now we *have* to put the annotation of `Team` as a string: `"T
We use the same trick in the `team_model.py` file:

```Python hl_lines="1 5-6 14"
{!./docs_src/tutorial/code_structure/tutorial002/team_model.py!}
{!../../docs_src/tutorial/code_structure/tutorial002/team_model.py!}
```

Now we get editor support, autocompletion, inline errors, and **SQLModel** keeps working. 🎉
Expand All @@ -225,7 +225,7 @@ Now we get editor support, autocompletion, inline errors, and **SQLModel** keeps
Now, just for completeness, the `app.py` file would import the models from both modules:

```Python hl_lines="4-5 10 12-14"
{!./docs_src/tutorial/code_structure/tutorial002/app.py!}
{!../../docs_src/tutorial/code_structure/tutorial002/app.py!}
```

And of course, all the tricks with `TYPE_CHECKING` and type annotations in strings are **only needed in the files with circular imports**.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ We will continue with the code in the previous example and we will add more thin
<summary>👀 Full file preview</summary>

```Python
{!./docs_src/tutorial/connect/create_tables/tutorial001.py!}
{!../../docs_src/tutorial/connect/create_tables/tutorial001.py!}
```

</details>
Expand All @@ -64,7 +64,7 @@ Let's start by creating two teams:
```Python hl_lines="3-9"
# Code above omitted 👆

{!./docs_src/tutorial/connect/insert/tutorial001.py[ln:31-37]!}
{!../../docs_src/tutorial/connect/insert/tutorial001.py[ln:31-37]!}

# Code below omitted 👇
```
Expand All @@ -73,7 +73,7 @@ Let's start by creating two teams:
<summary>👀 Full file preview</summary>

```Python
{!./docs_src/tutorial/connect/insert/tutorial001.py!}
{!../../docs_src/tutorial/connect/insert/tutorial001.py!}
```

</details>
Expand All @@ -95,7 +95,7 @@ Let's not forget to add this function `create_heroes()` to the `main()` function
```Python hl_lines="5"
# Code above omitted 👆

{!./docs_src/tutorial/connect/insert/tutorial001.py[ln:63-65]!}
{!../../docs_src/tutorial/connect/insert/tutorial001.py[ln:63-65]!}

# Code below omitted 👇
```
Expand All @@ -104,7 +104,7 @@ Let's not forget to add this function `create_heroes()` to the `main()` function
<summary>👀 Full file preview</summary>

```Python
{!./docs_src/tutorial/connect/insert/tutorial001.py!}
{!../../docs_src/tutorial/connect/insert/tutorial001.py!}
```

</details>
Expand Down Expand Up @@ -143,7 +143,7 @@ As the `Hero` class model now has a field (column, attribute) `team_id`, we can
```Python hl_lines="12"
# Code above omitted 👆

{!./docs_src/tutorial/connect/insert/tutorial001.py[ln:31-41]!}
{!../../docs_src/tutorial/connect/insert/tutorial001.py[ln:31-41]!}

# Code below omitted 👇
```
Expand All @@ -152,7 +152,7 @@ As the `Hero` class model now has a field (column, attribute) `team_id`, we can
<summary>👀 Full file preview</summary>

```Python
{!./docs_src/tutorial/connect/insert/tutorial001.py!}
{!../../docs_src/tutorial/connect/insert/tutorial001.py!}
```

</details>
Expand Down Expand Up @@ -182,7 +182,7 @@ Let's now create two more heroes:
```Python hl_lines="14-20"
# Code above omitted 👆

{!./docs_src/tutorial/connect/insert/tutorial001.py[ln:31-52]!}
{!../../docs_src/tutorial/connect/insert/tutorial001.py[ln:31-52]!}

# Code below omitted 👇
```
Expand All @@ -191,7 +191,7 @@ Let's now create two more heroes:
<summary>👀 Full file preview</summary>

```Python
{!./docs_src/tutorial/connect/insert/tutorial001.py!}
{!../../docs_src/tutorial/connect/insert/tutorial001.py!}
```

</details>
Expand Down Expand Up @@ -228,7 +228,7 @@ Now let's refresh and print those new heroes to see their new ID pointing to the
```Python hl_lines="26-28 30-32"
# Code above omitted 👆

{!./docs_src/tutorial/connect/insert/tutorial001.py[ln:31-60]!}
{!../../docs_src/tutorial/connect/insert/tutorial001.py[ln:31-60]!}

# Code below omitted 👇
```
Expand All @@ -237,7 +237,7 @@ Now let's refresh and print those new heroes to see their new ID pointing to the
<summary>👀 Full file preview</summary>

```Python
{!./docs_src/tutorial/connect/insert/tutorial001.py!}
{!../../docs_src/tutorial/connect/insert/tutorial001.py!}
```

</details>
Expand Down
Loading

0 comments on commit df84ec2

Please sign in to comment.