Skip to content

Commit 3cb7be4

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 5a29b6b commit 3cb7be4

2 files changed

Lines changed: 33 additions & 35 deletions

File tree

docs/explanation.rst

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -182,27 +182,27 @@ Use ``user_log_dir`` and ``site_log_dir`` for application logs:
182182
format="%(asctime)s - %(levelname)s - %(message)s",
183183
)
184184
185-
******************************
185+
************************
186186
User media directories
187-
******************************
187+
************************
188188

189-
Unlike app dirs (data, config, cache, etc.), media dirs are **not** scoped to the app name. They point to
190-
standard user-facing folders that exist independently of any particular application. Use them when your app
191-
needs to read from or save into a folder the user already expects — not when storing application state.
189+
Unlike app dirs (data, config, cache, etc.), media dirs are **not** scoped to the app name. They point to standard
190+
user-facing folders that exist independently of any particular application. Use them when your app needs to read from or
191+
save into a folder the user already expects — not when storing application state.
192192

193193
The distinction matters:
194194

195195
- ``user_data_dir("MyApp")`` → ``~/.local/share/MyApp`` — your app's private storage
196196
- ``user_documents_dir()`` → ``~/Documents`` — the user's document library
197197

198198
On Linux, media dirs are defined by the `XDG user-dirs specification
199-
<https://www.freedesktop.org/wiki/Software/xdg-user-dirs/>`_ and stored in ``~/.config/user-dirs.dirs``.
200-
The ``xdg-user-dirs`` tool lets users relocate them. Set the corresponding environment variable
201-
(``XDG_DOCUMENTS_DIR``, ``XDG_DOWNLOAD_DIR``, etc.) to override on a per-session basis. On macOS and
202-
Windows, ``platformdirs`` returns the platform-conventional location.
199+
<https://www.freedesktop.org/wiki/Software/xdg-user-dirs/>`_ and stored in ``~/.config/user-dirs.dirs``. The
200+
``xdg-user-dirs`` tool lets users relocate them. Set the corresponding environment variable (``XDG_DOCUMENTS_DIR``,
201+
``XDG_DOWNLOAD_DIR``, etc.) to override on a per-session basis. On macOS and Windows, ``platformdirs`` returns the
202+
platform-conventional location.
203203

204204
Media and user-facing directories
205-
==================================
205+
=================================
206206

207207
Use these when your app saves or opens files the user should see in their own folders:
208208

@@ -223,32 +223,31 @@ Use these when your app saves or opens files the user should see in their own fo
223223
<https://gitlab.freedesktop.org/xdg/xdg-user-dirs/-/commit/217cae71c620ed2b3ed2936256ece68defccc6ab>`_.
224224

225225
``user_publicshare_dir`` (``XDG_PUBLICSHARE_DIR``)
226-
Files shared with other local accounts. On Windows this is the machine-wide ``C:\Users\Public``
227-
(``%PUBLIC%``), not a per-user directory.
226+
Files shared with other local accounts. On Windows this is the machine-wide ``C:\Users\Public`` (``%PUBLIC%``), not
227+
a per-user directory.
228228

229229
.. code-block:: python
230230
231231
from platformdirs import user_documents_path
232232
233233
report = user_documents_path() / "report.pdf"
234234
235-
Do not use these to store application state or config — if the file would confuse the user when they browse
236-
the folder, it belongs in ``user_data_dir`` instead.
235+
Do not use these to store application state or config — if the file would confuse the user when they browse the folder,
236+
it belongs in ``user_data_dir`` instead.
237237

238238
Templates
239239
=========
240240

241-
``user_templates_dir`` (``XDG_TEMPLATES_DIR``) points to the folder used by file managers for new-file
242-
templates. macOS has no platform-defined templates directory; ``~/Templates`` is returned as a pragmatic
243-
fallback.
241+
``user_templates_dir`` (``XDG_TEMPLATES_DIR``) points to the folder used by file managers for new-file templates. macOS
242+
has no platform-defined templates directory; ``~/Templates`` is returned as a pragmatic fallback.
244243

245244
Fonts
246245
=====
247246

248247
``user_fonts_dir`` points to the per-user font installation directory:
249248

