Packs¶
Realizes A-PACK-1 (registry) and A-PACK-2 (built-in packs); requirements R-PACK-001 – R-PACK-009.
PackRegistry — packs/__init__.py¶
PackRegistry(extra_dirs)searchesextra_dirsthenBUILTIN_DIR(thepacks/package directory).registry(extra_dirs)is anlru_cached factory so the fence, the extension and the CLI share one registry per set of directories.get(id)loadspack.json, loads the parent first (defaultbase), mergeselements,modifiers,chrome,sizes,iconsand per-modetokensover the parent's, recordsown_elements, and caches thePack(M-PACK-1)._elementbuilds eachElementDef(M-PACK-2) and rejects a missingrole.ids()lists pack directories;for_module(name)builds a lower-cased module index on first use.Pack.lineage()(root first),Pack.font(name)(alias lookup up the lineage),Pack.chrome_for(device),Pack.css_text().
Built-in packs — packs/<id>/¶
| Directory | Contents |
|---|---|
base/ |
the core vocabulary (90 elements), base tokens, generic modifier maps, the structural CSS of every role (pack.css, ~650 lines) |
swiftui/, fluent/, mui/, angular-material/, sapui5/, bootstrap/, shadcn/ |
framework packs (R-PACK-008), each extends base |
The packs are written only in shared/packs/<id>/ (R-REPO-002.C1). The Python build copies them
into python/src/mockitdown/packs/<id>/, where BUILTIN_DIR finds them, and ships them as package
data (python/pyproject.toml [tool.setuptools.package-data]: packs/*/pack.json,
packs/*/pack.css). Edit shared/, then reinstall or run python/tools/sync_shared.py.
The contract tests — tests/test_packs.py¶
| Test | Checks |
|---|---|
test_packs_load_and_roles_exist |
every pack loads; every element's role is an r_<role> method; every pack declares modules |
test_css_is_scoped |
every selector of a non-base pack.css starts with .mkd-pack-<id> |
test_css_has_no_appearance_branching |
no data-appearance / prefers-color-scheme in non-base CSS |
test_tokens_have_light_and_dark |
light tokens ⊇ base light tokens; dark tokens non-empty |
test_module_names_are_unique |
no module name claimed by two packs |
test_every_element_renders |
Name() renders without errors (except argument) for every element of every pack |
test_stylesheet_builds_for_all |
the all-packs stylesheet assembles |
Writing a pack is described in the Pack authoring guide.
Revision history¶
| Version | Date | Change |
|---|---|---|
| 0.1.0 | 2026-11-24 | Page written |
| 0.3.2 | 2026-11-25 | Packs live in shared/packs and are copied into the package at build 1 |