Skip to content

Commit d6f28bd

Browse files
marc-hbhenrikbrixandersen
authored andcommitted
doc: external_content: exclude backup files
For most people, this should be only an optimization. For Emacs TRAMP (ssh) users, this fixes the following build failure when a file is not saved yet. This build failure happens because TRAMP creates backup files on the local host and seems to use deliberately broken symlinks as "bookmarks" to those local files. file snippets/.#index.rst snippets/.#index.rst: broken symbolic link to [email protected] ``` Traceback ========= Traceback (most recent call last): File "/usr/lib/python3.13/site-packages/sphinx/events.py", in emit results.append(listener.handler(self.app, *args)) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File " doc/_extensions/zephyr/external_content.py", in sync_contents shutil.copy(src, dst) ~~~~~~~~~~~^^^^^^^^^^ File "/usr/lib/python3.13/shutil.py", line 428, in copy copyfile(src, dst, follow_symlinks=follow_symlinks) ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.13/shutil.py", line 260, in copyfile with open(src, 'rb') as fsrc: ~~~~^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: '___/zephyr/snippets/.#index.rst' ``` Just for the record, these backup files were already discussed in commit bab7df9 (".gitignore: do not ignore .\#* files") Signed-off-by: Marc Herbert <[email protected]>
1 parent 1282481 commit d6f28bd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

doc/_extensions/zephyr/external_content.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,19 @@ def sync_contents(app: Sphinx) -> None:
108108
if not f.is_dir()
109109
)
110110

111+
def _pattern_excludes(f):
112+
# backup files
113+
return f.match('.#*') or f.match('*~')
114+
111115
for content in app.config.external_content_contents:
112116
prefix_src, glob = content
113117
for src in prefix_src.glob(glob):
114118
if src.is_dir():
115119
to_copy.extend(
116-
[(f, prefix_src) for f in src.glob("**/*") if not f.is_dir()]
120+
[(f, prefix_src) for f in src.glob("**/*") if
121+
(not f.is_dir() and not _pattern_excludes(f))]
117122
)
118-
else:
123+
elif not _pattern_excludes(src):
119124
to_copy.append((src, prefix_src))
120125

121126
for entry in to_copy:

0 commit comments

Comments
 (0)