adrienbrignon / mkdocs-exporter

⚡ The fastest and most configurable plugin for MkDocs, allowing seamless export of individual pages and/or entire documentation as PDF documents.
https://adrienbrignon.github.io/mkdocs-exporter/
MIT License
83 stars 9 forks source link

Unable to get the plugin to work with MKDocs (Material theme) #4

Closed tor30122 closed 1 year ago

tor30122 commented 1 year ago

Issue

Plugin seems unable to generate PDFs

Description

I've installed the plugin using pip, at first run it asked me to update Playwright, so I did. Trying to start the dev server again I got the following error:

Log

Running mkdocs serve gives this output:

INFO     -  Building documentation...
INFO     -  Cleaning site directory
INFO     -  The following pages exist in the docs directory, but are not included in the "nav" configuration:
              - index.md
              - hei.md
              - MicroBit\index.md
              - MicroBit\introduksjontilMicrobit.md
              - Testing\index.md
WARNING  -  A relative path to 'index.html' is included in the 'nav' configuration, which is not found in the documentation files
WARNING  -  A relative path to 'MicroBit/index.html' is included in the 'nav' configuration, which is not found in the documentation files
INFO     -  Rendering PDF for index.md...
INFO     -  Launching browser...
INFO     -  Rendering PDF for MicroBit\index.md...
Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\tor30122\AppData\Roaming\Python\Python310\site-packages\mkdocs\__main__.py", line 301, in <module>
    cli()
  File "C:\Users\tor30122\AppData\Roaming\Python\Python310\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\tor30122\AppData\Roaming\Python\Python310\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Users\tor30122\AppData\Roaming\Python\Python310\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\tor30122\AppData\Roaming\Python\Python310\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\tor30122\AppData\Roaming\Python\Python310\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\tor30122\AppData\Roaming\Python\Python310\site-packages\mkdocs\__main__.py", line 234, in serve_command
    serve.serve(dev_addr=dev_addr, livereload=livereload, watch=watch, **kwargs)
  File "C:\Users\tor30122\AppData\Roaming\Python\Python310\site-packages\mkdocs\commands\serve.py", line 83, in serve
    builder(config)
  File "C:\Users\tor30122\AppData\Roaming\Python\Python310\site-packages\mkdocs\commands\serve.py", line 76, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "C:\Users\tor30122\AppData\Roaming\Python\Python310\site-packages\mkdocs\commands\build.py", line 332, in build
    config.plugins.run_event('post_build', config=config)
  File "C:\Users\tor30122\AppData\Roaming\Python\Python310\site-packages\mkdocs\plugins.py", line 522, in run_event
    result = method(**kwargs)
  File "C:\Users\tor30122\AppData\Roaming\Python\Python310\site-packages\mkdocs_exporter\plugins\pdf\plugin.py", line 143, in on_post_build
    loop.run_until_complete(asyncio.gather(*concurrently(self.tasks, max(1, self.config.concurrency or 1))))
  File "C:\Program Files\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
    return future.result()
  File "C:\Users\tor30122\AppData\Roaming\Python\Python310\site-packages\mkdocs_exporter\plugins\pdf\plugin.py", line 137, in limit
    return await asyncio.create_task(coroutine)
  File "C:\Users\tor30122\AppData\Roaming\Python\Python310\site-packages\mkdocs_exporter\plugins\pdf\plugin.py", line 113, in render
    pdf = await self.renderer.render(page, polyfills=self.config['polyfills'])
  File "C:\Users\tor30122\AppData\Roaming\Python\Python310\site-packages\mkdocs_exporter\plugins\pdf\renderer.py", line 79, in render
    return await self.browser.print(html)
  File "C:\Users\tor30122\AppData\Roaming\Python\Python310\site-packages\mkdocs_exporter\browser.py", line 81, in print
    await page.goto('file://' + file.name, wait_until='networkidle')
  File "C:\Users\tor30122\AppData\Roaming\Python\Python310\site-packages\playwright\async_api\_generated.py", line 9204, in goto
    await self._impl_obj.goto(
  File "C:\Users\tor30122\AppData\Roaming\Python\Python310\site-packages\playwright\_impl\_page.py", line 495, in goto
    return await self._main_frame.goto(**locals_to_params(locals()))
  File "C:\Users\tor30122\AppData\Roaming\Python\Python310\site-packages\playwright\_impl\_frame.py", line 147, in goto
    await self._channel.send("goto", locals_to_params(locals()))
  File "C:\Users\tor30122\AppData\Roaming\Python\Python310\site-packages\playwright\_impl\_connection.py", line 61, in send
    return await self._connection.wrap_api_call(
  File "C:\Users\tor30122\AppData\Roaming\Python\Python310\site-packages\playwright\_impl\_connection.py", line 461, in wrap_api_call
    return await cb()
  File "C:\Users\tor30122\AppData\Roaming\Python\Python310\site-packages\playwright\_impl\_connection.py", line 96, in inner_send
    result = next(iter(done)).result()
playwright._impl._api_types.Error: net::ERR_FAILED at file:///C:/Users/tor30122/AppData/Local/Temp/tmpdm_awifw.html
=========================== logs ===========================
navigating to "file:///C:/Users/tor30122/AppData/Local/Temp/tmpdm_awifw.html", waiting until "networkidle"
============================================================

Configuration

My mkdocs.yml file is:

site_name: IM Boka

nav:
    - Velkommen: 'index.html'
    - MicroBit: 'MicroBit/index.html'

theme:
  name: material
  language: nb
  features:
    - navigation.instant
    - navigation.tracking
    - navigation.tabs
#    - navigation.expand
#    - navigation.indexes
#    - navigation.footer
    - content.code.copy

  palette:
    # Palette toggle for light mode
    - scheme: default
      primary: teal
      toggle:
        icon: material/lightbulb
        name: Switch to dark mode

    # Palette toggle for dark mode
    - scheme: slate
      primary: teal
      toggle:
        icon: material/lightbulb-outline
        name: Switch to light mode
        primary: teal

extra:
  consent:
    title: Cookie consent
    description: >-
      We use cookies to recognize your repeated visits and preferences, as well
      as to measure the effectiveness of our documentation and whether users
      find what they're searching for. With your consent, you're helping us to
      make our documentation better.
    actions:
      - accept
      - reject

copyright: >
  Copyright &copy; 2023 IM Greveskogen –
  <a href="#__consent">Endre cookie innstillinger</a>

plugins:
  - search
  - offline
  - mkdocs-video
  - mkdocs/exporter
  - mkdocs/exporter/pdf

markdown_extensions:
  - attr_list
  - pymdownx.emoji:
      emoji_index: !!python/name:materialx.emoji.twemoji
      emoji_generator: !!python/name:materialx.emoji.to_svg 
  - pymdownx.highlight:
      anchor_linenums: true
  - pymdownx.superfences:
      custom_fences:
        - name: mermaid
          class: mermaid
          format: !!python/name:pymdownx.superfences.fence_code_format
  - pymdownx.tabbed:
      alternate_style: true 
  - admonition
  - pymdownx.details
adrienbrignon commented 1 year ago

Hello @tor30122,

Thank you for submitting an issue.
I'm currently investigating and will come back to you as soon as I get more details.

In the meantime, could you try to update the plugin to the v2.0.0 version and see if it solves your problem, please?

adrienbrignon commented 1 year ago

Should be fixed in v2.0.1.
Feel free to reopen the issue if that is not the case.