Skip to content

Commit

Permalink
docs: automatic this.md generation (#705)
Browse files Browse the repository at this point in the history
* docs: automatic 'this' rendering

* workaround with hooks

* rm this.md
  • Loading branch information
FBruzzesi authored Oct 28, 2024
1 parent 94ac54e commit 9f4d7fa
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 56 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Automatically generate when building docs
docs/this.md

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
36 changes: 36 additions & 0 deletions docs/generate_this_content.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from __future__ import annotations

from pathlib import Path
from typing import Final

from sklego.this import poem

DESTINATION_PATH: Final[Path] = Path("docs") / "this.md"

content = f"""
# Import This
In Python there's a poem that you can read by importing the `this` module.
```py
import this
```
It has wonderful lessons that the authors of the language learned while designing the python language.
In the same tradition we've done the same thing. Folks who have made significant contributions have also been asked to
contribute to the poem.
You can read it via:
```py
from sklego import this
```
```console
{poem}
```
"""

with DESTINATION_PATH.open(mode="w") as destination:
destination.write(content)
56 changes: 0 additions & 56 deletions docs/this.md

This file was deleted.

3 changes: 3 additions & 0 deletions mkdocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,6 @@ nav:

not_in_nav: |
_static
hooks:
- docs/generate_this_content.py

0 comments on commit 9f4d7fa

Please sign in to comment.