transcript 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- transcript-0.4.0/CHANGELOG.md +33 -0
- transcript-0.4.0/LICENSE +21 -0
- transcript-0.4.0/MANIFEST.in +26 -0
- transcript-0.4.0/PKG-INFO +201 -0
- transcript-0.4.0/README.md +150 -0
- transcript-0.4.0/docs/changelog.md +8 -0
- transcript-0.4.0/docs/getting-started.md +47 -0
- transcript-0.4.0/docs/html-jinja.md +51 -0
- transcript-0.4.0/docs/hub.md +34 -0
- transcript-0.4.0/docs/index.md +27 -0
- transcript-0.4.0/docs/javascript.md +36 -0
- transcript-0.4.0/docs/operators.md +61 -0
- transcript-0.4.0/docs/project.md +56 -0
- transcript-0.4.0/docs/publishing.md +66 -0
- transcript-0.4.0/docs/scss.md +52 -0
- transcript-0.4.0/mkdocs.yml +51 -0
- transcript-0.4.0/pyproject.toml +99 -0
- transcript-0.4.0/setup.cfg +4 -0
- transcript-0.4.0/src/transcript/__init__.py +112 -0
- transcript-0.4.0/src/transcript/builders/__init__.py +1 -0
- transcript-0.4.0/src/transcript/builders/html/__init__.py +6 -0
- transcript-0.4.0/src/transcript/builders/html/__init__.pyi +796 -0
- transcript-0.4.0/src/transcript/builders/html/args.py +25 -0
- transcript-0.4.0/src/transcript/builders/html/attrs.py +189 -0
- transcript-0.4.0/src/transcript/builders/html/html.py +81 -0
- transcript-0.4.0/src/transcript/builders/jinja.py +228 -0
- transcript-0.4.0/src/transcript/builders/js.py +280 -0
- transcript-0.4.0/src/transcript/builders/scss.py +393 -0
- transcript-0.4.0/src/transcript/builders/xml.py +166 -0
- transcript-0.4.0/src/transcript/core/__init__.py +14 -0
- transcript-0.4.0/src/transcript/core/ai.py +116 -0
- transcript-0.4.0/src/transcript/core/config.py +29 -0
- transcript-0.4.0/src/transcript/core/container.py +120 -0
- transcript-0.4.0/src/transcript/core/factory.py +180 -0
- transcript-0.4.0/src/transcript/core/fingerprint.py +265 -0
- transcript-0.4.0/src/transcript/core/meta.py +41 -0
- transcript-0.4.0/src/transcript/core/registers.py +53 -0
- transcript-0.4.0/src/transcript/core/stubs.py +19 -0
- transcript-0.4.0/src/transcript/io/__init__.py +12 -0
- transcript-0.4.0/src/transcript/io/file.py +40 -0
- transcript-0.4.0/src/transcript/io/hub.py +191 -0
- transcript-0.4.0/src/transcript/io/json_data.py +185 -0
- transcript-0.4.0/src/transcript/io/load.py +154 -0
- transcript-0.4.0/src/transcript/io/renderer.py +49 -0
- transcript-0.4.0/src/transcript/presets/__init__.py +63 -0
- transcript-0.4.0/src/transcript/presets/forms.py +108 -0
- transcript-0.4.0/src/transcript/presets/html.py +247 -0
- transcript-0.4.0/src/transcript/presets/jinja.py +119 -0
- transcript-0.4.0/src/transcript/presets/scss.py +221 -0
- transcript-0.4.0/src/transcript/presets/tailwind.py +392 -0
- transcript-0.4.0/src/transcript/project.py +223 -0
- transcript-0.4.0/src/transcript/purge.py +171 -0
- transcript-0.4.0/src/transcript/py.typed +0 -0
- transcript-0.4.0/src/transcript.egg-info/PKG-INFO +201 -0
- transcript-0.4.0/src/transcript.egg-info/SOURCES.txt +56 -0
- transcript-0.4.0/src/transcript.egg-info/dependency_links.txt +1 -0
- transcript-0.4.0/src/transcript.egg-info/requires.txt +27 -0
- transcript-0.4.0/src/transcript.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.4.0] - 2026-03-25
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `load()` / `html_to_data()` / `data_to_container()` — HTML/JSON round-trip for regeneration
|
|
13
|
+
- JavaScript builders (`JS`, `JSFunction`, `JSIf`, `JSClass`, …)
|
|
14
|
+
- Automatic BEM helpers (`BEM`, `BEMElement`, `BEMModifier`, nested `CSSClass`)
|
|
15
|
+
- Tailwind-like utility presets (`Tailwind`, `tw`, `utility`)
|
|
16
|
+
- `Project` with templates/static paths and `generate()`
|
|
17
|
+
- SCSS class purge (`purge_scss`) similar to Tailwind content scanning
|
|
18
|
+
- `Hub` client for fetching/posting `JsonData` prebuilds
|
|
19
|
+
- IO helpers: `File`, `JsonData`, `Renderer`
|
|
20
|
+
- MkDocs documentation under `docs/`
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- Package metadata prepared for PyPI publication
|
|
25
|
+
- Core runtime dependency reduced to `python-dotenv` (Jinja/preview/AI as extras)
|
|
26
|
+
- Version bump to `0.4.0`
|
|
27
|
+
|
|
28
|
+
## [0.3.1] - 2026-03-01
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
|
|
32
|
+
- HTML / Jinja2 / SCSS container builders with `<<` / `>>`
|
|
33
|
+
- Presets for documents, forms and base stylesheets
|
transcript-0.4.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Marcin Kallas
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include LICENSE
|
|
3
|
+
include CHANGELOG.md
|
|
4
|
+
include pyproject.toml
|
|
5
|
+
include mkdocs.yml
|
|
6
|
+
recursive-include docs *.md
|
|
7
|
+
recursive-include src/transcript *.py
|
|
8
|
+
recursive-include src/transcript *.pyi
|
|
9
|
+
recursive-include src/transcript py.typed
|
|
10
|
+
|
|
11
|
+
exclude .env
|
|
12
|
+
exclude *.env
|
|
13
|
+
exclude .env.*
|
|
14
|
+
exclude secrets/*
|
|
15
|
+
exclude *.key
|
|
16
|
+
exclude *.pem
|
|
17
|
+
|
|
18
|
+
recursive-exclude src/transcript/old *
|
|
19
|
+
recursive-exclude tests *
|
|
20
|
+
recursive-exclude docs/site *
|
|
21
|
+
recursive-exclude __pycache__ *
|
|
22
|
+
recursive-exclude .mypy_cache *
|
|
23
|
+
recursive-exclude .pytest_cache *
|
|
24
|
+
|
|
25
|
+
global-exclude *.pyc *.pyo *.pyd
|
|
26
|
+
global-exclude *~ *.swp
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: transcript
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Python DSL for composing HTML, Jinja2, SCSS and JavaScript with << / >> data-flow operators
|
|
5
|
+
Author-email: Marcin Kallas <marcin.kallas@gmail.com>
|
|
6
|
+
Maintainer-email: Marcin Kallas <marcin.kallas@gmail.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/itelementsadmin/transcript
|
|
9
|
+
Project-URL: Documentation, https://github.com/itelementsadmin/transcript#readme
|
|
10
|
+
Project-URL: Repository, https://github.com/itelementsadmin/transcript
|
|
11
|
+
Project-URL: Issues, https://github.com/itelementsadmin/transcript/issues
|
|
12
|
+
Project-URL: Changelog, https://github.com/itelementsadmin/transcript/blob/main/CHANGELOG.md
|
|
13
|
+
Keywords: html,scss,css,jinja2,javascript,dsl,codegen,templates,tailwind,bem,static-site
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
|
22
|
+
Classifier: Topic :: Software Development :: Code Generators
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Classifier: Topic :: Text Processing :: Markup :: HTML
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.13
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
30
|
+
Provides-Extra: jinja
|
|
31
|
+
Requires-Dist: jinja2>=3.1.6; extra == "jinja"
|
|
32
|
+
Provides-Extra: preview
|
|
33
|
+
Requires-Dist: websockets>=15.0.1; extra == "preview"
|
|
34
|
+
Requires-Dist: watchdog>=6.0.0; extra == "preview"
|
|
35
|
+
Provides-Extra: ai
|
|
36
|
+
Requires-Dist: langchain>=0.3.27; extra == "ai"
|
|
37
|
+
Requires-Dist: langchain-openai>=0.3.34; extra == "ai"
|
|
38
|
+
Requires-Dist: langchain-google-genai>=2.1.12; extra == "ai"
|
|
39
|
+
Requires-Dist: langchain-ollama>=0.3.9; extra == "ai"
|
|
40
|
+
Requires-Dist: pydantic>=2.11.9; extra == "ai"
|
|
41
|
+
Provides-Extra: dev
|
|
42
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
43
|
+
Requires-Dist: build>=1.2; extra == "dev"
|
|
44
|
+
Requires-Dist: twine>=5.0; extra == "dev"
|
|
45
|
+
Provides-Extra: docs
|
|
46
|
+
Requires-Dist: mkdocs>=1.6; extra == "docs"
|
|
47
|
+
Requires-Dist: mkdocs-material>=9.5; extra == "docs"
|
|
48
|
+
Provides-Extra: all
|
|
49
|
+
Requires-Dist: transcript[ai,jinja,preview]; extra == "all"
|
|
50
|
+
Dynamic: license-file
|
|
51
|
+
|
|
52
|
+
# transcript
|
|
53
|
+
|
|
54
|
+
Python DSL for composing **HTML**, **Jinja2**, **SCSS** and **JavaScript** as nested code containers.
|
|
55
|
+
Data flows with overloaded operators `<<` (inject) and `>>` (export).
|
|
56
|
+
|
|
57
|
+
[](https://pypi.org/project/transcript/)
|
|
58
|
+
[](https://pypi.org/project/transcript/)
|
|
59
|
+
[](LICENSE)
|
|
60
|
+
|
|
61
|
+
## Install
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pip install transcript
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Optional extras:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pip install transcript[jinja] # Jinja2 runtime
|
|
71
|
+
pip install transcript[preview] # live preview helpers
|
|
72
|
+
pip install transcript[ai] # LangChain helpers
|
|
73
|
+
pip install transcript[dev] # pytest, build, twine
|
|
74
|
+
pip install transcript[docs] # MkDocs
|
|
75
|
+
pip install transcript[all]
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Requires **Python 3.13+**.
|
|
79
|
+
|
|
80
|
+
## Quick start
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from transcript import Div, File, HTMLArg, P, SCSS
|
|
84
|
+
from transcript.presets import HTML5Document
|
|
85
|
+
|
|
86
|
+
page = HTML5Document(title='Hello', lang='en')
|
|
87
|
+
hero = Div()
|
|
88
|
+
hero << HTMLArg('id', 'top') << P('Built with transcript')
|
|
89
|
+
page.body << hero
|
|
90
|
+
|
|
91
|
+
page >> File('templates/index.html')
|
|
92
|
+
html = page >> str
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Core ideas
|
|
96
|
+
|
|
97
|
+
Every block (tag, rule, function) is a **container**: opening, body, closing.
|
|
98
|
+
|
|
99
|
+
| Expression | Meaning |
|
|
100
|
+
|---|---|
|
|
101
|
+
| `a << b` | inject block / value into `a` |
|
|
102
|
+
| `a << HTMLArg(...)` / `XMLArg(...)` | set opening-tag attributes |
|
|
103
|
+
| `a << File(...)` | inject file contents |
|
|
104
|
+
| `a << JsonData(...)` | attrs + nested content from JSON |
|
|
105
|
+
| `a << CSSClass('hero')` | add CSS class name to `class` |
|
|
106
|
+
| `a >> str` | export generated code |
|
|
107
|
+
| `a >> File('out.html')` | write to disk |
|
|
108
|
+
| `a >> JsonData()` | serialize structure to JSON |
|
|
109
|
+
| `a >> Renderer()` | push code into a renderer |
|
|
110
|
+
|
|
111
|
+
Reverse the pipeline with `load`:
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
from transcript import load
|
|
115
|
+
|
|
116
|
+
data = load('templates/index.html') # JsonData
|
|
117
|
+
tree = load('templates/index.html', as_container=True)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## SCSS, BEM and Tailwind-like utilities
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from transcript import BEM, CSSClass, Tailwind, tw, Div
|
|
124
|
+
|
|
125
|
+
card = BEM('card', display='grid')
|
|
126
|
+
card << CSSClass('title', font_size='1.25rem') # &__title
|
|
127
|
+
card.modifier('featured') # &--featured
|
|
128
|
+
|
|
129
|
+
Div(class_=tw('flex', 'items-center', 'gap-4', 'p-4', 'bg-white'))
|
|
130
|
+
sheet = Tailwind(utilities=('layout', 'spacing', 'color'))
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## JavaScript
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
from transcript import JS, JSFunction, JSLine, File
|
|
137
|
+
|
|
138
|
+
script = JS()
|
|
139
|
+
script << JSFunction('init', 'root', JSLine("root.classList.add('ready')"))
|
|
140
|
+
script >> File('static/app.js')
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Project generate + purge
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
from transcript import Project, JS, tw, Div
|
|
147
|
+
from transcript.presets import HTML5Document
|
|
148
|
+
from transcript.presets.tailwind import Tailwind
|
|
149
|
+
|
|
150
|
+
project = Project('myapp')
|
|
151
|
+
page = HTML5Document(title='App')
|
|
152
|
+
page.body << Div(class_=tw('flex', 'gap-4', 'p-4'))
|
|
153
|
+
project.add('index.html', page)
|
|
154
|
+
project.add('app.scss', Tailwind(utilities=('layout', 'spacing')))
|
|
155
|
+
project.add('app.js', JS())
|
|
156
|
+
project.generate() # writes files; purges unused utility classes
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Hub (prebuild store)
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
from transcript import Hub, JsonData
|
|
163
|
+
|
|
164
|
+
hub = Hub() # TRANSCRIPT_HUB_URL + token/api_key from .env
|
|
165
|
+
block = hub.get('hero-card')
|
|
166
|
+
hub.post(page >> JsonData(), prebuild_id='home')
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
See [`.env.example`](.env.example) for variable names.
|
|
170
|
+
|
|
171
|
+
## Documentation
|
|
172
|
+
|
|
173
|
+
Full docs live in [`docs/`](docs/):
|
|
174
|
+
|
|
175
|
+
- [Getting started](docs/getting-started.md)
|
|
176
|
+
- [Operators & IO](docs/operators.md)
|
|
177
|
+
- [HTML & Jinja](docs/html-jinja.md)
|
|
178
|
+
- [SCSS / BEM / Tailwind](docs/scss.md)
|
|
179
|
+
- [JavaScript](docs/javascript.md)
|
|
180
|
+
- [Project & purge](docs/project.md)
|
|
181
|
+
- [Publishing to PyPI](docs/publishing.md)
|
|
182
|
+
|
|
183
|
+
Build the site locally:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
pip install transcript[docs]
|
|
187
|
+
mkdocs serve
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Development
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
python -m venv .venv
|
|
194
|
+
.venv\Scripts\activate # Windows
|
|
195
|
+
pip install -e ".[dev]"
|
|
196
|
+
pytest
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## License
|
|
200
|
+
|
|
201
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# transcript
|
|
2
|
+
|
|
3
|
+
Python DSL for composing **HTML**, **Jinja2**, **SCSS** and **JavaScript** as nested code containers.
|
|
4
|
+
Data flows with overloaded operators `<<` (inject) and `>>` (export).
|
|
5
|
+
|
|
6
|
+
[](https://pypi.org/project/transcript/)
|
|
7
|
+
[](https://pypi.org/project/transcript/)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install transcript
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Optional extras:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install transcript[jinja] # Jinja2 runtime
|
|
20
|
+
pip install transcript[preview] # live preview helpers
|
|
21
|
+
pip install transcript[ai] # LangChain helpers
|
|
22
|
+
pip install transcript[dev] # pytest, build, twine
|
|
23
|
+
pip install transcript[docs] # MkDocs
|
|
24
|
+
pip install transcript[all]
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Requires **Python 3.13+**.
|
|
28
|
+
|
|
29
|
+
## Quick start
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from transcript import Div, File, HTMLArg, P, SCSS
|
|
33
|
+
from transcript.presets import HTML5Document
|
|
34
|
+
|
|
35
|
+
page = HTML5Document(title='Hello', lang='en')
|
|
36
|
+
hero = Div()
|
|
37
|
+
hero << HTMLArg('id', 'top') << P('Built with transcript')
|
|
38
|
+
page.body << hero
|
|
39
|
+
|
|
40
|
+
page >> File('templates/index.html')
|
|
41
|
+
html = page >> str
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Core ideas
|
|
45
|
+
|
|
46
|
+
Every block (tag, rule, function) is a **container**: opening, body, closing.
|
|
47
|
+
|
|
48
|
+
| Expression | Meaning |
|
|
49
|
+
|---|---|
|
|
50
|
+
| `a << b` | inject block / value into `a` |
|
|
51
|
+
| `a << HTMLArg(...)` / `XMLArg(...)` | set opening-tag attributes |
|
|
52
|
+
| `a << File(...)` | inject file contents |
|
|
53
|
+
| `a << JsonData(...)` | attrs + nested content from JSON |
|
|
54
|
+
| `a << CSSClass('hero')` | add CSS class name to `class` |
|
|
55
|
+
| `a >> str` | export generated code |
|
|
56
|
+
| `a >> File('out.html')` | write to disk |
|
|
57
|
+
| `a >> JsonData()` | serialize structure to JSON |
|
|
58
|
+
| `a >> Renderer()` | push code into a renderer |
|
|
59
|
+
|
|
60
|
+
Reverse the pipeline with `load`:
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from transcript import load
|
|
64
|
+
|
|
65
|
+
data = load('templates/index.html') # JsonData
|
|
66
|
+
tree = load('templates/index.html', as_container=True)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## SCSS, BEM and Tailwind-like utilities
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
from transcript import BEM, CSSClass, Tailwind, tw, Div
|
|
73
|
+
|
|
74
|
+
card = BEM('card', display='grid')
|
|
75
|
+
card << CSSClass('title', font_size='1.25rem') # &__title
|
|
76
|
+
card.modifier('featured') # &--featured
|
|
77
|
+
|
|
78
|
+
Div(class_=tw('flex', 'items-center', 'gap-4', 'p-4', 'bg-white'))
|
|
79
|
+
sheet = Tailwind(utilities=('layout', 'spacing', 'color'))
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## JavaScript
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
from transcript import JS, JSFunction, JSLine, File
|
|
86
|
+
|
|
87
|
+
script = JS()
|
|
88
|
+
script << JSFunction('init', 'root', JSLine("root.classList.add('ready')"))
|
|
89
|
+
script >> File('static/app.js')
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Project generate + purge
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from transcript import Project, JS, tw, Div
|
|
96
|
+
from transcript.presets import HTML5Document
|
|
97
|
+
from transcript.presets.tailwind import Tailwind
|
|
98
|
+
|
|
99
|
+
project = Project('myapp')
|
|
100
|
+
page = HTML5Document(title='App')
|
|
101
|
+
page.body << Div(class_=tw('flex', 'gap-4', 'p-4'))
|
|
102
|
+
project.add('index.html', page)
|
|
103
|
+
project.add('app.scss', Tailwind(utilities=('layout', 'spacing')))
|
|
104
|
+
project.add('app.js', JS())
|
|
105
|
+
project.generate() # writes files; purges unused utility classes
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Hub (prebuild store)
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
from transcript import Hub, JsonData
|
|
112
|
+
|
|
113
|
+
hub = Hub() # TRANSCRIPT_HUB_URL + token/api_key from .env
|
|
114
|
+
block = hub.get('hero-card')
|
|
115
|
+
hub.post(page >> JsonData(), prebuild_id='home')
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
See [`.env.example`](.env.example) for variable names.
|
|
119
|
+
|
|
120
|
+
## Documentation
|
|
121
|
+
|
|
122
|
+
Full docs live in [`docs/`](docs/):
|
|
123
|
+
|
|
124
|
+
- [Getting started](docs/getting-started.md)
|
|
125
|
+
- [Operators & IO](docs/operators.md)
|
|
126
|
+
- [HTML & Jinja](docs/html-jinja.md)
|
|
127
|
+
- [SCSS / BEM / Tailwind](docs/scss.md)
|
|
128
|
+
- [JavaScript](docs/javascript.md)
|
|
129
|
+
- [Project & purge](docs/project.md)
|
|
130
|
+
- [Publishing to PyPI](docs/publishing.md)
|
|
131
|
+
|
|
132
|
+
Build the site locally:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
pip install transcript[docs]
|
|
136
|
+
mkdocs serve
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Development
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
python -m venv .venv
|
|
143
|
+
.venv\Scripts\activate # Windows
|
|
144
|
+
pip install -e ".[dev]"
|
|
145
|
+
pytest
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## License
|
|
149
|
+
|
|
150
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Getting started
|
|
2
|
+
|
|
3
|
+
## Requirements
|
|
4
|
+
|
|
5
|
+
- Python **3.13+**
|
|
6
|
+
- Core dependency: `python-dotenv` (used by `Hub`)
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install transcript
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Editable install for development:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
git clone <your-repo-url>
|
|
18
|
+
cd transcript
|
|
19
|
+
python -m venv .venv
|
|
20
|
+
# Windows:
|
|
21
|
+
.venv\Scripts\activate
|
|
22
|
+
pip install -e ".[dev]"
|
|
23
|
+
pytest
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## First page
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
from transcript import Div, File, HTMLArg, P
|
|
30
|
+
from transcript.presets import HTML5Document
|
|
31
|
+
|
|
32
|
+
page = HTML5Document(title='Start', lang='pl')
|
|
33
|
+
hero = Div()
|
|
34
|
+
hero << HTMLArg('id', 'hero') << P('Witaj w transcript')
|
|
35
|
+
page.body << hero
|
|
36
|
+
|
|
37
|
+
print(page >> str)
|
|
38
|
+
page >> File('templates/index.html')
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Mental model
|
|
42
|
+
|
|
43
|
+
1. Create containers (`Div()`, `SCSS(...)`, `JSFunction(...)`, …)
|
|
44
|
+
2. Compose them with `<<`
|
|
45
|
+
3. Export with `>>`
|
|
46
|
+
|
|
47
|
+
See [Operators & IO](operators.md) for the full operator table.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# HTML & Jinja
|
|
2
|
+
|
|
3
|
+
## HTML tags
|
|
4
|
+
|
|
5
|
+
All common HTML5 tags are generated as classes (`Div`, `Span`, `Form`, …) from `transcript.builders.html`.
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
from transcript import Div, Img, P, Ul, Li
|
|
9
|
+
|
|
10
|
+
Div(P('Hello'), id='box', class_='card')
|
|
11
|
+
Img(src='/logo.svg', alt='Logo') # void / self-closing
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Use `HTMLArg` for explicit attributes (including boolean ones):
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
from transcript import Button, HTMLArg
|
|
18
|
+
|
|
19
|
+
Button('Save') << HTMLArg('disabled') << HTMLArg('class', 'btn', 'btn-primary')
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Presets
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from transcript.presets import HTML5Document, LoginForm, Navbar
|
|
26
|
+
|
|
27
|
+
page = HTML5Document(title='App', lang='pl', css=['/static/app.css'])
|
|
28
|
+
page.body << Navbar(brand='App', links=(('/', 'Home'),))
|
|
29
|
+
page.body << LoginForm()
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Jinja2 builders
|
|
33
|
+
|
|
34
|
+
Builders emit Jinja syntax as text (no template execution required at build time):
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from transcript import JinjaBlock, JinjaExtends, JinjaFor, JinjaVar, Li, Ul
|
|
38
|
+
|
|
39
|
+
items = Ul()
|
|
40
|
+
items << JinjaFor('item', 'items', Li(JinjaVar('item.name')))
|
|
41
|
+
|
|
42
|
+
page = Div()
|
|
43
|
+
page << JinjaExtends('base.html')
|
|
44
|
+
page << JinjaBlock('content', items)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Install the optional runtime if you later render templates yourself:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install transcript[jinja]
|
|
51
|
+
```
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Hub API
|
|
2
|
+
|
|
3
|
+
`Hub` talks to a remote prebuild store using JSON.
|
|
4
|
+
|
|
5
|
+
## Configuration
|
|
6
|
+
|
|
7
|
+
Constructor args or environment (also via `.env`):
|
|
8
|
+
|
|
9
|
+
| Variable | Purpose |
|
|
10
|
+
|---|---|
|
|
11
|
+
| `TRANSCRIPT_HUB_URL` / `HUB_URL` | API base URL |
|
|
12
|
+
| `TRANSCRIPT_HUB_TOKEN` / `HUB_TOKEN` | Bearer token |
|
|
13
|
+
| `TRANSCRIPT_HUB_API_KEY` / `HUB_API_KEY` | `X-API-Key` header |
|
|
14
|
+
| `TRANSCRIPT_HUB_USERNAME` / `HUB_USERNAME` | Basic auth user |
|
|
15
|
+
| `TRANSCRIPT_HUB_PASSWORD` / `HUB_PASSWORD` | Basic auth password |
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from transcript import Div, Hub, JsonData
|
|
21
|
+
|
|
22
|
+
hub = Hub() # or Hub(url='https://…', token='…')
|
|
23
|
+
data = hub.get('hero-card')
|
|
24
|
+
Div() << data
|
|
25
|
+
|
|
26
|
+
hub.post(page >> JsonData(), prebuild_id='home', title='Home page')
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Endpoints used by default:
|
|
30
|
+
|
|
31
|
+
- `GET {url}/prebuilds/{id}`
|
|
32
|
+
- `POST {url}/prebuilds` or `POST {url}/prebuilds/{id}`
|
|
33
|
+
|
|
34
|
+
Errors raise `HubError` with optional HTTP `status` and `payload`.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# transcript
|
|
2
|
+
|
|
3
|
+
**transcript** is a Python library for generating frontend artifacts — HTML, Jinja2 templates, SCSS/CSS and JavaScript — using nested **containers** and data-flow operators.
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
from transcript import Div, P, File
|
|
7
|
+
|
|
8
|
+
card = Div(class_='card')
|
|
9
|
+
card << P('Hello')
|
|
10
|
+
card >> File('templates/card.html')
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Why
|
|
14
|
+
|
|
15
|
+
- One model for tags, style rules and JS blocks: open → body → close
|
|
16
|
+
- `<<` injects children / attributes / files / JSON
|
|
17
|
+
- `>>` exports to string, file, JSON or a renderer
|
|
18
|
+
- Presets for HTML documents, forms, BEM and Tailwind-like utilities
|
|
19
|
+
- `Project.generate()` writes a whole app tree and can purge unused CSS classes
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install transcript
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Continue with [Getting started](getting-started.md).
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# JavaScript
|
|
2
|
+
|
|
3
|
+
JavaScript uses the same container model as HTML/SCSS.
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
from transcript import (
|
|
7
|
+
File, JS, JSConst, JSFunction, JSIf, JSLine, JSReturn,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
script = JS()
|
|
11
|
+
script << JSConst('API', "'/api'")
|
|
12
|
+
script << JSFunction(
|
|
13
|
+
'ready',
|
|
14
|
+
'el',
|
|
15
|
+
JSIf('el', JSLine("el.classList.add('is-ready')")),
|
|
16
|
+
JSReturn('el'),
|
|
17
|
+
)
|
|
18
|
+
script >> File('static/js/app.js')
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Main classes
|
|
22
|
+
|
|
23
|
+
| Class | Role |
|
|
24
|
+
|---|---|
|
|
25
|
+
| `JS` / `JSModule` | File / module root |
|
|
26
|
+
| `JSBlock` | Generic `{ ... }` |
|
|
27
|
+
| `JSFunction` | `function` or arrow (`arrow=True`) |
|
|
28
|
+
| `JSClass` / `JSMethod` | ES class bodies |
|
|
29
|
+
| `JSIf` / `JSElif` / `JSElse` / `JSFor` / `JSWhile` | Control flow |
|
|
30
|
+
| `JSConst` / `JSLet` / `JSVar` | Declarations |
|
|
31
|
+
| `JSLine` / `JSCall` / `JSReturn` | Statements |
|
|
32
|
+
| `JSImport` / `JSExport` | Modules |
|
|
33
|
+
| `JSObject` | Object literal |
|
|
34
|
+
| `JSComment` | `//` or `/* */` |
|
|
35
|
+
|
|
36
|
+
Chain with `<<` exactly like HTML builders.
|