Skip to content

Commit 2671930

Browse files
committed
2.7.4: README as a short entrance to the documentation site
Documentation only; the code is the same as 2.7.3. - README is a minimal entrance: presentation, one example, the site link and a flat documentation list, with the design notes under Maintaining. The introduction and its fuller examples move to docs/overview.md. - Dropped what the site derives or what goes stale: badges, install commands, Status and License sections, the hand-kept line and example counts, the dependency tree, the version in the run() banner sample. - The layers and pytypehintstore are described once in architecture.md, the widget demo once in types.md. - examples.md lists the users, bookings and gallery mini-apps, drops the link to the README and the repeated install blocks. - Design notes state the theme and stream polling as facts, not plans. - Links to pytypehint, pytypehintweb and pytypehintstore point to their documentation sites. - CHANGELOG headings use "## X.Y.Z - YYYY-MM-DD"; seven dates corrected to their PyPI upload dates. - pyproject gains the Documentation URL; Source becomes Repository. - test_docs_snippets follows the CRUD fragment into docs/overview.md.
1 parent 28daaee commit 2671930

14 files changed

Lines changed: 564 additions & 714 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 81 additions & 102 deletions
Large diffs are not rendered by default.

‎README.md‎

Lines changed: 14 additions & 536 deletions
Large diffs are not rendered by default.

