@@ -44,14 +44,35 @@ ruff check --fix .
4444ruff format .
4545```
4646
47- ### Styling (Tailwind CSS)
47+ ### Template Development
4848
49- ** IMPORTANT ** : Never edit ` microdocs/templates/default.css ` directly - it is auto-generated!
49+ Templates are built using Vite, which compiles HTML, CSS (Tailwind), and JavaScript into single-file outputs.
5050
51- To modify styles:
52- 1 . Edit ` microdocs/templates/default.tailwind.css ` (source file)
53- 2 . Run Tailwind CLI to compile: ` npx @tailwindcss/cli@latest -i microdocs/templates/default.tailwind.css -o microdocs/templates/default.css --minify `
54- 3 . The compiled/minified CSS will be written to ` default.css `
51+ ** Template Structure:**
52+ - Source: ` templates_src/{template_name}/ ` (root level, not in microdocs/)
53+ - ` {template_name}.html ` - HTML template with Jinja2 markup
54+ - ` {template_name}.css ` - Tailwind CSS source
55+ - ` {template_name}.js ` - JavaScript source
56+ - Output: ` microdocs/templates/{template_name}/{template_name}.html ` (single file with inlined CSS/JS)
57+
58+ ** Development workflow:**
59+ ``` bash
60+ # Start dev server with hot-reloading
61+ npm run dev
62+
63+ # Build all templates for production
64+ npm run build
65+
66+ # Preview built templates
67+ npm run preview
68+ ```
69+
70+ ** IMPORTANT** :
71+ - Never edit files in ` microdocs/templates/ ` directly - they are auto-generated by Vite!
72+ - Always edit source files in ` templates_src/ ` (at project root)
73+ - Run ` npm run build ` to compile templates after making changes
74+ - The build process automatically discovers all template directories and builds them
75+ - ` templates_src/ ` is excluded from PyPI package builds (only compiled templates are distributed)
5576
5677### Testing
5778
@@ -90,48 +111,53 @@ pytest --cov=microdocs
90111
91112When creating a new release, follow these steps ** in order** :
92113
93- 1 . ** Run full test suite** - Verify everything passes before releasing
114+ 1 . ** Build templates** - Ensure templates are up to date
115+ ``` bash
116+ npm run build
117+ ```
118+
119+ 2 . ** Run full test suite** - Verify everything passes before releasing
94120 ``` bash
95121 pytest && ruff check . && ruff format --check .
96122 ```
97123
98- 2 . ** Update version** in ` pyproject.toml `
124+ 3 . ** Update version** in ` pyproject.toml `
99125 - Bump version number
100126 - Update development status classifier if needed (Alpha → Beta → Production/Stable)
101127
102- 3 . ** Update CHANGELOG.md**
128+ 4 . ** Update CHANGELOG.md**
103129 - Move "Unreleased" section to new version heading with date
104130 - Add summary of changes (Added, Changed, Fixed, etc.)
105131 - Include deployment instructions with new version number
106132
107- 4 . ** Commit changes**
133+ 5 . ** Commit changes**
108134 ``` bash
109135 git add pyproject.toml CHANGELOG.md
110136 git commit -m " Release version X.Y.Z"
111137 ```
112138
113- 5 . ** Create git tag**
139+ 6 . ** Create git tag**
114140 ``` bash
115141 git tag -a vX.Y.Z -m " Release vX.Y.Z: brief description"
116142 ```
117143
118- 6 . ** Build the package**
144+ 7 . ** Build the package**
119145 ``` bash
120146 uv build
121147 ```
122148
123- 7 . ** Publish to PyPI**
149+ 8 . ** Publish to PyPI**
124150 ``` bash
125151 uv publish
126152 ```
127153
128- 8 . ** Push changes and tags**
154+ 9 . ** Push changes and tags**
129155 ``` bash
130156 git push
131157 git push --tags
132158 ```
133159
134- 9 . ** Update floating major version tag** (for GitHub Action compatibility)
160+ 10 . ** Update floating major version tag** (for GitHub Action compatibility)
135161 ``` bash
136162 # For v1.x.x releases, update the v1 tag
137163 git tag -f v1 vX.Y.Z
@@ -178,30 +204,34 @@ When creating a new release, follow these steps **in order**:
178204 - Returns flat list with level/id/name for each heading
179205 - ` convert_plain_text_to_html(text_content) ` : Converts plain text to HTML with line breaks
180206
181- 3 . ** Template System** (templates/default.html)
182- - Jinja2-based template rendering
183- - Single-page HTML template with Tailwind CSS and Alpine.js
184- - Uses CDN for:
185- - Tailwind CSS (includes forms, typography, aspect-ratio, line-clamp, container-queries plugins)
186- - Alpine.js 3.x for reactive UI
187- - Two-column layout:
188- - Main content area (left, flex-1)
189- - TOC sidebar (right, fixed 16rem width, sticky)
190- - Page-based navigation: sections act like pages, only one visible at a time
191- - Alpine.js state: ` activeSection ` tracks which section is displayed
192- - First section shown by default
193- - Smooth transitions between sections
194- - Dynamic navigation with active state highlighting
195- - Table of Contents (TOC):
196- - Shows all headings (H1-H6) for current section
197- - Automatically indented based on heading level (0.75rem per level)
198- - Sticky positioning (follows scroll)
199- - Each section has its own TOC
200- - Template variables:
201- - ` {{ title }} ` - Extracted from first H1 heading in first markdown file or provided via CLI
202- - ` {{ sections }} ` - List of sections with ` id ` , ` name ` , ` html ` , and ` toc ` attributes
203- - ` {{ inlined_css }} ` - CSS content from companion ` .css ` file
207+ 3 . ** Template System**
208+ - ** Build Process** : Templates are built using Vite (see Template Development section)
209+ - ** Source Location** : ` microdocs/templates_src/{template_name}/ `
210+ - ` {template_name}.html ` - Jinja2 template with embedded template tags
211+ - ` {template_name}.css ` - Tailwind CSS source
212+ - ` {template_name}.js ` - JavaScript (Alpine.js initialization)
213+ - ** Output Location** : ` microdocs/templates/{template_name}/{template_name}.html `
214+ - Single-file HTML with all CSS/JS inlined by Vite
215+ - ** Default Template** (` templates/default/default.html ` ):
216+ - Single-page HTML template with Tailwind CSS and Alpine.js
217+ - Uses CDN for Alpine.js 3.x and Tocbot
218+ - Two-column layout:
219+ - Main content area (left, flex-1)
220+ - TOC sidebar (right, fixed 16rem width, sticky)
221+ - Page-based navigation: sections act like pages, only one visible at a time
222+ - Alpine.js state: ` activeSection ` tracks which section is displayed
223+ - Smooth transitions between sections
224+ - Dynamic navigation with active state highlighting
225+ - Table of Contents (TOC):
226+ - Shows all headings (H1-H6) for current section
227+ - Automatically indented based on heading level
228+ - Sticky positioning (follows scroll)
229+ - Each section has its own TOC
230+ - ** Template Variables** (Jinja2):
231+ - ` {{ title }} ` - Extracted from first H1 or provided via CLI
232+ - ` {{ sections }} ` - List of sections with ` id ` , ` name ` , ` html ` attributes
204233 - ` {{ repo_url }} ` - Optional repository URL
234+ - ` {{ build_timestamp }} ` - Build timestamp in UTC
205235
206236### Important Notes
207237
0 commit comments