250-
- **Linux**: ``$XDG_DATA_HOME/fonts`` (default ``~/.local/share/fonts``) — derived from ``$XDG_DATA_HOME``,
251-
not a dedicated env var. See the `XDG Base Directory Specification
249+
- **Linux**: ``$XDG_DATA_HOME/fonts`` (default ``~/.local/share/fonts``) — derived from ``$XDG_DATA_HOME``, not a
250+
dedicated env var. See the `XDG Base Directory Specification
252251
<https://specifications.freedesktop.org/basedir/latest/>`_.
253252
- **macOS**: ``~/Library/Fonts``
254253
- **Windows**: ``%LOCALAPPDATA%\Microsoft\Windows\Fonts`` — the per-user font location added in Windows 10
@@ -266,19 +265,18 @@ Fonts
266265
Preference directory
267266
**********************
268267

269-
``user_preference_dir`` is meaningful mainly on macOS, where Apple's conventions distinguish two separate
270-
locations:
268+
``user_preference_dir`` is meaningful mainly on macOS, where Apple's conventions distinguish two separate locations:
271269

272270
- ``~/Library/Application Support/AppName`` — long-term application data, databases, plug-ins
273271
- ``~/Library/Preferences/AppName`` — user-adjustable preference files (historically ``.plist``)
274272

275-
On Linux and Windows, ``user_preference_dir`` is an alias for ``user_config_dir`` — the XDG and Windows
276-
conventions make no such distinction. On Android, it also aliases ``user_config_dir``.
273+
On Linux and Windows, ``user_preference_dir`` is an alias for ``user_config_dir`` — the XDG and Windows conventions make
274+
no such distinction. On Android, it also aliases ``user_config_dir``.
277275

278276
Use ``user_preference_dir`` when you specifically need to follow Apple's `File System Programming Guide
279277
<https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html>`_
280-
and store preference files in ``~/Library/Preferences``. For most cross-platform applications
281-
``user_config_dir`` is sufficient.
278+
and store preference files in ``~/Library/Preferences``. For most cross-platform applications ``user_config_dir`` is
279+
sufficient.
282280

283281
**************************
284282
User vs site directories

docs/platforms.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,9 @@ See also: :ref:`api:User desktop directory`
406406

407407
See also: :ref:`api:User projects directory`
408408

409-
Defined by `$XDG_PROJECTS_DIR <https://gitlab.freedesktop.org/xdg/xdg-user-dirs/-/commit/217cae71c620ed2b3ed2936256ece68defccc6ab>`_
410-
(recently added to xdg-user-dirs).
409+
Defined by `$XDG_PROJECTS_DIR
410+
<https://gitlab.freedesktop.org/xdg/xdg-user-dirs/-/commit/217cae71c620ed2b3ed2936256ece68defccc6ab>`_ (recently added
411+
to xdg-user-dirs).
411412

412413
.. tab-set::
413414

@@ -439,9 +440,8 @@ See also: :ref:`api:User public share directory`
439440

440441
Defined by `$XDG_PUBLICSHARE_DIR <https://www.freedesktop.org/wiki/Software/xdg-user-dirs/>`_.
441442

442-
On Windows, this is the machine-wide ``C:\Users\Public`` (``%PUBLIC%``), shared across all local accounts —
443-
not a per-user directory. See `FOLDERID_Public
444-
<https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid>`_.
443+
On Windows, this is the machine-wide ``C:\Users\Public`` (``%PUBLIC%``), shared across all local accounts — not a
444+
per-user directory. See `FOLDERID_Public <https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid>`_.
445445

446446
.. tab-set::
447447

@@ -503,9 +503,9 @@ platform-defined templates directory; ``~/Templates`` is returned as a pragmatic
503503

504504
See also: :ref:`api:User fonts directory`
505505

506-
Derived from ``$XDG_DATA_HOME/fonts`` on Linux (no dedicated env var). See the `XDG Base Directory
507-
Specification <https://specifications.freedesktop.org/basedir/latest/>`_. On Windows, uses the per-user font
508-
location added in Windows 10.
506+
Derived from ``$XDG_DATA_HOME/fonts`` on Linux (no dedicated env var). See the `XDG Base Directory Specification
507+
<https://specifications.freedesktop.org/basedir/latest/>`_. On Windows, uses the per-user font location added in Windows
508+
10.
509509

510510
.. tab-set::
511511

@@ -534,8 +534,8 @@ location added in Windows 10.
534534

535535
See also: :ref:`api:User preference directory`
536536

537-
On macOS, ``~/Library/Preferences`` is distinct from ``~/Library/Application Support`` (``user_config_dir``).
538-
See `Apple's File System Programming Guide
537+
On macOS, ``~/Library/Preferences`` is distinct from ``~/Library/Application Support`` (``user_config_dir``). See
538+
`Apple's File System Programming Guide
539539
<https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html>`_.
540540
On all other platforms, this aliases ``user_config_dir``.
541541

0 commit comments

Comments
 (0)