Skip to content

Commit 35fe7a9

Browse files
committed
docs: align user docs with Unreleased changes for next release
A reader review flagged several drifts between the docs and the code after the heavy Unreleased work. This commit walks through each file and brings it back in sync. README gets the biggest cleanup: the Quick Start no longer places the template tag before the first build, there is now a `mkdir assets` step so Django doesn't error out on a missing STATICFILES_DIRS entry, the watcher autoreloader and the runserver passthrough are called out in the command table, the requirements range is corrected from the fictitious "Django 4.0-6.0+" to the actually supported 4.2/5.2/6.0, and the advanced configuration example uses TAILWIND_CLI_USE_SYSTEM_BINARY plus the new opt-in TAILWIND_CLI_AUTO_SOURCE_EXTERNAL_APPS instead of a hardcoded TAILWIND_CLI_PATH. docs/usage.md loses its accidental duplicate `### watch` heading, gains a tip admonition about the auto-generated `.gitignore`, and aligns on the current default source-CSS location (which previously contradicted settings.md). docs/installation.md picks up the new `mkdir assets` step, mentions `--noreload`, and gets its own note about the auto `.gitignore`. docs/settings.md rewrites the TAILWIND_CLI_SRC_CSS entry so it agrees with usage.md on where the default file lives and who owns it. docs/development.md now mentions both the watch autoreloader and the runserver passthrough under "Daily Development". docs/index.md toctree is reordered so template_tags and base_template come before the development chapter. Typos fixed: "seperately"/"seperate", "production built" → "build".
1 parent 27b066f commit 35fe7a9

6 files changed

Lines changed: 60 additions & 41 deletions

File tree

README.md

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,15 @@ INSTALLED_APPS = [
5050
"django_tailwind_cli",
5151
]
5252

53-
# Configure static files directory
53+
# Configure static files directory — make sure it exists on disk,
54+
# Django raises an error at startup if it does not.
5455
STATICFILES_DIRS = [BASE_DIR / "assets"]
5556
```
5657

58+
```bash
59+
mkdir -p assets
60+
```
61+
5762
### 3. Set up your base template
5863

5964
Create or update your base template (e.g., `templates/base.html`):
@@ -76,25 +81,23 @@ Create or update your base template (e.g., `templates/base.html`):
7681
</html>
7782
```
7883

79-
### 4. Interactive setup (recommended for first-time users)
80-
81-
```bash
82-
python manage.py tailwind setup
83-
```
84-
85-
This will guide you through the complete setup process!
86-
87-
### 5. Start developing
84+
### 4. Start developing
8885

8986
```bash
90-
# Start development server with hot reload
87+
# Start Django's dev server with a parallel Tailwind watcher (recommended)
9188
python manage.py tailwind runserver
9289

9390
# Or run build and watch separately
9491
python manage.py tailwind watch # In one terminal
9592
python manage.py runserver # In another terminal
9693
```
9794

95+
The watcher runs under Django's own auto-reloader, so editing `settings.py` (e.g. adding a new app) restarts it automatically and picks up the new configuration on the fly. Pass `--noreload` to opt out.
96+
97+
First run creates a managed `<BASE_DIR>/.django_tailwind_cli/` directory for the CLI binary and an auto-generated `source.css`. The directory is automatically git-ignored — no entry in your project-level `.gitignore` needed.
98+
99+
> **Tip:** Prefer a guided walkthrough? Run `python manage.py tailwind setup` instead for an interactive step-by-step first-time setup.
100+
98101
### 🎉 You're ready to go!
99102

100103
Start adding Tailwind classes to your templates:
@@ -146,19 +149,21 @@ Start adding Tailwind classes to your templates:
146149

147150
### 🛠️ Management Commands
148151

149-
| Command | Purpose | Example |
150-
| -------------- | -------------------------- | ---------------------------------------- |
151-
| `setup` | Interactive setup guide | `python manage.py tailwind setup` |
152-
| `build` | Production CSS build | `python manage.py tailwind build` |
153-
| `watch` | Development file watcher | `python manage.py tailwind watch` |
154-
| `runserver` | Combined server + watcher | `python manage.py tailwind runserver` |
155-
| `config` | Show current configuration | `python manage.py tailwind config` |
156-
| `troubleshoot` | Debug common issues | `python manage.py tailwind troubleshoot` |
152+
| Command | Purpose | Example |
153+
| -------------- | ---------------------------------------------------- | ---------------------------------------- |
154+
| `setup` | Interactive first-time setup guide | `python manage.py tailwind setup` |
155+
| `build` | Production CSS build | `python manage.py tailwind build` |
156+
| `watch` | Development file watcher (Django autoreload by default) | `python manage.py tailwind watch` |
157+
| `runserver` | Django dev server + watcher (forwards any runserver flag) | `python manage.py tailwind runserver` |
158+
| `config` | Show current configuration | `python manage.py tailwind config` |
159+
| `troubleshoot` | Debug common issues | `python manage.py tailwind troubleshoot` |
160+
161+
`tailwind runserver` is a transparent passthrough: every positional argument and option (apart from `--force-default-runserver`) is forwarded verbatim to the underlying `runserver` or `runserver_plus`. Every flag those commands accept works — including `runserver_plus`-only ones like `--extra-file`, `--reloader-interval`, and `--print-sql`.
157162

