Simplify tempfile setup
This commit is contained in:
parent
5f5a057c34
commit
e23e44bfe9
2 changed files with 11 additions and 9 deletions
|
@ -1,15 +1,16 @@
|
|||
import tempfile
|
||||
import shutil
|
||||
import os
|
||||
from pygments.formatters.html import HtmlFormatter
|
||||
from mkdocs.structure.files import File
|
||||
from minify_html import minify
|
||||
from mkdocs.utils import write_file
|
||||
from mkdocs.utils import write_file, clean_directory
|
||||
|
||||
PYGMENTS_STYLE_DIR = tempfile.mkdtemp()
|
||||
|
||||
shutil.rmtree(PYGMENTS_STYLE_DIR, ignore_errors=True)
|
||||
os.mkdir(PYGMENTS_STYLE_DIR)
|
||||
def on_post_build(config):
|
||||
clean_directory(PYGMENTS_STYLE_DIR)
|
||||
|
||||
on_build_error = on_pre_build = on_post_build
|
||||
|
||||
def minify_css(styles: str) -> str:
|
||||
wrapped_styles = f"<style>{styles}</styles>"
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
from mkdocs.utils import meta, write_file
|
||||
from mkdocs.utils import meta, write_file, clean_directory
|
||||
from mkdocs.structure.files import File, Files
|
||||
import tempfile
|
||||
import os
|
||||
import shutil
|
||||
|
||||
TAGS_TEMP_DIR = os.path.join(tempfile.gettempdir(), "mkdocs-tags")
|
||||
TAGS_TEMP_DIR = tempfile.mkdtemp()
|
||||
|
||||
shutil.rmtree(TAGS_TEMP_DIR, ignore_errors=True)
|
||||
os.mkdir(TAGS_TEMP_DIR)
|
||||
def on_post_build(config):
|
||||
clean_directory(TAGS_TEMP_DIR)
|
||||
|
||||
on_build_error = on_pre_build = on_post_build
|
||||
|
||||
def on_files(files: Files, config):
|
||||
tags = set()
|
||||
|
|
Loading…
Reference in a new issue