Skip to content

Commit e7d6225

Browse files
committed
bring back mkdocs material
1 parent 7eda2a8 commit e7d6225

File tree

10 files changed

+213
-128
lines changed

10 files changed

+213
-128
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525
- Added preset values to the `view.toml` generated by `view init`
2626
- Fixed fancy logging not exiting after a `KeyboardInterrupt`
2727
- Added prettier input prompts to `view init`
28+
- Added `HTML.from_file`
2829
- **Breaking Change:** Middleware functions must now take `call_next`
2930

3031
## [1.0.0-alpha9] - 2024-2-4

README.md

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,47 @@
1717
- [PyPI](https://pypi.org/project/view.py)
1818
- [Discord](https://discord.gg/tZAfuWAbm2)
1919

20-
## Example
20+
## Features
21+
22+
- Batteries Detachable: Don't like our approach to something? No problem! We aim to provide native support for all your favorite libraries, as well as provide APIs to let you reinvent the wheel as you wish.
23+
- Lightning Fast: Powered by [pyawaitable](https://github.com/ZeroIntensity/pyawaitable), view.py is the first web framework to implement ASGI in pure C, without the use of external transpilers.
24+
- Developer Oriented: view.py is developed with ease of use in mind, providing a rich documentation, docstrings, and type hints.
25+
26+
## Examples
2127

2228
```py
23-
from view import new_app, h1
29+
from view import new_app
2430

2531
app = new_app()
2632

2733
@app.get("/")
2834
async def index():
29-
return h1("Hello, view.py!")
35+
return await app.template("index.html", engine="jinja")
3036

3137
app.run()
3238
```
3339

40+
```py
41+
# routes/index.py
42+
from view import get, HTML
43+
44+
# Build TypeScript Frontend
45+
@get(steps=["typescript"], cache_rate=1000)
46+
async def index():
47+
return await HTML.from_file("dist/index.html")
48+
```
49+
50+
```py
51+
from view import JSON, body, post
52+
53+
@post("/create")
54+
@body("name", str)
55+
@body("books", dict[str, str])
56+
def create(name: str, books: dict[str, str]):
57+
# ...
58+
return JSON({"message": "Successfully created user!"}), 201
59+
```
60+
3461
## Installation
3562

3663
**Python 3.8+ is required.**

docs/getting-started/configuration.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ Before you can make any projects with view.py, you should learn about how it han
88

99
When creating your app, view will search for one of the following configuration files:
1010

11-
- `view.toml`
12-
- `view.json`
13-
- `view.ini`
14-
- `view_config.py`
11+
- `view.toml`
12+
- `view.json`
13+
- `view.ini`
14+
- `view_config.py`
1515

1616
Note that while all of these are different formats, they can all evaluate to the same thing internally. If you have any questions on these semantics, once again see [configzen](https://github.com/bswck/configzen).
1717

@@ -81,12 +81,12 @@ test = env("TEST", tp=int)
8181

8282
**Environment Prefix: `view_app_`**
8383

84-
| Key | Description | Default |
85-
| ------------ | ------------------------------------------------------------------------------------------------------------------------------ | ------------ |
86-
| `loader` | This is the strategy that will be used to load routes. Can be `manual`, `simple`, or `filesystem`. | `manual` |
87-
| `app_path` | A string defining the location of the app, as well as the variable name. Should be in the format of `file_path:variable_name`. | `app.py:app` |
88-
| `uvloop` | Whether or not to use `uvloop` as a means of event loop. Can be `decide` or a `bool` value. | `decide` |
89-
| `loader_path`| When the loader is `simple` or `filesystem`, this is the path that it searches for routes. | `routes/` |
84+
| Key | Description | Default |
85+
| ------------- | ------------------------------------------------------------------------------------------------------------------------------ | ------------ |
86+
| `loader` | This is the strategy that will be used to load routes. Can be `manual`, `simple`, or `filesystem`. | `manual` |
87+
| `app_path` | A string defining the location of the app, as well as the variable name. Should be in the format of `file_path:variable_name`. | `app.py:app` |
88+
| `uvloop` | Whether or not to use `uvloop` as a means of event loop. Can be `decide` or a `bool` value. | `decide` |
89+
| `loader_path` | When the loader is `simple` or `filesystem`, this is the path that it searches for routes. | `routes/` |
9090

9191
Example with TOML:
9292

@@ -100,12 +100,12 @@ loader_path = "./app"
100100

101101
**Environment Prefix:** `view_server_`
102102

103-
| Key | Description | Default |
104-
| ------------ | -------------------------------------------------------------------------------------------------------------------- | ---------- |
105-
| `host` | IPv4 address specifying what address to bind the server to. `0.0.0.0` by default. | `0.0.0.0` |
106-
| `port` | Integer defining what port to bind the server to. | `5000` |
107-
| `backend` | ASGI backend to use. Can be `uvicorn`, `daphne`, or `hypercorn`. | `uvicorn` |
108-
| `extra_args` | Dictionary containing extra parameters for the ASGI backend. This parameter is specific to the backend and not View. | `{}` |
103+
| Key | Description | Default |
104+
| ------------ | -------------------------------------------------------------------------------------------------------------------- | --------- |
105+
| `host` | IPv4 address specifying what address to bind the server to. `0.0.0.0` by default. | `0.0.0.0` |
106+
| `port` | Integer defining what port to bind the server to. | `5000` |
107+
| `backend` | ASGI backend to use. Can be `uvicorn`, `daphne`, or `hypercorn`. | `uvicorn` |
108+
| `extra_args` | Dictionary containing extra parameters for the ASGI backend. This parameter is specific to the backend and not View. | `{}` |
109109

110110
Example with TOML:
111111

@@ -119,7 +119,7 @@ port = 8080
119119

120120
**Environment Prefix:** `view_log_`
121121

122-
| Key | Description | Default |
122+
| Key | Description | Default |
123123
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------- |
124124
| `level` | Log level. May be `debug`, `info`, `warning`, `error`, `critical`, or an `int`. This is based on Python's built-in [logging module](https://docs.python.org/3/library/logging.html). | `info` |
125125
| `server_logger` | This is a `bool` determining whether the ASGI backend's logger should be displayed. | `False` |
@@ -129,16 +129,16 @@ port = 8080
129129

130130
### User Logging Settings
131131

132-
*Environment Prefix:* `view_user_log_`
132+
_Environment Prefix:_ `view_user_log_`
133133

134-
- `urgency`: The log level for user logging. `info` by default.
135-
- `log_file`: The target file for outputting log messages. `None` by default.
136-
- `show_time`: Whether to show the time in each message. `True` by default.
137-
- `show_caller`: Whether to show the caller function in each message. `True` by default.
138-
- `show_color`: Whether to enable colorization for messages. `True` by default.
139-
- `show_urgency`: Whether to show the urgency for messages. `True` by default.
140-
- `file_write`: The preference for writing to an output file, if set. May be `both`, to write to both the terminal and the output file, `only`, to write to just the output file, or `never`, to not write anything.
141-
- `strftime`: The time format used if `show_time` is set to `True`. `%H:%M:%S` by default.
134+
- `urgency`: The log level for user logging. `info` by default.
135+
- `log_file`: The target file for outputting log messages. `None` by default.
136+
- `show_time`: Whether to show the time in each message. `True` by default.
137+
- `show_caller`: Whether to show the caller function in each message. `True` by default.
138+
- `show_color`: Whether to enable colorization for messages. `True` by default.
139+
- `show_urgency`: Whether to show the urgency for messages. `True` by default.
140+
- `file_write`: The preference for writing to an output file, if set. May be `both`, to write to both the terminal and the output file, `only`, to write to just the output file, or `never`, to not write anything.
141+
- `strftime`: The time format used if `show_time` is set to `True`. `%H:%M:%S` by default.
142142

143143
Example with TOML:
144144

@@ -153,12 +153,12 @@ log_file = "app.log"
153153

154154
## Template Settings
155155

156-
*Environment Prefix:* `view_templates_`
156+
_Environment Prefix:_ `view_templates_`
157157

158-
- `directory`: The path to search for templates. `./templates` by default.
159-
- `locals`: Whether to include local variables in the rendering parameters (i.e. local variables can be used inside templates). `True` by default
160-
- `globals`: The same as `locals`, but for global variables instead. `True` by default.
161-
- `engine`: The default template engine to use for rendering. Can be `view`, `jinja`, `django`, `mako`, or `chameleon`. `view` by default.
158+
- `directory`: The path to search for templates. `./templates` by default.
159+
- `locals`: Whether to include local variables in the rendering parameters (i.e. local variables can be used inside templates). `True` by default
160+
- `globals`: The same as `locals`, but for global variables instead. `True` by default.
161+
- `engine`: The default template engine to use for rendering. Can be `view`, `jinja`, `django`, `mako`, or `chameleon`. `view` by default.
162162

163163
Example with TOML:
164164

docs/index.md

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,64 @@
11
---
2-
template: home.html
3-
4-
title: The Batteries-Detachable Web Framework
2+
hide:
3+
- navigation
54
---
5+
6+
# Welcome to view.py's documentation!
7+
8+
Here, you can learn how to use view.py and its various features.
9+
10+
- [Source](https://github.com/ZeroIntensity/view.py)
11+
- [PyPI](https://pypi.org/project/view.py)
12+
- [Discord](https://discord.gg/tZAfuWAbm2)
13+
14+
!!! warning
15+
16+
view.py is in very early stages and not yet considered to be ready for production.
17+
If you would like to follow development progress, join [the discord](https://discord.gg/tZAfuWAbm2).
18+
For contributing to view.py, please see our [contributors file](https://github.com/ZeroIntensity/view.py/blob/master/CONTRIBUTING.md)
19+
20+
## Quickstart
21+
22+
Install view.py:
23+
24+
```
25+
$ pip install -U view.py
26+
```
27+
28+
Initialize your project:
29+
30+
```
31+
$ view init
32+
```
33+
34+
**Note:** If this yields unexpected results, you may need to use `py -m view init` instead.
35+
36+
Write your first app:
37+
38+
```py
39+
from view import new_app
40+
41+
app = new_app()
42+
43+
@app.query("greeting", str, default="hello")
44+
@app.query("name", str, default="world")
45+
@app.get("/")
46+
async def index(greeting: str, name: str):
47+
return f"{greeting}, {name}!"
48+
49+
app.run()
50+
```
51+
52+
## Why View?
53+
54+
As of now, view.py is still in alpha. Lot's of development progress is being made, but a production-ready stable release is still a bit far off. With that being said, anything mentioned in this documentation has been deemed already stable. In that case, why choose view.py over other frameworks?
55+
56+
If you've used a framework like [Django](https://djangoproject.com), you're likely already familiar with the "batteries included" idea, meaning that it comes with everything you could need right out of the box. View takes a different approach: batteries-detachable. It aims to provide you everything you need, but gives you a choice to use it or not, as well as actively supporting external libraries. This ideology is what makes View special. In batteries detachable, you can use whatever you like right out of the box, but if you don't like View's approach to something or like another library instead, you may easily use it.
57+
58+
## Should I use it?
59+
60+
For a big project, **not yet**, as View is not currently ideal for working with a big codebase. However, **that doesn't mean you should forget about it**. view.py will soon be stable and production ready, and you should keep it in mind. To support view.py's development, you can either [sponsor me](https://github.com/sponsors/ZeroIntensity) or [star the project](https://github.com/zerointensity/view.py/stargazers).
61+
62+
## Developing View
63+
64+
As stated earlier, view.py is very new and not yet at a stable 1.0.0 release. Whether you're completely new to GitHub contribution or an experienced developer, view.py has something you could help out with. If you're interested in contributing or helping out with anything, be sure to read [the contributors file](https://github.com/ZeroIntensity/view.py/blob/master/CONTRIBUTING.md) and/or joining the [discord](https://discord.gg/tZAfuWAbm2).

docs/welcome.md

Lines changed: 0 additions & 59 deletions
This file was deleted.

html/geist.ttf

-101 KB
Binary file not shown.

mkdocs.yml

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ repo_url: https://github.com/ZeroIntensity/view.py
44
repo_name: ZeroIntensity/view.py
55

66
nav:
7-
- index.md
8-
- Welcome: welcome.md
7+
- Home: index.md
98
- Getting Started:
109
- Installation: getting-started/installation.md
1110
- Configuration: getting-started/configuration.md
@@ -30,8 +29,60 @@ nav:
3029
- Templates: reference/templates.md
3130

3231
theme:
33-
name: null
34-
custom_dir: "html/"
32+
name: material
33+
palette:
34+
- media: "(prefers-color-scheme)"
35+
primary: red
36+
accent: red
37+
toggle:
38+
icon: material/brightness-auto
39+
name: Switch to light mode
40+
41+
# Palette toggle for light mode
42+
- media: "(prefers-color-scheme: light)"
43+
scheme: default
44+
primary: red
45+
accent: red
46+
toggle:
47+
icon: material/brightness-7
48+
name: Switch to dark mode
49+
50+
# Palette toggle for dark mode
51+
- media: "(prefers-color-scheme: dark)"
52+
scheme: slate
53+
primary: red
54+
accent: red
55+
toggle:
56+
icon: material/brightness-4
57+
name: Switch to system preference
58+
features:
59+
- content.tabs.link
60+
- content.code.copy
61+
- search.highlight
62+
- search.share
63+
- search.suggest
64+
- navigation.footer
65+
- navigation.indexes
66+
- navigation.sections
67+
- navigation.tabs
68+
- navigation.tabs.sticky
69+
- navigation.top
70+
- toc.follow
71+
72+
icon:
73+
repo: fontawesome/brands/github
74+
75+
extra:
76+
social:
77+
- icon: fontawesome/brands/discord
78+
link: https://discord.gg/tZAfuWAbm2
79+
name: view.py discord
80+
- icon: fontawesome/brands/github
81+
link: https://github.com/ZeroIntensity/view.py
82+
name: view.py repository
83+
- icon: material/heart
84+
link: https://github.com/sponsors/ZeroIntensity/
85+
name: support view.py
3586

3687
markdown_extensions:
3788
- toc:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,4 @@ view = "view.__main__:main"
136136
exclude = ["src/view/databases.py", "src/view/components.py", "src/view/_codec.py"]
137137
ignore_missing_imports = true
138138
follow_imports = "skip"
139-
enable_incomplete_feature = ["Unpack"]
139+
enable_incomplete_feature = ["Unpack"]

0 commit comments

Comments
 (0)