158163
## 📋 Requirements
159164

160165
- **Python:** 3.10+
161-
- **Django:** 4.0-6.0+
166+
- **Django:** 4.2 LTS, 5.2, or 6.0
162167
- **Platform:** Windows, macOS, Linux (automatic platform detection)
163168

164169
## ⚙️ Configuration Examples
@@ -181,9 +186,11 @@ TAILWIND_CLI_DIST_CSS = "css/app.css"
181186
# Enable DaisyUI
182187
TAILWIND_CLI_USE_DAISY_UI = True
183188

184-
# Custom CLI path (for CI/CD)
185-
TAILWIND_CLI_PATH = "/usr/local/bin/tailwindcss"
186-
TAILWIND_CLI_AUTOMATIC_DOWNLOAD = False
189+
# Use an already-installed Tailwind binary (e.g. `brew install tailwindcss`)
190+
TAILWIND_CLI_USE_SYSTEM_BINARY = True
191+
192+
# Auto-inject @source directives for editable-installed external apps (opt-in)
193+
TAILWIND_CLI_AUTO_SOURCE_EXTERNAL_APPS = True
187194
```
188195

189196
### Production Settings

docs/development.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ python manage.py tailwind watch # Terminal 1: CSS watching
2727
python manage.py runserver # Terminal 2: Django server
2828
```
2929

30+
`tailwind watch` (and the inner watcher spawned by `tailwind runserver`) runs under Django's auto-reloader by default. Any change to a Python file — including `settings.py` — restarts the watcher, regenerates the source CSS file, and respawns the Tailwind CLI subprocess. Pass `--noreload` to disable.
31+
32+
`tailwind runserver` is a transparent wrapper around the underlying Django `runserver` / `runserver_plus` command: every runserver flag is forwarded verbatim. Consult `python manage.py runserver --help` (or `runserver_plus --help` with `django-extensions` installed) for the full list of available options.
33+
3034
## Template Development
3135

3236
1. **Create/Edit Template**

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
installation
99
usage
1010
settings
11-
development
1211
template_tags
1312
base_template
13+
development
1414
changelog
1515
```

docs/installation.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,16 @@
3535
]
3636
```
3737

38-
3. Configure the `STATICFILES_DIRS` parameter in your `settings.py` if not already configured.
38+
3. Configure the `STATICFILES_DIRS` parameter in your `settings.py` if not already configured, and make sure the referenced directory exists on disk — Django raises an error at startup if it doesn't.
3939

4040
```python
4141
STATICFILES_DIRS = [BASE_DIR / "assets"]
4242
```
4343

44+
```shell
45+
mkdir -p assets
46+
```
47+
4448
4. Add template code.
4549

4650
```htmldjango
@@ -65,7 +69,11 @@
6569
python manage.py tailwind watch
6670
```
6771

68-
If you only start the Tailwind CLI in watch mode, you have to start the debug server with the standard command `python manage.py runserver` seperately.
72+
If you only start the Tailwind CLI in watch mode, you have to start the debug server with the standard command `python manage.py runserver` separately.
73+
74+
`tailwind watch` runs under Django's auto-reloader by default, so editing `settings.py` restarts the watcher and respawns the Tailwind CLI with a fresh configuration. Pass `--noreload` to disable this.
75+
76+
6. The first run creates a managed directory at `<BASE_DIR>/.django_tailwind_cli/` for the downloaded CLI binary and the auto-generated source CSS file. This directory is automatically git-ignored via a `.gitignore` file it drops on first use — you don't need to add anything to your project-level `.gitignore`.
6977

7078
## Optional steps
7179

docs/settings.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,11 @@ TAILWIND_CLI_ASSET_NAME = "tailwindcss-extra"
143143

144144
### TAILWIND_CLI_SRC_CSS
145145

146-
**Default**: `".django_tailwind_cli/source.css"`
146+
**Default**: `".django_tailwind_cli/source.css"` (relative to `BASE_DIR`, auto-created on first use)
147147

148-
This variable can be set to a relative path and an absolute path.
148+
Path to the Tailwind CSS input file. The library manages the default file itself — it writes a minimal `@import "tailwindcss";` (plus `@plugin "daisyui";` if DaisyUI is enabled) into `<BASE_DIR>/.django_tailwind_cli/source.css` on first run and updates it when the auto-generated content drifts.
149149

