Skip to content

Commit 177536a

Browse files
authored
Only copy source files if they are converted by the plugin (#222)
1 parent d72a84a commit 177536a

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
file: ./coverage.xml
8686

8787
- name: Upload test results to GitHub
88-
uses: actions/upload-artifact@v2
88+
uses: actions/upload-artifact@v4
8989
if: failure()
9090
with:
9191
name: test-results-py${{ matrix.python-version }}

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# mkdocs-jupyter Change Log
22

3+
## 0.25.1
4+
5+
- Fix issue which caused unrelated source files from being copied into the output directory.
6+
- Replace print statements with logging.
7+
38
## 0.24.3
49

510
- Fix theme selection

src/mkdocs_jupyter/plugin.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
import os
23
import pathlib
34

@@ -12,6 +13,8 @@
1213

1314
from . import convert
1415

16+
logger = logging.getLogger("mkdocs.plugins.mkdocs_jupyter")
17+
1518

1619
class NotebookFile(File):
1720
"""
@@ -150,7 +153,7 @@ def _set_nb_url(self, page):
150153

151154
def on_post_page(self, output_content, page, config):
152155
# Include source
153-
if self.config["include_source"]:
156+
if self.config["include_source"] and self.should_include(page.file):
154157
from shutil import copyfile
155158

156159
nb_source = page.file.abs_src_path
@@ -160,7 +163,7 @@ def on_post_page(self, output_content, page, config):
160163

161164
os.makedirs(nb_target_dir, exist_ok=True)
162165
copyfile(nb_source, nb_target)
163-
print(f"Copied jupyter file: {nb_source} to {nb_target}")
166+
logger.info("Copied jupyter file: %s to %s", nb_source, nb_target)
164167

165168
# Include data files
166169
data_files = self.config["data_files"].get(page.file.src_path, [])
@@ -175,7 +178,7 @@ def on_post_page(self, output_content, page, config):
175178

176179
os.makedirs(data_target_dir, exist_ok=True)
177180
copyfile(data_source, data_target)
178-
print(page.data_files)
181+
logger.info("Copied data files: %s to %s", data_files, data_target_dir)
179182

180183

181184
def _get_markdown_toc(markdown_source, toc_depth):

0 commit comments

Comments
 (0)