Skip to content

Commit

Permalink
Fixed info plugin to gather all files recursively
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkrzyskow authored and squidfunk committed Mar 5, 2024
1 parent 15f1506 commit 712bc1c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
12 changes: 4 additions & 8 deletions material/plugins/info/plugin.py
Expand Up @@ -30,7 +30,6 @@
from io import BytesIO
from markdown.extensions.toc import slugify
from mkdocs.plugins import BasePlugin, event_priority
from mkdocs.structure.files import get_files
from mkdocs.utils import get_theme_dir
from zipfile import ZipFile, ZIP_DEFLATED

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

# Append all files visible to MkDocs
for file in get_files(config):
path = os.path.relpath(file.abs_src_path, os.path.curdir)
f.write(path, os.path.join(example, path))

# Add information on installed packages
f.writestr(
os.path.join(example, "requirements.lock.txt"),
Expand Down
12 changes: 4 additions & 8 deletions src/plugins/info/plugin.py
Expand Up @@ -30,7 +30,6 @@
from io import BytesIO
from markdown.extensions.toc import slugify
from mkdocs.plugins import BasePlugin, event_priority
from mkdocs.structure.files import get_files
from mkdocs.utils import get_theme_dir
from zipfile import ZipFile, ZIP_DEFLATED

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

# Append all files visible to MkDocs
for file in get_files(config):
path = os.path.relpath(file.abs_src_path, os.path.curdir)
f.write(path, os.path.join(example, path))

# Add information on installed packages
f.writestr(
os.path.join(example, "requirements.lock.txt"),
Expand Down

0 comments on commit 712bc1c

Please sign in to comment.