Skip to content

Rewrite the client as a package against client spec 2.3 - #370

Draft
SpikeTheDragon40k wants to merge 2 commits into
tldr-pages:mainfrom
SpikeTheDragon40k:rewrite
Draft

SpikeTheDragon40k wants to merge 2 commits into
tldr-pages:mainfrom
SpikeTheDragon40k:rewrite

Conversation

@SpikeTheDragon40k

Copy link
Copy Markdown
Member

Replace the single-file tldr.py with a small src/tldr package whose modules map to sections of the client specification: settings, languages, platforms, stores, cache, resolver, render and cli.

  • Configuration is parsed once from the environment, not at import time.
  • One resolver (platform before language) replaces three lookup loops.
  • A placeholder scanner replaces regexes and sentinel strings, fixing triple braces and </> being stripped from descriptions.
  • Platforms are discovered from the cache (dos, cisco-ios, ...).
  • Adds -S/-E, the spec's issue link on missing pages, and sends warnings to stderr so stdout only carries the page.
  • The cache downloads per-language archives and swaps them in atomically, refreshing when older than TLDR_CACHE_MAX_AGE.
  • termcolor is no longer a dependency.

Replace the single-file tldr.py with a small src/tldr package whose
modules map to sections of the client specification: settings,
languages, platforms, stores, cache, resolver, render and cli.

- Configuration is parsed once from the environment, not at import time.
- One resolver (platform before language) replaces three lookup loops.
- A placeholder scanner replaces regexes and sentinel strings, fixing
  triple braces and `<`/`>` being stripped from descriptions.
- Platforms are discovered from the cache (dos, cisco-ios, ...).
- Adds -S/-E, the spec's issue link on missing pages, and sends
  warnings to stderr so stdout only carries the page.
- The cache downloads per-language archives and swaps them in
  atomically, refreshing when older than TLDR_CACHE_MAX_AGE.
- termcolor is no longer a dependency.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Managor

Managor commented Oct 26, 2026

Copy link
Copy Markdown
Member

Converting to a draft as this will most definitely not be merged.

@Managor
Managor marked this pull request as draft October 26, 2026 15:12
The package split (settings, languages, platforms, http, stores, cache,
resolver, render, cli) traded one kind of indirection for another. Go
back to the legacy shape: one tldr.py with the legacy function names,
flags, environment variables, cache layout and termcolor/shtab
dependencies, keeping the fixes.

- Page lookup is a single find_page loop over platform, language and
  source. The user cache, every $XDG_DATA_DIRS/tldr, a -s checkout and a
  remote mirror are just entries in the source list, so adding a
  location (as tldr-pages#329 did) is one line instead of a flag threaded through
  four functions and a third copy of the loop.
- Fix the tldr-pages#329 lookup bugs: every XDG_DATA_DIRS entry is used, and a
  system page on the host platform beats a user-cache page on another
  platform.
- The cache stamp records the languages fetched, so changing LANG
  downloads the new language instead of waiting for the cache to expire.
- Unescape \{\{ and \}\} inside placeholders (aws-dynamodb, fakedata, x8).
- TLDR_DOWNLOAD_CACHE_LOCATION takes the tldr.zip URL again, and
  TLDR_CACHE_ENABLED=0 falls back to the cache on network errors, as
  documented.

Rendering every page of tldr-pages (47,670) with both clients only
differs where the legacy client dropped `<`/`>` from descriptions or
mangled `{{[, ]+}}`-style placeholders (tuc, pw-loopback).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants