FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

๐Ÿ“ Add docs ยท feanil/sqlmodel@6d1d86a ยท GitHub

Repository navigation

Commit 6d1d86a

Browse files
committed
๐Ÿ“ Add docs
1 parent 29017c6 commit 6d1d86a

51 files changed

Lines changed: 12260 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

โ€Ždocs/advanced/index.mdโ€Ž

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Advanced User Guide
2+
3+
The **Advanced User Guide** will be coming soon to a <del>theater</del> **documentation** near you... ๐Ÿ˜…
4+
5+
I just have to `add` it, `commit` it, and `refresh` it. ๐Ÿ˜‰
6+
7+
It will include:
8+
9+
* How to use the `async` and `await` with the async session.
10+
* How to run migrations.
11+
* How to combine **SQLModel** models with SQLAlchemy.
12+
* ...and more.

โ€Ždocs/alternatives.mdโ€Ž

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Alternatives, Inspiration and Comparisons
2+
3+
Coming soon...

โ€Ždocs/contributing.mdโ€Ž

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# Contributing
2+
3+
First, you might want to see the basic ways to [help SQLModel and get help](help.md){.internal-link target=_blank}.
4+
5+
## Developing
6+
7+
If you already cloned the repository and you know that you need to deep dive in the code, here are some guidelines to set up your environment.
8+
9+
### Python
10+
11+
SQLModel supports Python 3.6 and above, but for development you should have at least **Python 3.7**.
12+
13+
### Poetry
14+
15+
**SQLModel** uses <a href="https://python-poetry.org/" class="external-link" target="_blank">Poetry</a> to build, package, and publish the project.
16+
17+
You can learn how to install it in the <a href="https://python-poetry.org/docs/#installation" class="external-link" target="_blank">Poetry docs</a>.
18+
19+
After having Poetry available, you can install the development dependencies:
20+
21+
<div class="termy">
22+
23+
```console
24+
$ poetry install
25+
26+
---> 100%
27+
```
28+
29+
</div>
30+
31+
It will also create a virtual environment automatically and will install all the dependencies and your local SQLModel in it.
32+
33+
### Poetry Shell
34+
35+
To use your current environment, and to have access to all the tools in it (for example `pytest` for the tests) enter into a Poetry Shell:
36+
37+
<div class="termy">
38+
39+
```console
40+
$ poetry shell
41+
```
42+
43+
</div>
44+
45+
That will set up the environment variables needed dand will start a new shell with them.
46+
47+
#### Using your local SQLModel
48+
49+
If you create a Python file that imports and uses SQLModel, and run it with the Python from your local Poetry environment, it will use your local SQLModel source code.
50+
51+
And if you update that local SQLModel source code, when you run that Python file again, it will use the fresh version of SQLModel you just edited.
52+
53+
Poetry takes care of making that work. But of course, it will only work in the current Poetry environment, if you install standard SQLModel in another environment (not from the source in the GitHub repo), that will use the standard SQLModel, not your custom version.
54+
55+
### Format
56+
57+
There is a script that you can run that will format and clean all your code:
58+
59+
<div class="termy">
60+
61+
```console
62+
$ bash scripts/format.sh
63+
```
64+
65+
</div>
66+
67+
It will also auto-sort all your imports.
68+
69+
### Format imports
70+
71+
There is another script that formats all the imports and makes sure you don't have unused imports:
72+
73+
<div class="termy">
74+
75+
```console
76+
$ bash scripts/format-imports.sh
77+
```
78+
79+
</div>
80+
81+
As it runs one command after the other and modifies and reverts many files, it takes a bit longer to run, so it might be easier to use `scripts/format.sh` frequently and `scripts/format-imports.sh` only before committing.
82+
83+
## Docs
84+
85+
The documentation uses <a href="https://www.mkdocs.org/" class="external-link" target="_blank">MkDocs</a> with <a href="https://squidfunk.github.io/mkdocs-material/" class="external-link" target="_blank">Material for MkDocs</a>.
86+
87+
All the documentation is in Markdown format in the directory `./docs`.
88+
89+
Many of the tutorials have blocks of code.
90+
91+
In most of the cases, these blocks of code are actual complete applications that can be run as is.
92+
93+
In fact, those blocks of code are not written inside the Markdown, they are Python files in the `./docs_src/` directory.
94+
95+
And those Python files are included/injected in the documentation when generating the site.
96+
97+
### Docs for tests
98+
99+
Most of the tests actually run against the example source files in the documentation.
100+
101+
This helps making sure that:
102+
103+
* The documentation is up to date.
104+
* The documentation examples can be run as is.
105+
* Most of the features are covered by the documentation, ensured by test coverage.
106+
107+
During local development, there is a script that builds the site and checks for any changes, live-reloading:
108+
109+
<div class="termy">
110+
111+
```console
112+
$ bash scripts/docs-live.sh
113+
114+
<span style="color: green;">[INFO]</span> - Building documentation...
115+
<span style="color: green;">[INFO]</span> - Cleaning site directory
116+
<span style="color: green;">[INFO]</span> - Documentation built in 2.74 seconds
117+
<span style="color: green;">[INFO]</span> - Serving on http://127.0.0.1:8008
118+
```
119+
120+
</div>
121+
122+
It will serve the documentation on `http://127.0.0.1:8008`.
123+
124+
That way, you can edit the documentation/source files and see the changes live.
125+
126+
## Tests
127+
128+
There is a script that you can run locally to test all the code and generate coverage reports in HTML:
129+
130+
<div class="termy">
131+
132+
```console
133+
$ bash scripts/test-cov-html.sh
134+
```
135+
136+
</div>
137+
138+
This command generates a directory `./htmlcov/`, if you open the file `./htmlcov/index.html` in your browser, you can explore interactively the regions of code that are covered by the tests, and notice if there is any region missing.
139+
140+
## Thanks
141+
142+
Thanks for contributing! โ˜•

0 commit comments

Comments
ย (0)

Back | FazBrowse Home | New Git URL