Skip to content

Commit e21bae6

Browse files
committed
Merge branch 'docs-rewrite' of https://github.com/ZeroIntensity/view.py into docs-rewrite
2 parents 311f301 + 2a72f89 commit e21bae6

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

CONTRIBUTING.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ If you're stuck, confused, or just don't know what to start with, our [Discord](
88

99
## Getting Started
1010

11-
Assuming you have Git installed, simply clone the repo and install view.py locally:
11+
Assuming you have Git installed, simply clone the repo and install view.py locally (under a virtual environment):
1212

1313
```
1414
$ git clone https://github.com/ZeroIntensity/view.py
1515
$ cd view.py
16+
$ python3 -m venv .venv
17+
$ source .venv/bin/activate
1618
$ pip install .
1719
```
1820

@@ -43,9 +45,12 @@ async def index():
4345
app.run()
4446
```
4547

46-
Note that you do need to `pip install .` to get your changes under the `view` module. However, waiting for pip every time can be a headache. Unless you're modifying the [C API](https://github.com/ZeroIntensity/view.py/tree/master/src/_view), you don't actually need it. Instead, you can test your code via just importing from `src.view`. For example:
48+
Note that you do need to `pip install .` to get your changes under the `view` module. However, waiting for pip every time can be a headache. Unless you're modifying the [C API](https://github.com/ZeroIntensity/view.py/tree/master/src/_view), you don't actually need it. Instead, you can test your code via just importing from `src.view`. A `test.py` file **should not** be inside of the `src/view` folder, but instead outside it (i.e. in the same directory as `src`).
49+
50+
For example, a simple `test.py` could look like:
4751

4852
```py
53+
# test.py
4954
from src.view import new_app
5055

5156
app = new_app()
@@ -57,6 +62,8 @@ async def index():
5762
app.run()
5863
```
5964

65+
**Note:** Import from `view` internally *does not* work when using `src.view`. Instead, your imports inside of view.py should look like `from .foo import bar`. For example, if you wanted to import `view.routing.get` from `src/view/app.py`, your import would look like `from .routing import get`
66+
6067
For debugging purposes, you're also going to want to disable `fancy` and `hijack` in the configuration:
6168

6269
```toml
@@ -65,6 +72,8 @@ fancy = false
6572
hijack = false
6673
```
6774

75+
These settings will stop view.py's fancy output from showing, as well as stopping the hijack of the `uvicorn` logger, and you'll get the raw `uvicorn` output.
76+
6877
## Writing Tests
6978

7079
**Note:** You do need to `pip install .` to update the tests, as they import from `view` and not `src.view`.
@@ -84,7 +93,7 @@ async def _():
8493

8594
async with app.test() as test:
8695
res = await test.get("/")
87-
assert res.test == "test"
96+
assert res.message == "test"
8897
```
8998

9099
In the above code, a server **would not** be started, and instead just virtualized for testing purposes.

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
<div align="center"><img src="https://raw.githubusercontent.com/ZeroIntensity/view.py/master/html/logo.png" alt="view.py logo" width=250 height=auto /></div>
22

3-
## The Batteries-Detachable Web Framework
3+
<div align="center"><h2>The Batteries-Detachable Web Framework</h2></div>
44

55
> [!Warning]
66
> view.py is in very early stages and not yet considered to be ready for production.
77
> If you would like to follow development progress, join [the discord](https://discord.gg/tZAfuWAbm2).
88
> For contributing to view.py, please see our [CONTRIBUTING.md](https://github.com/ZeroIntensity/view.py/blob/master/CONTRIBUTING.md)
99
10+
<div align="center">
11+
<a href="https://clientarea.space-hosting.net/aff.php?aff=303"><img width=250 height=auto src="https://cdn-dennd.nitrocdn.com/fygsTSpFNuiCdXWNTtgOTVMRlPWNnIZx/assets/images/optimized/rev-758b0f8/www.space-hosting.net/wp-content/uploads/2023/02/cropped-Icon.png"></a>
12+
<h3>view.py is affiliated with <a href="https://clientarea.space-hosting.net/aff.php?aff=303">Space Hosting</a></h3>
13+
</div>
14+
1015
- [Docs](https://view.zintensity.dev)
1116
- [Source](https://github.com/ZeroIntensity/view.py)
1217
- [PyPI](https://pypi.org/project/view.py)
1318
- [Discord](https://discord.gg/tZAfuWAbm2)
1419

20+
## Example
21+
1522
```py
1623
from view import new_app, h1
1724

@@ -24,23 +31,23 @@ async def index():
2431
app.run()
2532
```
2633

27-
### Installation
34+
## Installation
2835

2936
**Python 3.8+ is required.**
3037

31-
#### Development
38+
### Development
3239

3340
```
3441
$ pip install git+https://github.com/ZeroIntensity/view.py
3542
```
3643

37-
#### Linux/macOS
44+
### Linux/macOS
3845

3946
```
4047
$ python3 -m pip install -U view.py
4148
```
4249

43-
#### Windows
50+
### Windows
4451

4552
```
4653
> py -3 -m pip install -U view.py

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
template: home.html
33
title: The Batteries-Detachable Web Framework
4-
---
4+
---

0 commit comments

Comments
 (0)