Skip to content

✨ feat: add user_publicshare_dir, user_templates_dir, user_fonts_dir, user_preference_dir#491

Merged
gaborbernat merged 8 commits into
mainfrom
xdg-gaps
May 28, 2026
Merged

✨ feat: add user_publicshare_dir, user_templates_dir, user_fonts_dir, user_preference_dir#491
gaborbernat merged 8 commits into
mainfrom
xdg-gaps

Conversation

@gaborbernat
Copy link
Copy Markdown
Member

@gaborbernat gaborbernat commented May 27, 2026

Cross-ecosystem research (Rust dirs/directories, Java directories-jvm, Go adrg/xdg) shows four directories consistently supported elsewhere but absent from platformdirs: public share, templates, fonts, and preference. Two come directly from the XDG user-dirs spec (XDG_PUBLICSHARE_DIR, XDG_TEMPLATES_DIR), one is derived from XDG_DATA_HOME (fonts), and one exposes the macOS-specific ~/Library/Preferences split that Rust and Java both model explicitly.

user_publicshare_dir and user_templates_dir follow the existing media-dir pattern: unix.py reads user-dirs.dirs via _get_user_media_dir and XDGMixin overrides via the env var. user_fonts_dir has no dedicated env var — it is derived from $XDG_DATA_HOME/fonts, so XDGMixin watches XDG_DATA_HOME instead. user_preference_dir aliases user_config_dir on Linux, Windows, and Android; on macOS it returns ~/Library/Preferences/AppName, a genuinely separate location from ~/Library/Application Support.

Three platform-specific decisions: macOS returns ~/Templates as a pragmatic fallback for user_templates_dir (Rust/Java return None, but the str return type requires a path); Windows user_publicshare_dir returns C:\Users\Public (%PUBLIC%) — a machine-wide folder, not per-user, matching Rust/Java convention; Windows user_fonts_dir uses %LOCALAPPDATA%\Microsoft\Windows\Fonts, the real per-user writable font location added in Windows 10.

Documentation: explanation.rst gains a prose introduction and a complete colored flowchart covering all directory types (app dirs and user media dirs); platforms.rst has per-platform tables for all four new properties with upstream spec links; api.rst adds autofunction entries; README updated with the full directory type listing; docs toctree reorganised with Diátaxis-style captions.

… user_preference_dir

Cross-ecosystem research (Rust dirs/directories, Java directories-jvm,
Go adrg/xdg) shows these four directories are consistently supported
elsewhere but absent from platformdirs. Two come directly from the
xdg-user-dirs spec (XDG_PUBLICSHARE_DIR, XDG_TEMPLATES_DIR), one is
derived from XDG_DATA_HOME (fonts), and one exposes the macOS-specific
~/Library/Preferences split that Rust and Java both model explicitly.

publicshare and templates follow the existing media-dir pattern: unix.py
reads user-dirs.dirs via _get_user_media_dir, XDGMixin overrides via the
env var. fonts has no dedicated env var so XDGMixin derives it from
XDG_DATA_HOME/fonts instead. preference aliases user_config_dir on all
platforms except macOS, where ~/Library/Preferences is a genuinely
separate location from ~/Library/Application Support.

macOS has no standard templates directory; ~/Templates is returned as a
pragmatic fallback (consistent with Go's approach) to preserve the str
return contract. Windows fonts uses %LOCALAPPDATA%\Microsoft\Windows\Fonts,
the real per-user writable location added in Windows 10.
Add explanation, per-platform tables, and API references for
user_publicshare_dir, user_templates_dir, user_fonts_dir, and
user_preference_dir. Also add the missing "User media directories"
section to explanation.rst covering the full set of non-app-scoped
dirs, with upstream spec links (XDG user-dirs, Apple File System
Guide, Windows KNOWNFOLDERID).

Notable callouts: macOS has no native templates dir (~/Templates
fallback), Windows publicshare is machine-wide C:\Users\Public,
fonts on Windows uses the Win10+ per-user location, and
preference_dir is only distinct from config_dir on macOS.
@gaborbernat gaborbernat requested a review from ofek as a code owner May 27, 2026 22:49
@gaborbernat gaborbernat added documentation Improvements or additions to documentation enhancement New feature or request labels May 27, 2026
Add the missing user-facing/media dirs branch (documents, downloads,
pictures, videos, music, fonts, templates, projects, desktop,
publicshare) and the macOS preference dir node. Color coding:
blue = app dirs, green = user media dirs, purple = macOS-only
preference, amber = decision nodes.
@gaborbernat gaborbernat enabled auto-merge (squash) May 28, 2026 03:19
@gaborbernat gaborbernat disabled auto-merge May 28, 2026 03:21
@gaborbernat gaborbernat changed the title ✨ feat: add user_publicshare_dir, user_templates_dir, user_fonts_dir, user_preference_dir ✨ feat: add user_{publicshare,templates,fonts,preference}_dir May 28, 2026
@gaborbernat gaborbernat changed the title ✨ feat: add user_{publicshare,templates,fonts,preference}_dir ✨ feat: add user_publicshare_dir, user_templates_dir, user_fonts_dir, user_preference_dir May 28, 2026
@gaborbernat gaborbernat enabled auto-merge (squash) May 28, 2026 03:24
@gaborbernat gaborbernat merged commit 078bc61 into main May 28, 2026
32 checks passed
@gaborbernat gaborbernat deleted the xdg-gaps branch May 28, 2026 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant