Skip to content

Commit f545fe6

Browse files
author
Fabien Coelho
committed
switch from sphinx to mkdocs
1 parent 6c347df commit f545fe6

File tree

12 files changed

+191
-125
lines changed

12 files changed

+191
-125
lines changed

.github/workflows/doc.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ jobs:
1717
- name: Generate documentation
1818
run: |
1919
make doc
20-
ln -s docs/_build/html _site
21-
find docs/_build -type d -print | xargs chmod a+rx
22-
find docs/_build -type f -print | xargs chmod a+r
20+
find _site -type d -print | xargs chmod a+rx
21+
find _site -type f -print | xargs chmod a+r
2322
- name: Upload to GitHub Pages
2423
uses: actions/upload-pages-artifact@v3
2524
deploy:

Makefile

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ SHELL = /bin/bash
55

66
MODULE = ProxyPatternPool
77

8-
F.md = $(wildcard *.md)
8+
F.md = $(wildcard *.md docs/*.md)
99
F.pdf = $(F.md:%.md=%.pdf)
1010

1111
# PYTHON = /snap/bin/pypy3
@@ -62,9 +62,7 @@ check.pymarkdown: dev
6262
pymarkdown scan $(F.md)
6363

6464
.PHONY: check.docs
65-
check.docs: venv/.doc
66-
source venv/bin/activate
67-
sphinx-lint docs/
65+
check.docs: check.pymarkdown
6866

6967
# check.black check.pyright
7068
.PHONY: check
@@ -73,7 +71,7 @@ check: check.pyright check.pymarkdown check.ruff check.pytest check.coverage
7371
.PHONY: clean
7472
clean:
7573
$(MAKE) -C docs clean
76-
$(RM) -r __pycache__ */__pycache__ dist build .mypy_cache .pytest_cache .coverage htmlcov .ruff_cache
74+
$(RM) -r __pycache__ */__pycache__ dist build .mypy_cache .pytest_cache .coverage htmlcov .ruff_cache _site/
7775
$(RM) $(F.pdf)
7876

7977
.PHONY: clean.venv
@@ -105,7 +103,7 @@ venv/.doc: venv
105103
.PHONY: doc
106104
doc: venv/.doc check.docs
107105
source venv/bin/activate
108-
$(MAKE) -C docs html
106+
mkdocs build
109107

110108
.PHONY: pub
111109
pub: venv/.pub

README.md

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

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docs/index.md

docs/REFERENCE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# API Reference
2+
3+
::: ProxyPatternPool

docs/TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## ProxyPatternPool Backlog
1+
# ProxyPatternPool Backlog
22

33
- remove `gevent` exclusions for Python 3.13 when possible.
44
- suspend house keeping thread when nothing to do?

docs/VERSIONS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Version history.
44

55
## ? on ?
66

7-
- Switch documentation to Sphinx.
7+
- Switch documentation to Mkdocs.
88

99
## 11.4 on 2025-03-08
1010

docs/favicon.ico

14.7 KB
Binary file not shown.

docs/index.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# ProxyPatternPool
2+
3+
Generic Proxy and Pool classes for Python.
4+
5+
![Status](https://github.com/zx80/proxy-pattern-pool/actions/workflows/ppp.yml/badge.svg?branch=main&style=flat)
6+
![Tests](https://img.shields.io/badge/tests-13%20✓-success)
7+
![Coverage](https://img.shields.io/badge/coverage-100%25-success)
8+
![Issues](https://img.shields.io/github/issues/zx80/proxy-pattern-pool?style=flat)
9+
![Python](https://img.shields.io/badge/python-3-informational)
10+
![Version](https://img.shields.io/pypi/v/ProxyPatternPool)
11+
![Badges](https://img.shields.io/badge/badges-8-informational)
12+
![License](https://img.shields.io/pypi/l/proxypatternpool?style=flat)
13+
14+
This module provides two classes:
15+
16+
- `Proxy` implements the
17+
[proxy pattern](https://en.wikipedia.org/wiki/Proxy_pattern),
18+
i.e. all calls to methods on the proxy are forwarded to an internally wrapped
19+
object. This allows to solve the classic chicken-and-egg importation and
20+
initialization possibly circular-dependency issue with Python modules:
21+
22+
```python
23+
# File "database.py"
24+
db = Proxy()
25+
26+
def init_app(config):
27+
db.set_obj(initialization from config)
28+
```
29+
30+
```python
31+
# File "app.py"
32+
import database
33+
from database import db # db is a proxy to nothing
34+
35+
# delayed initialization
36+
database.init_app(config)
37+
38+
# db is now a proxy to the initialized object
39+
```
40+
41+
When an internal pool is used, method `_ret_obj` **must** be called to return
42+
the object to the pool when done with it.
43+
44+
- `Pool` implements a full-featured thread-safe pool of things which can be used
45+
to store expensive-to-create objects such as database connections, to be
46+
shared between threads for instance. The above proxy object creates a pool
47+
automatically depending on its parameters.
48+
49+
This generic pool class can be used independently of the `Proxy` class.
50+
51+
It provides numerous hooks to provide callbacks for creation, deletion,
52+
stats, tracing, health check… which makes it ideal to manage any kind
53+
of expensive resources within a process.
54+
55+
```python
56+
import ProxyPatternPool as ppp
57+
58+
# start a pool with 2 resources created by "fun"
59+
pool = ppp.Pool(
60+
fun = lambda n: f"expensive object {n}",
61+
min_size=2, max_size=2, timeout=0.5,
62+
)
63+
64+
# get resources
65+
a = pool.get(); b = pool.get() # max_size reached
66+
try:
67+
c = pool.get() # will timeout after 0.5 seconds
68+
assert False
69+
except ppp.TimeOut:
70+
pass
71+
72+
pool.ret(a); pool.ret(b); # return resources
73+
74+
pool.shutdown()
75+
del pool
76+
```
77+
78+
## License
79+
80+
This code is [Public Domain](https://creativecommons.org/publicdomain/zero/1.0/).
81+
82+
All software has bug, this is software, hence… Beware that you may lose your
83+
hairs or your friends because of it. If you like it, feel free to send a
84+
postcard to the author.
85+
86+
## Versions
87+
88+
[Sources](https://github.com/zx80/proxy-pattern-pool),
89+
[documentation](https://zx80.github.io/proxy-pattern-pool/) and
90+
[issues](https://github.com/zx80/proxy-pattern-pool/issues)
91+
are hosted on [GitHub](https://github.com).
92+
Install [package](https://pypi.org/project/ProxyPatternPool/) from
93+
[PyPI](https://pypi.org/).
94+
See [version details](VERSIONS.md).

docs/index.rst

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

0 commit comments

Comments
 (0)