Skip to content

Commit 55d6e68

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

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
@@ -141,27 +141,27 @@ Use ``user_log_dir`` and ``site_log_dir`` for application logs:
141141
format="%(asctime)s - %(levelname)s - %(message)s",
142142
)
143143
144-
******************************
144+
************************
145145
User media directories
146-
******************************
146+
************************
147147

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

152152
The distinction matters:
153153

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

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

163163
Media and user-facing directories
164-
==================================
164+
=================================
165165

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

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

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

188188
.. code-block:: python
189189
190190
from platformdirs import user_documents_path
191191
192192
report = user_documents_path() / "report.pdf"
193193
194-
Do not use these to store application state or config — if the file would confuse the user when they browse
195-
the folder, it belongs in ``user_data_dir`` instead.
194+
Do not use these to store application state or config — if the file would confuse the user when they browse the folder,
195+
it belongs in ``user_data_dir`` instead.
196196

197197
Templates
198198
=========
199199

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

204203
Fonts
205204
=====
206205

207206
``user_fonts_dir`` points to the per-user font installation directory:
208207

209-
- **Linux**: ``$XDG_DATA_HOME/fonts`` (default ``~/.local/share/fonts``) — derived from ``$XDG_DATA_HOME``,
210-
not a dedicated env var. See the `XDG Base Directory Specification
208+
- **Linux**: ``$XDG_DATA_HOME/fonts`` (default ``~/.local/share/fonts``) — derived from ``$XDG_DATA_HOME``, not a
209+
dedicated env var. See the `XDG Base Directory Specification
211210
<https://specifications.freedesktop.org/basedir/latest/>`_.
212211
- **macOS**: ``~/Library/Fonts``
213212
- **Windows**: ``%LOCALAPPDATA%\Microsoft\Windows\Fonts`` — the per-user font location added in Windows 10
@@ -225,19 +224,18 @@ Fonts
225224
Preference directory
226225
**********************
227226

228-
``user_preference_dir`` is meaningful mainly on macOS, where Apple's conventions distinguish two separate
229-
locations:
227+
``user_preference_dir`` is meaningful mainly on macOS, where Apple's conventions distinguish two separate locations:
230228

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

234-
On Linux and Windows, ``user_preference_dir`` is an alias for ``user_config_dir`` — the XDG and Windows
235-
conventions make no such distinction. On Android, it also aliases ``user_config_dir``.
232+
On Linux and Windows, ``user_preference_dir`` is an alias for ``user_config_dir`` — the XDG and Windows conventions make
233+
no such distinction. On Android, it also aliases ``user_config_dir``.
236234

237235
Use ``user_preference_dir`` when you specifically need to follow Apple's `File System Programming Guide
238236
<https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html>`_
239-
and store preference files in ``~/Library/Preferences``. For most cross-platform applications
240-
``user_config_dir`` is sufficient.
237+
and store preference files in ``~/Library/Preferences``. For most cross-platform applications ``user_config_dir`` is
238+
sufficient.
241239

242240
**************************
243241
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)