Skip to content

Commit bf9c215

Browse files
authored
Attempt to fix docs (#303)
* Attempt to fix docs * Fix typo in docs * Fix another typo * Update docs so nav would work properly
1 parent cac20da commit bf9c215

File tree

7 files changed

+306
-10
lines changed

7 files changed

+306
-10
lines changed

.gitignore

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ venv/
77
.venv/
88
env3*/
99

10-
# Repo files that copied into docs
11-
docs/index.md
12-
docs/release-notes.md
13-
docs/contributing.md
14-
1510
# Byte-compiled / optimized / DLL files
1611
__pycache__/
1712
*.py[cod]

docs/contributing.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
First, you might want to see the basic ways to [help and get help](help-fastapi-utils.md){.internal-link target=_blank}.
2+
3+
## Developing
4+
5+
Once you've cloned the repository, here are some guidelines to set up your environment:
6+
7+
### Set up the development evironment
8+
9+
After cloning the repository, you can use `poetry` to create a virtual environment:
10+
11+
```console
12+
$ make develop
13+
```
14+
15+
Behind the scenes, this checks that you have python3 and poetry installed,
16+
then creates a virtual environment and installs the dependencies. At the end, it will print out
17+
the path to the executable in case you want to add it to your IDE.
18+
19+
20+
### Activate the environment
21+
22+
Once the virtual environment is created, you can activate it with:
23+
24+
```console
25+
$ poetry shell
26+
```
27+
28+
To check if this worked, try running:
29+
30+
```console
31+
$ which python
32+
33+
some/directory/fastapi-utils-SOMETHING-py3.X/bin/python
34+
```
35+
36+
If the output of this command shows the `python` binary in a path containing `fastapi-utils` somewhere in the name
37+
(as above), then it worked! 🎉
38+
39+
!!! tip
40+
Every time you install a new package with `pip` under that environment, activate the environment again.
41+
42+
This makes sure that if you use a terminal program installed by that package (like `mypy`),
43+
you use the one from your local environment and not any other that could be installed globally.
44+
45+
### Static Code Checks
46+
47+
This project makes use of `black`, `autoflake8`, and `isort` for formatting,
48+
`flake8` for linting, and `mypy` for static type checking.
49+
50+
51+
To auto-format your code, just run:
52+
53+
```console
54+
$ make format
55+
```
56+
57+
It will also auto-sort all your imports, and attempt to remove any unused imports.
58+
59+
You can run flake8 with:
60+
61+
```console
62+
$ make lint
63+
```
64+
65+
and you can run mypy with:
66+
67+
```console
68+
$ make mypy
69+
```
70+
71+
There are a number of other useful makefile recipes; you can see basic documentation of these by calling plain `make`:
72+
73+
```console
74+
$ make
75+
```
76+
77+
78+
## Docs
79+
80+
The documentation uses <a href="https://www.mkdocs.org/" class="external-link" target="_blank">MkDocs</a>.
81+
82+
All the documentation is in Markdown format in the directory `./docs`.
83+
84+
Many of the sections in the User Guide have blocks of code.
85+
86+
In fact, those blocks of code are not written inside the Markdown, they are Python files in the `./docs/src/` directory.
87+
88+
And those Python files are included/injected in the documentation when generating the site.
89+
90+
### Docs for tests
91+
92+
Most of the tests actually run against the example source files in the documentation.
93+
94+
This helps making sure that:
95+
96+
* The documentation is up to date.
97+
* The documentation examples can be run as is.
98+
* Most of the features are covered by the documentation, ensured by test coverage.
99+
100+
During local development, there is a script that builds the site and checks for any changes, live-reloading:
101+
102+
```console
103+
$ bash scripts/docs-live.sh
104+
```
105+
106+
It will serve the documentation on `http://0.0.0.0:8008`.
107+
108+
That way, you can edit the documentation/source files and see the changes live.
109+
110+
## Tests
111+
112+
You can run all tests via:
113+
114+
```console
115+
$ make test
116+
```
117+
118+
You can also generate a coverage report with:
119+
120+
```console
121+
make testcov
122+
```
123+
124+
On MacOS, if the tests all pass, the coverage report will be opened directly in a browser; on other operating systems
125+
a link will be printed to the local HTML containing the coverage report.
126+
127+
### Tests in your editor
128+
129+
If you want to use the integrated tests in your editor add `./docs/src` to your `PYTHONPATH` variable.
130+
131+
For example, in VS Code you can create a file `.env` with:
132+
133+
```env
134+
PYTHONPATH=./docs/src
135+
```

docs/help-fastapi-restful.md renamed to docs/help-fastapi-utils.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ You can connect with the maintainer on
3131

3232
## Create issues
3333

34-
You can <a href="https://github.com/dmontagu/fastapis-utils/issues/new/choose" class="external-link" target="_blank">create a new issue</a> in the GitHub repository, for example to:
34+
You can <a href="https://github.com/dmontagu/fastapi-utils/issues/new/choose" class="external-link" target="_blank">create a new issue</a> in the GitHub repository, for example to:
3535

3636
* Report a bug/issue.
3737
* Suggest a new feature.

docs/index.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<p align="center">
2+
<em>Quicker FastApi developing tools</em>
3+
</p>
4+
<p align="center">
5+
<a href="https://github.com/dmontagu/fastapi-utils" target="_blank">
6+
<img src="https://img.shields.io/github/last-commit/dmontagu/fastapi-utils.svg">
7+
<img src="https://github.com/dmontagu/fastapi-utils/workflows/build/badge.svg" alt="Build CI">
8+
</a>
9+
<a href="https://codecov.io/gh/dmontagu/fastapi-utils" target="_blank">
10+
<img src="https://codecov.io/gh/dmontagu/fastapi-utils/branch/master/graph/badge.svg" alt="Coverage">
11+
</a>
12+
<br />
13+
<a href="https://pypi.org/project/fastapi-utils" target="_blank">
14+
<img src="https://badge.fury.io/py/fastapi-utils.svg" alt="Package version">
15+
</a>
16+
<a href="https://github.com/dmontagu/fastapi-utils" target="_blank">
17+
<img src="https://img.shields.io/pypi/pyversions/fastapi-utils.svg" alt="Python versions">
18+
<img src="https://img.shields.io/github/license/dmontagu/fastapi-utils.svg" alt="License">
19+
</a>
20+
</p>
21+
22+
---
23+
**Documentation**: <a href="https://fastapi-utils.davidmontague.xyz" target="_blank">https://fastapi-utils.davidmontague.xyz</a>
24+
25+
**Source Code**: <a href="https://github.com/dmontagu/fastapi-utils" target="_blank">https://github.com/dmontagu/fastapi-utils</a>
26+
27+
---
28+
29+
<a href="https://fastapi.tiangolo.com">FastAPI</a> is a modern, fast web framework for building APIs with Python 3.7+.
30+
31+
But if you're here, you probably already knew that!
32+
33+
---
34+
35+
## Features
36+
37+
This package includes a number of utilities to help reduce boilerplate and reuse common functionality across projects:
38+
39+
* **Resource Class**: Create CRUD with ease the OOP way with `Resource` base class that lets you implement methods quick.
40+
* **Class Based Views**: Stop repeating the same dependencies over and over in the signature of related endpoints.
41+
* **Repeated Tasks**: Easily trigger periodic tasks on server startup
42+
* **Timing Middleware**: Log basic timing information for every request
43+
* **OpenAPI Spec Simplification**: Simplify your OpenAPI Operation IDs for cleaner output from OpenAPI Generator
44+
* **SQLAlchemy Sessions**: The `FastAPISessionMaker` class provides an easily-customized SQLAlchemy Session dependency
45+
46+
---
47+
48+
It also adds a variety of more basic utilities that are useful across a wide variety of projects:
49+
50+
* **APIModel**: A reusable `pydantic.BaseModel`-derived base class with useful defaults
51+
* **APISettings**: A subclass of `pydantic.BaseSettings` that makes it easy to configure FastAPI through environment variables
52+
* **String-Valued Enums**: The `StrEnum` and `CamelStrEnum` classes make string-valued enums easier to maintain
53+
* **CamelCase Conversions**: Convenience functions for converting strings from `snake_case` to `camelCase` or `PascalCase` and back
54+
* **GUID Type**: The provided GUID type makes it easy to use UUIDs as the primary keys for your database tables
55+
56+
See the [docs](https://https://fastapi-utils.davidmontague.xyz/) for more details and examples.
57+
58+
## Requirements
59+
60+
This package is intended for use with any recent version of FastAPI (depending on `pydantic>=1.0`), and Python 3.7+.
61+
62+
## Installation
63+
64+
```bash
65+
pip install fastapi-restful # For basic slim package :)
66+
67+
pip install fastapi-restful[session] # To add sqlalchemy session maker
68+
69+
pip install fastapi-restful[all] # For all the packages
70+
```
71+
72+
## License
73+
74+
This project is licensed under the terms of the MIT license.

docs/release-notes.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
## Latest changes
2+
3+
* Merge with [fastapi-utils](https://github.com/dmontagu/fastapi-utils)
4+
5+
## 0.6.0
6+
7+
* Fix bug where `Request.url_for` is not working as intended [[yuval9313/FastApi-RESTful#90](https://github.com/yuval9313/FastApi-RESTful/issues/90)]
8+
* Update multiple dependencies using @dependebot
9+
* Fix `repeat_every` is only running once [#142](https://github.com/yuval9313/FastApi-RESTful/pull/142)
10+
11+
## 0.5.0
12+
13+
* Bump sqlalchemy from 1.4.48 to 2.0.19 by @dependabot in #202
14+
* Pydantic v2 by @ollz272 in [#199](https://github.com/yuval9313/FastApi-RESTful/pull/199)
15+
* fix ci not run by @ollz272 in [#208](https://github.com/yuval9313/FastApi-RESTful/pull/208)
16+
17+
## 0.4.5
18+
19+
* Change the lock of fastapi to enable more versions of it to be installed
20+
21+
## 0.4.4
22+
23+
* Move to ruff for linting, etc.
24+
* Update various dependencies
25+
* Stop supporting Python 3.6
26+
* Deprecate InferringRouter (as its functionality is now built into `fastapi.APIRouter`)
27+
* Resolve various deprecationwarnings introduced by sqlalchemy 1.4.
28+
* Add support to Python 3.11
29+
* Change package description to avoid errors with pypi as [mentioned here](https://github.com/yuval9313/FastApi-RESTful/issues/175)
30+
31+
## 0.4.3
32+
33+
* Fix bug where inferred router raises exception when no content is needed but type hint is provided (e.g. `None` as return type with status code 204) (As mentiond in [#134](https://github.com/yuval9313/FastApi-RESTful/pull/134))
34+
* Improve tests and add more test cases
35+
* Bump dependencies versions
36+
37+
## 0.4.2
38+
39+
* Remove version pinning to allow diversity in python environments
40+
41+
## 0.4.1
42+
43+
* Add more pypi classifiers
44+
45+
## 0.4.0
46+
47+
** Breaking change **
48+
* Remove support to python < 3.6.2
49+
50+
Additionals:
51+
* Multiple version bumps
52+
* Add usage of **kwargs for to allow more options when including new router
53+
54+
## 0.3.1
55+
56+
* [CVE-2021-29510](https://github.com/samuelcolvin/pydantic/security/advisories/GHSA-5jqp-qgf6-3pvh) fix of pydantic - update is required
57+
* Made sqlalchemy as extras installs
58+
59+
## 0.3.0
60+
61+
* Add support for Python 3.9 :)
62+
* Fix case of duplicate routes when cbv used with prefix. (As mentioned in [#36](https://github.com/yuval9313/FastApi-RESTful/pull/36))
63+
* Made repeatable task pre activate (`wait_first`) to be float instead of boolean (Mentioned here [#45](https://github.com/yuval9313/FastApi-RESTful/pull/45))
64+
65+
## 0.2.4.1
66+
67+
* Another docs fix
68+
* Rename package folder to small casing to ease imports
69+
70+
## 0.2.4
71+
72+
* Mostly docs fixes
73+
74+
## 0.2.2
75+
76+
* Add `Resorce` classes for more OOP like designing
77+
* Methods are now can be used as class names
78+
79+
## 0.2.1
80+
81+
* Fix bug with multiple decorators on same method
82+
83+
## 0.2.0
84+
85+
* Make some of the functions/classes in `fastapi_utils.timing` private to clarify the intended public API
86+
* Add documentation for `fastapi_utils.timing` module
87+
* Fix bug with ordering of routes in a CBV router
88+
89+
## 0.1.1
90+
91+
* Add source docstrings for most functions.
92+
93+
## 0.1.0
94+
95+
* Initial release.

docs/user-guide/basics/enums.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class MyEnum(str, Enum):
2525
One nuisance with this approach is that if you rename one of the enum values (for example, using an IDE),
2626
you can end up with the name and value differing, which may lead to confusing errors.
2727

28-
For example, if you refactored the above as follows (forgetting to çhange the associated values), you'll get
28+
For example, if you refactored the above as follows (forgetting to change the associated values), you'll get
2929
pydantic parsing errors if you use the new *names* instead of the values in JSON bodies:
3030

3131
```python

docs/user-guide/class-based-views.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ The highlighted lines above show the results of performing each of the numbered
4848
Note how the signature of each endpoint definition now includes only the parts specific
4949
to that endpoint.
5050

51-
(Also note that we've also used the [`InferringRouter`](inferring-router.md){.internal-link target=_blank}
52-
here to remove the need to specify a `response_model` in the endpoint decorators.)
53-
5451
Hopefully this helps you to better reuse dependencies across endpoints!
5552

5653
!!! info

0 commit comments

Comments
 (0)