Skip to content

Commit 5a8c384

Browse files
committed
docs: simplify layout — virtualenv-style toctree captions, definition lists over list-table
1 parent dba63b8 commit 5a8c384

2 files changed

Lines changed: 42 additions & 56 deletions

File tree

docs/explanation.rst

Lines changed: 24 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -160,68 +160,39 @@ The ``xdg-user-dirs`` tool lets users relocate them. Set the corresponding envir
160160
(``XDG_DOCUMENTS_DIR``, ``XDG_DOWNLOAD_DIR``, etc.) to override on a per-session basis. On macOS and
161161
Windows, ``platformdirs`` returns the platform-conventional location.
162162

163-
Documents, downloads, and media
164-
================================
163+
Media and user-facing directories
164+
==================================
165165

166-
Use these dirs when saving or opening files that belong in the user's library:
166+
Use these when your app saves or opens files the user should see in their own folders:
167167

168-
.. 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
168+
``user_documents_dir`` (``XDG_DOCUMENTS_DIR``)
169+
Exported reports, user-authored files. Save here when the file is *for the user*, not the app.
170+
171+
``user_downloads_dir`` (``XDG_DOWNLOAD_DIR``)
172+
Files fetched from the internet at the user's request.
173+
174+
``user_pictures_dir`` / ``user_videos_dir`` / ``user_music_dir``
175+
Platform media libraries. Use when importing or exporting to the user's existing collection.
176+
177+
``user_desktop_dir`` (``XDG_DESKTOP_DIR``)
178+
Shortcut files and launchers. Rarely needed directly in code.
179+
180+
``user_projects_dir`` (``XDG_PROJECTS_DIR``)
181+
Root directory for the user's coding projects. `Recently added to xdg-user-dirs
182+
<https://gitlab.freedesktop.org/xdg/xdg-user-dirs/-/commit/217cae71c620ed2b3ed2936256ece68defccc6ab>`_.
183+
184+
``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.
190187

191188
.. code-block:: python
192189
193190
from platformdirs import user_documents_path
194191
195-
# Save an exported report where the user expects documents
196192
report = user_documents_path() / "report.pdf"
197193
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.
200-
201-
Desktop, projects, and public share
202-
=====================================
203-
204-
.. 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.
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.
225196

226197
Templates
227198
=========

docs/index.rst

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,30 @@ and Android.
4444
Keep multiple app versions side by side with the ``version`` parameter.
4545

4646
.. toctree::
47-
:maxdepth: 2
48-
:caption: Contents
47+
:hidden:
48+
:caption: Tutorial
4949

5050
tutorial
51+
52+
.. toctree::
53+
:hidden:
54+
:caption: How-to guides
55+
5156
howto
52-
explanation
57+
58+
.. toctree::
59+
:hidden:
60+
:caption: Reference
61+
5362
parameters
5463
api
5564
platforms
65+
66+
.. toctree::
67+
:hidden:
68+
:caption: Explanation
69+
70+
explanation
5671
changelog
5772

5873
********************

0 commit comments

Comments
 (0)