Skip to content

Commit

Permalink
fix: miscellaneous fixes
Browse files Browse the repository at this point in the history
- Improved compatibility with other dependencies
- Now linting the source code with `flake8`
  • Loading branch information
adrienbrignon committed May 8, 2023
1 parent c9b256d commit f10791a
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 13 deletions.
2 changes: 1 addition & 1 deletion mkdocs_exporter/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion mkdocs_exporter/logging.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging


logger = logging.getLogger('mkdocs.plugins.mkdocs-exporter')
logger = logging.getLogger('mkdocs.plugins.mkdocs_exporter')
"""The logger."""
5 changes: 2 additions & 3 deletions mkdocs_exporter/plugins/pdf/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -111,15 +110,15 @@ 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'])

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))

Expand Down
2 changes: 1 addition & 1 deletion mkdocs_exporter/preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
64 changes: 59 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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"
Expand All @@ -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"
5 changes: 5 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f10791a

Please sign in to comment.