8000 Setup doctest. · dry-python/dry-python.github.io@a0e99e3 · GitHub
[go: up one dir, main page]

Skip to content

Commit a0e99e3

Browse files
committed
Setup doctest.
1 parent 243b200 commit a0e99e3

File tree

5 files changed

+113
-2
lines changed

5 files changed

+113
-2
lines changed

docs/index.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ dry-python is a collection of libraries aimed to help you to build an applicatio
1313
You can define business logic processes with clear DSL.
1414

1515
```pycon
16+
1617
>>> from stories import story, arguments
1718

1819
>>> class BuySubscription:
@@ -25,13 +26,15 @@ You can define business logic processes with clear DSL.
2526
... I.persist_subscription
2627
... I.send_subscription_notification
2728
... I.show_category
29+
2830
```
2931

3032
## Dependencies
3133

3234
You can integrate it into frameworks you already use.
3335

3436
```pycon
37+
3538
>>> from dependencies import Injector, operation, this
3639
>>> from dependencies.contrib.django import view
3740
>>> from django.http import HttpResponse
@@ -49,16 +52,19 @@ You can integrate it into frameworks you already use.
4952
... return redirect(result.value)
5053
... elif result.failed_on("check_balance"):
5154
... return HttpResponse("<h1>Error: not enough money</h1>")
55+
5256
```
5357

5458
And a framework of your choice will not even notice the change.
5559

5660
```pycon
61+
5762
>>> from .views import BuySubscriptionView
5863

5964
>>> urlpatterns = [
6065
... path("buy_subscription/<int:id>/", BuySubscriptionView.as_view()),
6166
... ]
67+
6268
```
6369

6470
Drylabs maintains dry-python and helps those who want to use it inside their organizations. Read more at drylabs.io

mddoctest.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import sys
2+
from doctest import testfile
3+
from glob import glob
4+
5+
6+
def _main():
7+
markdown_files = glob("**/*.md", recursive=True)
8+
exit_code = 0
9+
for markdown_file in markdown_files:
10+
failed, attempted = testfile(markdown_file, module_relative=False)
11+
exit_code += failed
12+
sys.exit(exit_code)
13+
14+
15+
if __name__ == "__main__":
16+
_main()

poetry.lock

Lines changed: 86 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ mkdocs = "^1.0.4"
1010
mkdocs-material = "^4.6.0"
1111

1212
[tool.poetry.dev-dependencies]
13+
dependencies = "^0.15"
14+
django = "^3.0.2"
15+
invoke = "^1.4.0"
1316
pre-commit = "^1.21.0"
17+
stories = "^0.10.1"
1418
yamllint = "^1.20.0"
15-
invoke = "^1.4.0"

tasks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
@task
55
def lint(c):
66
c.run("poetry run pre-commit run -a")
7+
c.run("poetry run python -m mddoctest")
78
c.run("poetry run yamllint --strict .")
89
c.run("npm run lint:css")
910
c.run("npm run lint:js")

0 commit comments

Comments
 (0)
0