diff --git a/mkdocs_exporter/browser.py b/mkdocs_exporter/browser.py index b5d988e..31f9511 100644 --- a/mkdocs_exporter/browser.py +++ b/mkdocs_exporter/browser.py @@ -40,7 +40,7 @@ async def launch(self) -> Browser: if self.launched: return self - logger.info('[PDF] Launching browser...') + logger.info('Launching browser...') self.playwright = await async_playwright().start() self.browser = await self.playwright.chromium.launch(headless=True, args=self.args) diff --git a/mkdocs_exporter/logging.py b/mkdocs_exporter/logging.py index 08769c7..e6c13cf 100644 --- a/mkdocs_exporter/logging.py +++ b/mkdocs_exporter/logging.py @@ -1,5 +1,5 @@ import logging -logger = logging.getLogger('mkdocs.plugins.mkdocs-exporter') +logger = logging.getLogger('mkdocs.plugins.mkdocs_exporter') """The logger.""" diff --git a/mkdocs_exporter/plugins/pdf/plugin.py b/mkdocs_exporter/plugins/pdf/plugin.py index cb4ad75..6ef9219 100644 --- a/mkdocs_exporter/plugins/pdf/plugin.py +++ b/mkdocs_exporter/plugins/pdf/plugin.py @@ -6,7 +6,6 @@ from typing import Optional from mkdocs.plugins import BasePlugin from mkdocs_exporter.page import Page -from mkdocs.structure.pages import Page from mkdocs.plugins import event_priority from mkdocs_exporter.logging import logger from mkdocs.livereload import LiveReloadServer @@ -111,7 +110,7 @@ def on_post_page(self, html: str, page: Page, config: dict) -> Optional[str]: return html async def render(page: Page) -> None: - logger.info('[PDF] Rendering %s...', page.file.src_path) + logger.info('Rendering PDF for %s...', page.file.src_path) pdf = await self.renderer.render(page, polyfills=self.config['polyfills']) fullpath = os.path.join(config['site_dir'], page.formats['pdf']) @@ -119,7 +118,7 @@ async def render(page: Page) -> None: with open(fullpath, 'wb+') as file: file.write(pdf) - logger.info('[PDF] File written to %s!', fullpath) + logger.info('File written to %s!', fullpath) self.tasks.append(render(page)) diff --git a/mkdocs_exporter/preprocessor.py b/mkdocs_exporter/preprocessor.py index 7f5a380..99ea2f9 100644 --- a/mkdocs_exporter/preprocessor.py +++ b/mkdocs_exporter/preprocessor.py @@ -33,7 +33,7 @@ def button(self, title: str, href: str, icon: str, **kwargs) -> Preprocessor: svg = BeautifulSoup(icon, 'lxml') button.append(svg) - self.html.find('article', { 'class': 'md-content__inner' }).insert(0, button) + self.html.find('article', {'class': 'md-content__inner'}).insert(0, button) return self diff --git a/poetry.lock b/poetry.lock index 5833308..460f6c4 100644 --- a/poetry.lock +++ b/poetry.lock @@ -279,6 +279,24 @@ webencodings = "*" doc = ["sphinx", "sphinx_rtd_theme"] test = ["flake8", "isort", "pytest"] +[[package]] +name = "flake8" +version = "3.9.2" +description = "the modular source code checker: pep8 pyflakes and co" +category = "dev" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" +files = [ + {file = "flake8-3.9.2-py2.py3-none-any.whl", hash = "sha256:bf8fd333346d844f616e8d47905ef3a3384edae6b4e9beb0c5101e25e3110907"}, + {file = "flake8-3.9.2.tar.gz", hash = "sha256:07528381786f2a6237b061f6e96610a4167b226cb926e2aa2b6b1d78057c576b"}, +] + +[package.dependencies] +importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} +mccabe = ">=0.6.0,<0.7.0" +pycodestyle = ">=2.7.0,<2.8.0" +pyflakes = ">=2.3.0,<2.4.0" + [[package]] name = "fonttools" version = "4.38.0" @@ -426,14 +444,14 @@ lxml = ["lxml"] [[package]] name = "importlib-metadata" -version = "6.6.0" +version = "4.13.0" description = "Read metadata from Python packages" category = "main" optional = false python-versions = ">=3.7" files = [ - {file = "importlib_metadata-6.6.0-py3-none-any.whl", hash = "sha256:43dd286a2cd8995d5eaef7fee2066340423b818ed3fd70adf0bad5f1fac53fed"}, - {file = "importlib_metadata-6.6.0.tar.gz", hash = "sha256:92501cdf9cc66ebd3e612f1b4f0c0765dfa42f0fa38ffb319b6bd84dd675d705"}, + {file = "importlib_metadata-4.13.0-py3-none-any.whl", hash = "sha256:8a8a81bcf996e74fee46f0d16bd3eaa382a7eb20fd82445c3ad11f4090334116"}, + {file = "importlib_metadata-4.13.0.tar.gz", hash = "sha256:dd0173e8f150d6815e098fd354f6414b0f079af4644ddfe90c71e2fc6174346d"}, ] [package.dependencies] @@ -441,7 +459,7 @@ typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""} zipp = ">=0.5" [package.extras] -docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)"] perf = ["ipython"] testing = ["flake8 (<5)", "flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)", "pytest-perf (>=0.9.2)"] @@ -668,6 +686,18 @@ files = [ {file = "MarkupSafe-2.1.2.tar.gz", hash = "sha256:abcabc8c2b26036d62d4c746381a6f7cf60aafcc653198ad678306986b09450d"}, ] +[[package]] +name = "mccabe" +version = "0.6.1" +description = "McCabe checker, plugin for flake8" +category = "dev" +optional = false +python-versions = "*" +files = [ + {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, + {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, +] + [[package]] name = "mergedeep" version = "1.3.4" @@ -824,6 +854,18 @@ greenlet = "2.0.1" pyee = "9.0.4" typing-extensions = {version = "*", markers = "python_version <= \"3.8\""} +[[package]] +name = "pycodestyle" +version = "2.7.0" +description = "Python style guide checker" +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +files = [ + {file = "pycodestyle-2.7.0-py2.py3-none-any.whl", hash = "sha256:514f76d918fcc0b55c6680472f0a37970994e07bbb80725808c17089be302068"}, + {file = "pycodestyle-2.7.0.tar.gz", hash = "sha256:c389c1d06bf7904078ca03399a4816f974a1d590090fecea0c63ec26ebaf1cef"}, +] + [[package]] name = "pycparser" version = "2.21" @@ -867,6 +909,18 @@ files = [ [package.dependencies] typing-extensions = "*" +[[package]] +name = "pyflakes" +version = "2.3.1" +description = "passive checker of Python programs" +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +files = [ + {file = "pyflakes-2.3.1-py2.py3-none-any.whl", hash = "sha256:7893783d01b8a89811dd72d7dfd4d84ff098e5eed95cfa8905b22bbffe52efc3"}, + {file = "pyflakes-2.3.1.tar.gz", hash = "sha256:f5bc8ecabc05bb9d291eb5203d6810b49040f6ff446a756326104746cc00c1db"}, +] + [[package]] name = "pyphen" version = "0.14.0" @@ -1190,4 +1244,4 @@ test = ["pytest"] [metadata] lock-version = "2.0" python-versions = ">=3.7" -content-hash = "7d31a1a664c2fd354e16a2fd74c76ea926764c01969d588d1e50bb246d91e137" +content-hash = "f7dfbdb09c6e04de92a729a4a093df7cbc15d57afef35c4bcb6ca8a9125736d0" diff --git a/pyproject.toml b/pyproject.toml index 17436b0..a57d9c9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "mkdocs-exporter" -version = "1.0.0" +version = "1.0.1" repository = "https://github.com/adrienbrignon/mkdocs-exporter" keywords = ["mkdocs", "pdf", "exporter"] description = "A highly-configurable plugin for MkDocs that exports your pages to PDF files." @@ -27,7 +27,8 @@ beautifulsoup4 = ">=4.12.2" weasyprint = ">=50.0" lxml = ">=4.9" libsass = ">=0.22.0" -importlib-resources = "*" +importlib-resources = ">=5.0" +importlib-metadata = "<5.0" [tool.poetry.plugins."mkdocs.plugins"] "mkdocs/exporter" = "mkdocs_exporter.plugin:Plugin" @@ -36,3 +37,6 @@ importlib-resources = "*" [tool.poetry.urls] "Bug Tracker" = "https://github.com/adrienbrignon/mkdocs-exporter/issues" + +[tool.poetry.group.dev.dependencies] +flake8 = "<4" diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..890736c --- /dev/null +++ b/tox.ini @@ -0,0 +1,5 @@ +[flake8] +extend-ignore = E203, E111, E303 +exclude = .git,__pycache__,docs,dist,mkdocs_exporter/resources +max-complexity = 8 +max-line-length = 180