Skip to content

Commit 16be58d

Browse files
author
Laurent Franceschetti
committed
Migrate all tests toward the mkdocs-test framework (#244)
1 parent 59f82db commit 16be58d

File tree

16 files changed

+138
-1389
lines changed

16 files changed

+138
-1389
lines changed

mkdocs_macros/plugin.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -712,43 +712,6 @@ def render(self, markdown: str, force_rendering:bool=False) -> str:
712712
else:
713713
return error_message
714714

715-
def _save_debug_file(self, page:Page,
716-
rendered_markdown:str) -> str:
717-
"""
718-
Saves a page to disk for debug/testing purposes,
719-
with a reconstituted YAML front matter.
720-
721-
Argument:
722-
- page: the Page (page.markdown contains the old markdown)
723-
- rendered_mardkown (the new markdown)
724-
725-
Returns the saved document.
726-
"""
727-
dest_file = os.path.join(self.rendered_macros_dir,
728-
page.file.src_path)
729-
debug(f"Saving page '{page.title}' in destination file:",
730-
dest_file)
731-
# Create the subdirectory hierarchy if necessary
732-
os.makedirs(os.path.dirname(dest_file), exist_ok=True)
733-
if page.meta:
734-
# recreate the YAML header:
735-
yaml_values = yaml.dump(dict(page.meta),
736-
default_flow_style=False, sort_keys=False)
737-
document = '\n'.join([ '---',
738-
YAML_HEADER_WARNING,
739-
yaml_values.strip(),
740-
'---',
741-
rendered_markdown
742-
])
743-
else:
744-
# re-generate the document with YAML header
745-
document = rendered_markdown
746-
# write on file:
747-
debug("Saved ")
748-
with open(dest_file, 'w') as f:
749-
f.write(document)
750-
return document
751-
752715

753716
# ----------------------------------
754717
# Standard Hooks for a mkdocs plugin
@@ -989,11 +952,6 @@ def on_page_markdown(self, markdown, page:Page,
989952
for func in self.post_macro_functions:
990953
func(self)
991954

992-
# save the rendered page, with its YAML header
993-
if get_log_level('DEBUG'):
994-
self._save_debug_file(page,
995-
rendered_markdown=self.markdown)
996-
997955
return self.markdown
998956

999957
def on_post_build(self, config: config_options.Config):

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
# Initialization
1313
# --------------------
1414

15-
VERSION_NUMBER = '1.3.3'
15+
VERSION_NUMBER = '1.3.4'
1616

1717
# required if you want to run document/test
1818
# pip install 'mkdocs-macros-plugin[test]'
1919
TEST_REQUIRE = ['mkdocs-macros-test', 'mkdocs-material>=6.2',
20-
'mkdocs-include-markdown-plugin']
20+
'mkdocs-include-markdown-plugin', 'mkdocs-test']
2121

2222
# --------------------
2323
# Setup

0 commit comments

Comments
 (0)