150-
If it is a relative path it is assumed to be relative to `settings.BASE_DIR`. If `settings.BASE_DIR` is not defined or the file doesn't exist a `ValueError` is raised.
151-
152-
If it is an absolute path, this path is used as the input file for Tailwind CSS CLI. If the path doesn't exist, a `ValueError` is raised.
150+
Set this to point at a hand-written file if you need custom CSS alongside the Tailwind import. When `TAILWIND_CLI_SRC_CSS` is set, the library only creates the file if it doesn't yet exist and never overwrites it afterwards — you own it. A relative path is resolved against `settings.BASE_DIR`, an absolute path is used as-is.
153151

154152
### TAILWIND_CLI_DIST_CSS
155153

docs/usage.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,29 @@
66
**No.** The management commands of this library handle the download and installation of the Tailwind CLI. You don't have to deal with this. But you can configure the installation location and the version of the CLI you want to use. Take a look at the [settings](settings.md) section.
77
:::
88

9-
:::{admonition} Do I have to create my own `css/source.css` for Tailwind 4.x?
9+
:::{admonition} Do I have to create my own `source.css` for Tailwind 4.x?
1010
:class: tip
1111

12-
**No.** The management commands also take care of this step. If no `css/source.css` is present in your project, a new one with sane defaults will be created. Afterwards this file will be used and be customized by you. The default location for the file is first folder from the `STATICFILES_DIRS` of your project, but you can change this. Take a look at the [settings](settings.md) section.
12+
**No.** The management commands also take care of this step. If no source CSS file is present yet, one with sane defaults is created at `<BASE_DIR>/.django_tailwind_cli/source.css`. You can point at a hand-written file instead by setting [`TAILWIND_CLI_SRC_CSS`](settings.md#tailwind_cli_src_css) in your Django settings — the library leaves your file alone in that case.
13+
:::
14+
15+
:::{admonition} Is `.django_tailwind_cli/` safe to commit?
16+
:class: tip
17+
18+
**No, and you don't have to do anything.** On first use the library writes a `.gitignore` containing `*` into the managed directory, so the downloaded CLI binary and the auto-generated `source.css` are silently ignored by Git — no entry in your project-level `.gitignore` needed.
1319
:::
1420

1521
## Management commands
1622

1723
### build
1824

19-
Run `python manage.py tailwind build` to create an optimized production built of the stylesheet. Afterwards you are ready to deploy. Take care the this command is run before `python manage.py collectstatic` in your build process.
25+
Run `python manage.py tailwind build` to create an optimized production build of the stylesheet. Afterwards you are ready to deploy. Make sure this command runs before `python manage.py collectstatic` in your build process.
2026

2127
### watch
2228

23-
Run `python manage.py tailwind watch` to just start a tailwind watcher process if you prefer to start your debug server in a seperate shell or prefer a different solution than runserver or runserver_plus.
29+
Run `python manage.py tailwind watch` to start a Tailwind watcher process on its own — useful if you prefer to run your debug server in a separate shell or use a workflow other than `runserver` / `runserver_plus`.
2430

25-
By default the watch command runs under Django's own auto-reloader (the same one `runserver` uses). Whenever you change a Python file — including `settings.py` — the watcher restarts its Python process, regenerates the default source CSS file (picking up freshly added `INSTALLED_APPS`), and restarts the Tailwind CLI subprocess. This pairs nicely with [`TAILWIND_CLI_AUTO_SOURCE_EXTERNAL_APPS`](settings.md#tailwind_cli_auto_source_external_apps): adding an editable-installed app and updating `INSTALLED_APPS` is enough — no manual restart needed.
31+
By default the watch command runs under Django's own auto-reloader (the same one `runserver` uses). Whenever you change a Python file — including `settings.py` — the watcher restarts its Python process, regenerates the default source CSS file (picking up freshly added `INSTALLED_APPS`), and respawns the Tailwind CLI subprocess. This pairs nicely with [`TAILWIND_CLI_AUTO_SOURCE_EXTERNAL_APPS`](settings.md#tailwind_cli_auto_source_external_apps): adding an editable-installed app and updating `INSTALLED_APPS` is enough — no manual restart needed.
2632

2733
Pass `--noreload` if you want a single-process watch loop (e.g. in CI or when debugging the watcher itself):
2834

@@ -114,11 +120,7 @@ Areas covered:
114120

115121
### remove_cli
116122

117-
Run `python manage.py tailwind remove_cli` to remove the installed cli.
118-
119-
### watch
120-
121-
Run `python manage.py tailwind watch` to just start a tailwind watcher process if you prefer to start your debug server in a seperate shell or prefer a different solution than runserver or runserver_plus.
123+
Run `python manage.py tailwind remove_cli` to remove the installed CLI binary. This only works with the managed download; system binaries (`TAILWIND_CLI_USE_SYSTEM_BINARY = True`) are refused.
122124

123125
## Use with Docker Compose
124126

0 commit comments

Comments
 (0)