Skip to content

Commit 579c406

Browse files
committed
docs: add prose explaining the directory-choice flowchart
1 parent 5a29b6b commit 579c406

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

docs/explanation.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,18 @@ purpose. Application authors write platform-agnostic code while end users get pa
1717
Choosing the right directory
1818
******************************
1919

20-
``platformdirs`` provides different directory types for different kinds of data. Choose based on the data's purpose and
21-
lifetime.
20+
The first question is always: who owns this data? **App-internal data** — databases, caches, config files, logs — goes
21+
in an app dir scoped to your app name. **User-facing data** — files the user would browse to directly — goes in a media
22+
dir that sits alongside their documents, music, and photos.
23+
24+
Within app dirs, the next question is whether the data is essential. If it can be regenerated, use ``cache`` (fast
25+
lookups) or ``runtime`` (session-only sockets and PIDs). If it is important but not critical, use ``state`` (window
26+
positions, recent files). For settings use ``config``; on macOS, ``preference`` gives you the separate
27+
``~/Library/Preferences`` location that Apple convention expects. Use ``data`` for everything else that must survive
28+
app updates.
29+
30+
Within media dirs, pick the folder that matches the file's type from the user's perspective — not what your app does
31+
with it. A font your app installs for the user goes in ``fonts``, not ``data``.
2232

2333
.. mermaid::
2434

0 commit comments

Comments
 (0)