‎docs/architecture.md‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ pytypehintweb web plan, browser widgets and transport
1010
FuncToWeb routes, execution, integration and documentation
1111
```
1212

13-
* [`pytypehint`](https://github.com/offerrall/pytypehint) compiles a signature
13+
* [pytypehint](https://offerrall.github.io/pytypehint/) compiles a signature
1414
into a `Signature`: which types each parameter accepts, which constraints and
1515
defaults apply, and how the real arguments are built from validated values.
16-
* [`pytypehintweb`](https://github.com/offerrall/pytypehintweb) turns that
16+
* [pytypehintweb](https://offerrall.github.io/pytypehintweb/) turns that
1717
contract into a **plan**: the description of the form that the browser
1818
consumes, with its JSON transport, plus the widgets that render it.
1919
* FuncToWeb adds what is still missing in order to publish it: the HTTP routes,
@@ -24,6 +24,14 @@ catalog. What it does is re-export that catalog (the constraint and annotation
2424
atoms, `Color`, `Email` and the errors), so whoever writes a function never
2525
needs to import from the lower layers.
2626

27+
Beside the stack, not under it: FuncToWeb stores nothing — a function runs and
28+
returns. When a small app needs its rows to outlive the process,
29+
[pytypehintstore](https://offerrall.github.io/pytypehintstore/) persists the
30+
same dataclasses this stack validates, in memory and shadowed by a JSON file you
31+
can open and edit. It is optional and not a dependency:
32+
[`examples/project/todo_stored.py`](../examples/project/todo_stored.py) is the
33+
todo mini-app with the dict swapped for a store.
34+
2735
## From the function to the response
2836

2937
Each `WebFunction` compiles its schema, its plan and its base HTML once, at

‎docs/design/router.md‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ A `WebFunction` carries no theme of its own, because it compiles its HTML once,
2222
without knowing which application it will end up in. That is why the theme belongs
2323
to the space and two themes need two applications.
2424

25-
> Today the theme is set by whoever mounts the space. Letting the user
26-
> choose it, and remembering that choice, will come in a future version: that is
27-
> why there is no visible selector yet, no `localStorage`, no cookies, and no
28-
> theme-switching JavaScript.
25+
The theme is set by whoever mounts the space, not by the user: there is no
26+
visible selector, no `localStorage`, no cookies, and no theme-switching
27+
JavaScript.

‎docs/design/streaming.md‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,3 @@ goes back to sleep. Two things follow from that: an event can take up to one
4646
poll to go out, including the final `result`, and every open connection costs
4747
that wake-up for as long as the execution lasts. For what FuncToWeb is, internal
4848
tools with a few users at a time, neither is noticeable.
49-
50-
> Polling will be replaced by direct notification in a future version, to hold
51-
> more simultaneous connections. The contract does not change: the same events,
52-
> the same grouping of printed output and the same final envelope.

‎docs/examples.md‎

Lines changed: 21 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# Examples
22

3-
The [documentation](../README.md#documentation) is the technical reference;
4-
[`examples/`](../examples/) is the hands-on part, and it holds two kinds of file.
3+
The other pages are the technical reference; [`examples/`](../examples/) is
4+
the hands-on part, and it holds two kinds of file.
55

6-
**Examples** teach **a single capability** and nothing else: 81 of them, in the
7-
11 folders of the table below. **Mini-apps** live in [`project/`](../examples/project/) and
8-
do the opposite — each one combines several capabilities into a small complete
9-
application, to show how the pieces sit together once there is more than one.
6+
**Examples** teach **a single capability** and nothing else, grouped in the
7+
folders of the table below. **Mini-apps** live in
8+
[`project/`](../examples/project/) and do the opposite — each one combines
9+
several capabilities into a small complete application, to show how the pieces
10+
sit together once there is more than one.
1011

11-
Both kinds are runnable programs: a file with an `if __name__ == "__main__":`
12-
guard, which is what the count in the main README means. That is every `.py`
13-
file here, nothing in the collection is a module that only exists to be
14-
imported.
12+
Both kinds are runnable programs: every `.py` file has an
13+
`if __name__ == "__main__":` guard, and nothing in the collection is a module
14+
that only exists to be imported.
1515

1616
## Running
1717

@@ -45,19 +45,23 @@ Examples and mini-apps alike serve at <http://127.0.0.1:8000> and block until
4545
| --- | --- | --- |
4646
| [`project/todo.py`](../examples/project/todo.py) | one dataclass model reused by three functions, `app_of()` under a prefix, a hand-written route of your own | [types](types.md), [application](router.md) |
4747
| [`project/todo_stored.py`](../examples/project/todo_stored.py) | the same mini-app whose tasks survive the restart: the dict becomes a store and the model that draws the forms is what the JSON file holds | [types](types.md), [application](router.md) |
48+
| [`project/users.py`](../examples/project/users.py) | a dataclass with a photo field walking the whole file cycle: upload once, edit with the photo already in place and no byte uploaded again, and a host endpoint serving the stored file | [files](files.md), [prefill](prefill.md), [sdk](sdk.md) |
49+
| [`project/bookings.py`](../examples/project/bookings.py) | one dataclass that is the whole form and rulebook: a date, two times, an enum, a slider, a toggled note, and a cross-field rule in `__post_init__` that surfaces as a `422` in the form and the API alike | [types](types.md), [prefill](prefill.md) |
50+
| [`project/gallery.py`](../examples/project/gallery.py) | outputs a CRUD never reaches, drawn inside the modal: an image with its download, a table and streamed lines, with modals that close on their result and modals that do not | [outputs](outputs.md), [streaming](streaming.md), [sdk](sdk.md) |
4851

4952
A mini-app is still short enough to read in one sitting, and it is still an
5053
ordinary FastAPI application: the library contributes an application, never the
5154
host.
5255

5356
## Dependencies
5457

55-
Everything works with `pip install func-to-web`, except
58+
Everything runs with the library alone, except
5659
[`outputs_optional/`](#outputs-with-optional-dependencies), where each subfolder
57-
declares its own (`pillow`, `matplotlib`, `pandas`, `polars`, `numpy`), and
58-
[`project/todo_stored.py`](../examples/project/todo_stored.py), which needs
59-
[`pytypehintstore`](https://github.com/offerrall/pytypehintstore). None of them
60-
is required by the library.
60+
declares its own (`pillow`, `matplotlib`, `pandas`, `polars`, `numpy`);
61+
[`project/gallery.py`](../examples/project/gallery.py), which needs `pillow` and
62+
`pandas`; and [`project/todo_stored.py`](../examples/project/todo_stored.py),
63+
which needs [pytypehintstore](https://offerrall.github.io/pytypehintstore/). None
64+
of them is required by the library.
6165

6266
The examples use fictional data, never access the Internet and write only to
6367
the system temporary directories, with two deliberate exceptions:
@@ -135,20 +139,13 @@ dependency is imported only inside its own example.
135139
| `polars/` | polars | `pip install polars` | `table` |
136140
| `numpy/` | numpy | `pip install numpy` | `table` |
137141

138-
Each one is described below. None of these
139-
libraries is a dependency of FuncToWeb, and none of them appears in
140-
`pyproject.toml`: install only the one for the example you want to run.
142+
Each one is described below. None of these libraries is a dependency of
143+
FuncToWeb: install only the one for the example you want to run.
141144

142145
The reference for the outputs contract is in [Outputs](outputs.md).
143146

144147
### Image with Pillow
145148

146-
Optional dependency: **Pillow**.
147-
148-
```bash
149-
pip install pillow
150-
```
151-
152149
`image.py` draws a square gradient with a frame and a label, and returns
153150
the `PIL.Image.Image` object unchanged: FuncToWeb recognizes it as an image,
154151
encodes it as a PNG, and sends it as a data URI inside an `image` output.
@@ -168,12 +165,6 @@ python examples/outputs_optional/pillow/image.py
168165

169166
### Chart with matplotlib
170167

171-
Optional dependency: **matplotlib**.
172-
173-
```bash
174-
pip install matplotlib
175-
```
176-
177168
`figure.py` plots a sine wave and returns the `matplotlib.figure.Figure`, which
178169
FuncToWeb saves as a PNG with `bbox_inches="tight"` and delivers as an `image`
179170
output.
@@ -196,12 +187,6 @@ python examples/outputs_optional/matplotlib/figure.py
196187

197188
### Table with pandas
198189

199-
Optional dependency: **pandas**.
200-
201-
```bash
202-
pip install pandas
203-
```
204-
205190
`dataframe.py` builds a sales report in memory and returns the
206191
`pandas.DataFrame`, which is converted into a `table` output with the column
207192
names as headers.
@@ -223,12 +208,6 @@ python examples/outputs_optional/pandas/dataframe.py
223208

224209
### Table with polars
225210

226-
Optional dependency: **polars**.
227-
228-
```bash
229-
pip install polars
230-
```
231-
232211
`dataframe.py` builds an inventory report in memory, adds a computed column,
233212
and returns the `polars.DataFrame`, which is converted into a `table` output.
234213

@@ -248,12 +227,6 @@ python examples/outputs_optional/polars/dataframe.py
248227

249228
### Table with numpy
250229

251-
Optional dependency: **numpy**.
252-
253-
```bash
254-
pip install numpy
255-
```
256-
257230
`matrix.py` builds an operation table using broadcasting and returns the
258231
two-dimensional `numpy.ndarray`, which is converted into a `table` output.
259232

‎docs/getting-started.md‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# Getting started
22

3-
```bash
4-
pip install func-to-web
5-
```
6-
73
## A function and its web page
84

95
```python

0 commit comments

Comments
 (0)