Skip to content

Commit d1b853b

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

2 files changed

Lines changed: 72 additions & 75 deletions

File tree

docs/explanation.rst

Lines changed: 62 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -141,52 +141,52 @@ 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
Documents, downloads, and media
164-
================================
164+
===============================
165165

166166
Use these dirs when saving or opening files that belong in the user's library:
167167

168168
.. list-table::
169-
:widths: 30 20 50
170-
:header-rows: 1
171-
172-
* - Property
173-
- XDG variable
174-
- Typical use
175-
* - ``user_documents_dir``
176-
- ``XDG_DOCUMENTS_DIR``
177-
- Exported reports, user-authored files
178-
* - ``user_downloads_dir``
179-
- ``XDG_DOWNLOAD_DIR``
180-
- Files fetched from the internet at user request
181-
* - ``user_pictures_dir``
182-
- ``XDG_PICTURES_DIR``
183-
- Images the user owns
184-
* - ``user_videos_dir``
185-
- ``XDG_VIDEOS_DIR``
186-
- Video files the user owns
187-
* - ``user_music_dir``
188-
- ``XDG_MUSIC_DIR``
189-
- Audio files the user owns
169+
:widths: 30 20 50
170+
:header-rows: 1
171+
172+
- - Property
173+
- XDG variable
174+
- Typical use
175+
- - ``user_documents_dir``
176+
- ``XDG_DOCUMENTS_DIR``
177+
- Exported reports, user-authored files
178+
- - ``user_downloads_dir``
179+
- ``XDG_DOWNLOAD_DIR``
180+
- Files fetched from the internet at user request
181+
- - ``user_pictures_dir``
182+
- ``XDG_PICTURES_DIR``
183+
- Images the user owns
184+
- - ``user_videos_dir``
185+
- ``XDG_VIDEOS_DIR``
186+
- Video files the user owns
187+
- - ``user_music_dir``
188+
- ``XDG_MUSIC_DIR``
189+
- Audio files the user owns
190190

191191
.. code-block:: python
192192
@@ -195,48 +195,46 @@ Use these dirs when saving or opening files that belong in the user's library:
195195
# Save an exported report where the user expects documents
196196
report = user_documents_path() / "report.pdf"
197197
198-
Do not use ``user_documents_dir`` to store application data or config. If the file would confuse the user if
199-
they opened the folder, it belongs in ``user_data_dir`` instead.
198+
Do not use ``user_documents_dir`` to store application data or config. If the file would confuse the user if they opened
199+
the folder, it belongs in ``user_data_dir`` instead.
200200

201201
Desktop, projects, and public share
202-
=====================================
202+
===================================
203203

204204
.. list-table::
205-
:widths: 30 20 50
206-
:header-rows: 1
207-
208-
* - Property
209-
- XDG variable
210-
- Typical use
211-
* - ``user_desktop_dir``
212-
- ``XDG_DESKTOP_DIR``
213-
- Shortcut files, launchers (rarely needed in code)
214-
* - ``user_projects_dir``
215-
- ``XDG_PROJECTS_DIR``
216-
- Root directory for user's coding projects (`recently added to xdg-user-dirs
217-
<https://gitlab.freedesktop.org/xdg/xdg-user-dirs/-/commit/217cae71c620ed2b3ed2936256ece68defccc6ab>`_)
218-
* - ``user_publicshare_dir``
219-
- ``XDG_PUBLICSHARE_DIR``
220-
- Files shared with other users on the same machine
221-
222-
On Windows, ``user_publicshare_dir`` returns ``C:\Users\Public`` (``%PUBLIC%``) — a machine-wide shared
223-
folder, not per-user. This matches what Rust ``dirs`` and Java ``directories-jvm`` return, following the
224-
platform convention.
205+
:widths: 30 20 50
206+
:header-rows: 1
207+
208+
- - Property
209+
- XDG variable
210+
- Typical use
211+
- - ``user_desktop_dir``
212+
- ``XDG_DESKTOP_DIR``
213+
- Shortcut files, launchers (rarely needed in code)
214+
- - ``user_projects_dir``
215+
- ``XDG_PROJECTS_DIR``
216+
- Root directory for user's coding projects (`recently added to xdg-user-dirs
217+
<https://gitlab.freedesktop.org/xdg/xdg-user-dirs/-/commit/217cae71c620ed2b3ed2936256ece68defccc6ab>`_)
218+
- - ``user_publicshare_dir``
219+
- ``XDG_PUBLICSHARE_DIR``
220+
- Files shared with other users on the same machine
221+
222+
On Windows, ``user_publicshare_dir`` returns ``C:\Users\Public`` (``%PUBLIC%``) — a machine-wide shared folder, not
223+
per-user. This matches what Rust ``dirs`` and Java ``directories-jvm`` return, following the platform convention.
225224

226225
Templates
227226
=========
228227

229-
``user_templates_dir`` (``XDG_TEMPLATES_DIR``) points to the folder used by file managers for new-file
230-
templates. macOS has no platform-defined templates directory; ``~/Templates`` is returned as a pragmatic
231-
fallback.
228+
``user_templates_dir`` (``XDG_TEMPLATES_DIR``) points to the folder used by file managers for new-file templates. macOS
229+
has no platform-defined templates directory; ``~/Templates`` is returned as a pragmatic fallback.
232230

233231
Fonts
234232
=====
235233

236234
``user_fonts_dir`` points to the per-user font installation directory:
237235

238-
- **Linux**: ``$XDG_DATA_HOME/fonts`` (default ``~/.local/share/fonts``) — derived from ``$XDG_DATA_HOME``,
239-
not a dedicated env var. See the `XDG Base Directory Specification
236+
- **Linux**: ``$XDG_DATA_HOME/fonts`` (default ``~/.local/share/fonts``) — derived from ``$XDG_DATA_HOME``, not a
237+
dedicated env var. See the `XDG Base Directory Specification
240238
<https://specifications.freedesktop.org/basedir/latest/>`_.
241239
- **macOS**: ``~/Library/Fonts``
242240
- **Windows**: ``%LOCALAPPDATA%\Microsoft\Windows\Fonts`` — the per-user font location added in Windows 10
@@ -254,19 +252,18 @@ Fonts
254252
Preference directory
255253
**********************
256254

257-
``user_preference_dir`` is meaningful mainly on macOS, where Apple's conventions distinguish two separate
258-
locations:
255+
``user_preference_dir`` is meaningful mainly on macOS, where Apple's conventions distinguish two separate locations:
259256

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

263-
On Linux and Windows, ``user_preference_dir`` is an alias for ``user_config_dir`` — the XDG and Windows
264-
conventions make no such distinction. On Android, it also aliases ``user_config_dir``.
260+
On Linux and Windows, ``user_preference_dir`` is an alias for ``user_config_dir`` — the XDG and Windows conventions make
261+
no such distinction. On Android, it also aliases ``user_config_dir``.
265262

266263
Use ``user_preference_dir`` when you specifically need to follow Apple's `File System Programming Guide
267264
<https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html>`_
268-
and store preference files in ``~/Library/Preferences``. For most cross-platform applications
269-
``user_config_dir`` is sufficient.
265+
and store preference files in ``~/Library/Preferences``. For most cross-platform applications ``user_config_dir`` is
266+
sufficient.
270267

271268
**************************
272269
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)