Skip to content

Commit 4d56944

Browse files
committed
Working on readmes
1 parent d953197 commit 4d56944

File tree

11 files changed

+223
-31
lines changed

11 files changed

+223
-31
lines changed

Diff for: bolt-auth/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Create users and authenticate them.
66

7-
[link](https://github.com/dropseed/bolt/tree/main/bolt-auth/bolt/auth/config.py)
7+
[link](https://boltframework.dev/docs/bolt-auth/bolt/auth/config.py)
88

99
## Installation
1010

Diff for: bolt/README.md

+27-9
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,30 @@ Bolt is a web framework for building products with Python.
66

77
With the core `bolt` package you can build an app that:
88

9-
- Matches [URL patterns](https://github.com/dropseed/bolt/tree/main/bolt/bolt/urls/README.md) to Python views
10-
- Handles HTTP requests and responses
11-
- Renders HTML templates with Jinja
12-
- Processes user input via forms
13-
- Has a CLI interface
14-
- Serves static assets (CSS, JS, images)
15-
- Can be modified with middleware
16-
- Integrates first-party and third-party packages
17-
- Has a preflight check system
9+
- Matches [URL patterns](https://boltframework.dev/docs/bolt/bolt/urls) to Python [views](https://boltframework.dev/docs/bolt/bolt/views)
10+
- Handles [HTTP requests and responses](https://boltframework.dev/docs/bolt/bolt/http)
11+
- Renders [HTML templates](https://boltframework.dev/docs/bolt/bolt/templates) with Jinja
12+
- Processes user input via [forms](https://boltframework.dev/docs/bolt/bolt/forms)
13+
- Has a [CLI interface](https://boltframework.dev/docs/bolt/bolt/cli)
14+
- Serves static [assets](https://boltframework.dev/docs/bolt/bolt/assets) (CSS, JS, images)
15+
- Can be modified with [middleware](https://boltframework.dev/docs/bolt/bolt/middleware)
16+
- Integrates first-party and third-party [packages](https://boltframework.dev/docs/bolt/bolt/packages)
17+
- Has a [preflight check system](https://boltframework.dev/docs/bolt/bolt/preflight)
18+
19+
With the official Bolt ecosystem packages you can:
20+
21+
- Integrate a full-featured [database ORM](https://boltframework.dev/docs/bolt-db/)
22+
- Use a built-in [user authentication](https://boltframework.dev/docs/bolt-auth/) system
23+
- [Lint and format code](https://boltframework.dev/docs/bolt-code/)
24+
- Run a [database-backed cache](https://boltframework.dev/docs/bolt-cache/)
25+
- [Send emails](https://boltframework.dev/docs/bolt-mail/)
26+
- Streamline [local development](https://boltframework.dev/docs/bolt-dev/)
27+
- Manage [feature flags](https://boltframework.dev/docs/bolt-flags/)
28+
- Integrate [HTMX](https://boltframework.dev/docs/bolt-htmx/)
29+
- Style with [Tailwind CSS](https://boltframework.dev/docs/bolt-tailwind/)
30+
- Add [OAuth login](https://boltframework.dev/docs/bolt-oauth/) and API access
31+
- Run tests with [pytest](https://boltframework.dev/docs/bolt-test/)
32+
- Run a [background job worker](https://boltframework.dev/docs/bolt-worker/)
33+
- Build [staff tooling and admin dashboards](https://boltframework.dev/docs/bolt-staff/)
34+
35+
Learn more at [boltframework.dev](https://boltframework.dev).

Diff for: bolt/bolt/README.md

+27-9
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,30 @@ Bolt is a web framework for building products with Python.
44

55
With the core `bolt` package you can build an app that:
66

7-
- Matches [URL patterns](./urls/README.md) to Python views
8-
- Handles HTTP requests and responses
9-
- Renders HTML templates with Jinja
10-
- Processes user input via forms
11-
- Has a CLI interface
12-
- Serves static assets (CSS, JS, images)
13-
- Can be modified with middleware
14-
- Integrates first-party and third-party packages
15-
- Has a preflight check system
7+
- Matches [URL patterns](./urls) to Python [views](./views)
8+
- Handles [HTTP requests and responses](./http)
9+
- Renders [HTML templates](./templates) with Jinja
10+
- Processes user input via [forms](./forms)
11+
- Has a [CLI interface](./cli)
12+
- Serves static [assets](./assets) (CSS, JS, images)
13+
- Can be modified with [middleware](./middleware)
14+
- Integrates first-party and third-party [packages](./packages)
15+
- Has a [preflight check system](./preflight)
16+
17+
With the official Bolt ecosystem packages you can:
18+
19+
- Integrate a full-featured [database ORM](https://boltframework.dev/docs/bolt-db/)
20+
- Use a built-in [user authentication](https://boltframework.dev/docs/bolt-auth/) system
21+
- [Lint and format code](https://boltframework.dev/docs/bolt-code/)
22+
- Run a [database-backed cache](https://boltframework.dev/docs/bolt-cache/)
23+
- [Send emails](https://boltframework.dev/docs/bolt-mail/)
24+
- Streamline [local development](https://boltframework.dev/docs/bolt-dev/)
25+
- Manage [feature flags](https://boltframework.dev/docs/bolt-flags/)
26+
- Integrate [HTMX](https://boltframework.dev/docs/bolt-htmx/)
27+
- Style with [Tailwind CSS](https://boltframework.dev/docs/bolt-tailwind/)
28+
- Add [OAuth login](https://boltframework.dev/docs/bolt-oauth/) and API access
29+
- Run tests with [pytest](https://boltframework.dev/docs/bolt-test/)
30+
- Run a [background job worker](https://boltframework.dev/docs/bolt-worker/)
31+
- Build [staff tooling and admin dashboards](https://boltframework.dev/docs/bolt-staff/)
32+
33+
Learn more at [boltframework.dev](https://boltframework.dev).

Diff for: bolt/bolt/assets/README.md

+55-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,56 @@
1-
# assets
1+
# Assets
22

3-
Serve static assets for your app.
3+
Serve static assets (CSS, JS, images, etc.) for your app.
4+
5+
The default behavior is for Bolt to serve assets directly via a middleware.
6+
This is based on [whitenoise](http://whitenoise.evans.io/en/stable/).
7+
8+
## Usage
9+
10+
Generally speaking, the simplest way to include assests in your app is to put them either in `app/assets` or `app/<package>/assets`.
11+
12+
Then in your template you can use the `asset()` function to get the URL.
13+
14+
```html
15+
<link rel="stylesheet" href="{{ asset('css/style.css') }}">
16+
```
17+
18+
If you ever need to reference an asset directly in Python code, you can use the `get_asset_url()` function.
19+
20+
```python
21+
from bolt.assets import get_asset_url
22+
23+
print(get_asset_url("css/style.css"))
24+
```
25+
26+
## Settings
27+
28+
These are the default settings related to assets handling.
29+
30+
```python
31+
# app/settings.py
32+
MIDDLEWARE = [
33+
"bolt.middleware.security.SecurityMiddleware",
34+
"bolt.assets.whitenoise.middleware.WhiteNoiseMiddleware", # <--
35+
"bolt.middleware.common.CommonMiddleware",
36+
"bolt.csrf.middleware.CsrfViewMiddleware",
37+
"bolt.middleware.clickjacking.XFrameOptionsMiddleware",
38+
]
39+
40+
ASSETS_BACKEND = "bolt.assets.whitenoise.storage.CompressedManifestStaticFilesStorage"
41+
42+
# List of finder classes that know how to find assets files in
43+
# various locations.
44+
ASSETS_FINDERS = [
45+
"bolt.assets.finders.FileSystemFinder",
46+
"bolt.assets.finders.PackageDirectoriesFinder",
47+
]
48+
49+
# Absolute path to the directory assets files should be collected to.
50+
# Example: "/var/www/example.com/assets/"
51+
ASSETS_ROOT = BOLT_TEMP_PATH / "assets_collected"
52+
53+
# URL that handles the assets files served from ASSETS_ROOT.
54+
# Example: "http://example.com/assets/", "http://assets.example.com/"
55+
ASSETS_URL = "/assets/"
56+
```

Diff for: bolt/bolt/cli/README.md

+100
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,114 @@ which has been one of those most popular CLI frameworks in Python for a long tim
1010

1111
### `bolt shell`
1212

13+
Open a Python shell with the Bolt loaded.
14+
15+
To auto-load models or run other code at shell launch,
16+
create an `app/shell.py` and it will be imported automatically.
17+
18+
```python
19+
# app/shell.py
20+
from organizations.models import Organization
21+
22+
__all__ = [
23+
"Organization",
24+
]
25+
```
26+
1327
### `bolt compile`
1428

29+
Compile static assets (used in the deploy/production process).
30+
31+
Automatically runs `bolt tailwind compile` if [bolt-tailwind](https://boltframework.dev/docs/bolt-tailwind/) is installed.
32+
33+
Automatically runs `npm run compile` if you have a `package.json` with `scripts.compile`.
34+
1535
### `bolt run`
1636

37+
Run a Python script in the context of your app.
38+
1739
### `bolt legacy`
1840

41+
A temporary holdover for running the old `manage.py` commands that haven't been converted yet.
42+
43+
### `bolt preflight`
44+
45+
Run preflight checks to ensure your app is ready to run.
46+
47+
### `bolt create`
48+
49+
Create a new local package.
50+
51+
### `bolt setting`
52+
53+
View the runtime value of a named setting.
54+
1955
## Adding commands
2056

57+
### Add an `app/cli.py`
58+
59+
You can add "root" commands to your app by defining a `cli` function in `app/cli.py`.
60+
61+
```python
62+
import click
63+
64+
65+
@click.group()
66+
def cli():
67+
pass
68+
69+
70+
@cli.command()
71+
def custom_command():
72+
click.echo("An app command!")
73+
```
74+
75+
Then you can run the command with `bolt`.
76+
77+
```bash
78+
$ bolt custom-command
79+
An app command!
80+
```
81+
2182
### Add CLI commands to your local packages
2283

84+
Any package in `INSTALLED_PACKAGES` can define CLI commands by creating a `cli.py` in the root of the package.
85+
In `cli.py`, create a command or group of commands named `cli`.
86+
87+
```python
88+
import click
89+
90+
91+
@click.group()
92+
def cli():
93+
pass
94+
95+
96+
@cli.command()
97+
def hello():
98+
click.echo("Hello, world!")
99+
```
100+
101+
Bolt will use the name of the package in the CLI,
102+
then any commands you defined.
103+
104+
```bash
105+
$ bolt <pkg> hello
106+
Hello, world!
107+
```
108+
23109
### Add CLI commands to published packages
110+
111+
Some packages, like [bolt-dev](https://boltframework.dev/docs/bolt-dev/),
112+
never show up in `INSTALLED_PACKAGES` but still have CLI commands.
113+
These are detected via Python entry points.
114+
115+
An example with `pyproject.toml` and Poetry:
116+
117+
```toml
118+
# pyproject.toml
119+
[tool.poetry.plugins."bolt.cli"]
120+
"dev" = "bolt.dev:cli"
121+
"pre-commit" = "bolt.dev.precommit:cli"
122+
"contrib" = "bolt.dev.contribute:cli"
123+
```

Diff for: bolt/bolt/csrf/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# csrf
1+
# CSRF
22

33
Cross-Site Request Forgery (CSRF) protection.

Diff for: bolt/bolt/files/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Files
2+
3+
File upload handling and utilities.

Diff for: bolt/bolt/http/README.md

-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
11
# HTTP
2-
3-
Every HTTP request deserves and HTTP response.
4-
5-
At the end of the day,
6-
Bolt is for building websites and that means receiving HTTP requests
7-
and returning HTTP responses.

Diff for: bolt/bolt/logs/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Default logging settings and key-value logger.
44

55
In Python, logging can be a surprisingly complex topic.
66

7-
So Bolt includes some easy-to-use defaults that "just work".
7+
So Bolt aims for easy-to-use defaults that "just work".
88

99
## `app_logger`
1010

Diff for: scripts/compile-readmes

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ compile_readme() {
44
package_readme="$1"
55
code_readme="$2"
66

7+
echo "Compiling $code_readme to $package_readme"
8+
79
header_comment="<!-- This file is compiled from $code_readme. Do not edit this file directly. -->\n"
810

911
# Copy bolt/bolt/README.md to bolt/README.md and add a header comment
@@ -13,8 +15,8 @@ compile_readme() {
1315
code_base_dir=$(dirname "$code_readme")
1416

1517
# Find and replace any "](./" markdown links and replace with a full github.com url
16-
github_url="https://github.com/dropseed/bolt/tree/main"
17-
sed -i '' -e "s#](\./\([^)]*\))#]($github_url/$code_base_dir/\1)#g" "$package_readme"
18+
docs_url="https://boltframework.dev/docs"
19+
sed -i '' -e "s#](\./\([^)]*\))#]($docs_url/$code_base_dir/\1)#g" "$package_readme"
1820
}
1921

2022
compile_readme "bolt/README.md" "bolt/bolt/README.md"

Diff for: scripts/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ echo "${BOLD}Checking with ruff${NORMAL}"
88
echo ""
99
echo "${BOLD}Running tests${NORMAL}"
1010
./scripts/test
11+
12+
echo ""
13+
echo "${BOLD}Compiling readmes${NORMAL}"
14+
./scripts/compile-readmes

0 commit comments

Comments
 (0)