Skip to content

fix: watch pymdownx.snippets auto_append files for changes#418

Merged
squidfunk merged 2 commits intozensical:masterfrom
pratyush618:fix/snippets-not-watched-148
Mar 10, 2026
Merged

fix: watch pymdownx.snippets auto_append files for changes#418
squidfunk merged 2 commits intozensical:masterfrom
pratyush618:fix/snippets-not-watched-148

Conversation

@pratyush618
Copy link
Copy Markdown
Contributor

Fixes #148.

Summary

  • Abbreviations (and other content) added via pymdownx.snippets auto_append were not reflected in the served site unless the including .md file was also modified
  • The root cause is that the included files (e.g. includes/abbreviations.md) were neither watched by the file watcher nor factored into the cache key
  • Removing the .cache directory was the only workaround

Changes

Follows the same pattern as source_files (used for mkdocstrings):

  • python/zensical/config.py: Added _list_snippet_files() which resolves each entry in pymdownx.snippets.auto_append against the configured base_path directories (defaulting to "."), collecting the file paths and their mtimes as snippet_files
  • crates/zensical/src/config/project.rs: Added snippet_files: Vec<(PathBuf, u64)> to Project — because Project derives Hash, a change in mtime automatically invalidates all page caches
  • crates/zensical/src/watcher.rs: Watch snippet files and trigger a full pipeline restart (Error::Disconnected) when any of them change, so all pages that include them are rebuilt

@zensical
Copy link
Copy Markdown

zensical bot commented Mar 10, 2026

All commits verified and signed off.

@pratyush618 pratyush618 force-pushed the fix/snippets-not-watched-148 branch 2 times, most recently from 435d18d to e6bc595 Compare March 10, 2026 11:35
)

Abbreviations and other content added via `pymdownx.snippets` auto_append
were not reflected in the served site unless the including `.md` file was
also modified, because the included files were neither watched nor factored
into the cache key.

Collect the files referenced in `pymdownx.snippets.auto_append` (resolved
against the configured `base_path` directories) and expose them as
`snippet_files` in the project configuration, mirroring the existing
`source_files` mechanism used for mkdocstrings. The watcher now monitors
these files and triggers a full pipeline restart when any of them change,
ensuring all pages that include them are rebuilt with the updated content.

Signed-off-by: Pratyush Sharma <56130065+pratyush618@users.noreply.github.com>
Signed-off-by: squidfunk <martin.donath@squidfunk.com>
@squidfunk squidfunk force-pushed the fix/snippets-not-watched-148 branch from 40db094 to 44d659d Compare March 10, 2026 15:59
@squidfunk squidfunk merged commit 6c911ca into zensical:master Mar 10, 2026
1 check passed
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.

Abbreviations are not updated after adding a new one

2 participants