Skip to content

Commit 712bc1c

Browse files
kamilkrzyskowsquidfunk
authored andcommitted
Fixed info plugin to gather all files recursively
1 parent 15f1506 commit 712bc1c

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

Diff for: material/plugins/info/plugin.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
from io import BytesIO
3131
from markdown.extensions.toc import slugify
3232
from mkdocs.plugins import BasePlugin, event_priority
33-
from mkdocs.structure.files import get_files
3433
from mkdocs.utils import get_theme_dir
3534
from zipfile import ZipFile, ZIP_DEFLATED
3635

@@ -115,15 +114,12 @@ def on_config(self, config):
115114
# Create self-contained example from project
116115
files: list[str] = []
117116
with ZipFile(archive, "a", ZIP_DEFLATED, False) as f:
118-
for path in ["mkdocs.yml", "requirements.txt"]:
119-
if os.path.isfile(path):
117+
for abs_root, dirnames, filenames in os.walk(os.getcwd()):
118+
for name in filenames:
119+
path = os.path.join(abs_root, name)
120+
path = os.path.relpath(path, os.path.curdir)
120121
f.write(path, os.path.join(example, path))
121122

122-
# Append all files visible to MkDocs
123-
for file in get_files(config):
124-
path = os.path.relpath(file.abs_src_path, os.path.curdir)
125-
f.write(path, os.path.join(example, path))
126-
127123
# Add information on installed packages
128124
f.writestr(
129125
os.path.join(example, "requirements.lock.txt"),

Diff for: src/plugins/info/plugin.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
from io import BytesIO
3131
from markdown.extensions.toc import slugify
3232
from mkdocs.plugins import BasePlugin, event_priority
33-
from mkdocs.structure.files import get_files
3433
from mkdocs.utils import get_theme_dir
3534
from zipfile import ZipFile, ZIP_DEFLATED
3635

@@ -115,15 +114,12 @@ def on_config(self, config):
115114
# Create self-contained example from project
116115
files: list[str] = []
117116
with ZipFile(archive, "a", ZIP_DEFLATED, False) as f:
118-
for path in ["mkdocs.yml", "requirements.txt"]:
119-
if os.path.isfile(path):
117+
for abs_root, dirnames, filenames in os.walk(os.getcwd()):
118+
for name in filenames:
119+
path = os.path.join(abs_root, name)
120+
path = os.path.relpath(path, os.path.curdir)
120121
f.write(path, os.path.join(example, path))
121122

122-
# Append all files visible to MkDocs
123-
for file in get_files(config):
124-
path = os.path.relpath(file.abs_src_path, os.path.curdir)
125-
f.write(path, os.path.join(example, path))
126-
127123
# Add information on installed packages
128124
f.writestr(
129125
os.path.join(example, "requirements.lock.txt"),

0 commit comments

Comments
 (0)