Closed borrougagnou closed 1 year ago
Hi @borrougagnou,
First of all, thank your for submitting an issue.
Could you please provide some logs and an excerpt of your configuration file?
I'd be glad to assist you and, if necessary, publish some patches.
To answer your question, PDF documents are generated during the usual build process of MkDocs as this plugin hooks itself on its events.
Whenever your documentation gets built (via mkdocs serve
or mkdocs build
, for instance), PDF documents are generated and saved to the site_dir
directory.
I am still in the process of writing the documentation and hope to publish it soon!
PS: Feel free to draw some inspiration from the MkDocs configuration used by this repository.
Thank you for your answer:
mkdocs.yml
---
site_name: My Docs
theme:
name: readthedocs
extra_css: [extra.css]
nav:
- Home: index.md
- Setup:
- Setup flameshot: setup/flameshot.md
markdown_extensions:
- toc:
permalink:
plugins:
- mkdocs/exporter
- mkdocs/exporter/extras:
buttons:
- title: Download as PDF
enabled: !!python/name:mkdocs_exporter.plugins.pdf.button.enabled
icon: !!python/name:mkdocs_exporter.plugins.pdf.button.icon
href: !!python/name:mkdocs_exporter.plugins.pdf.button.href
download: !!python/name:mkdocs_exporter.plugins.pdf.button.download
docs/extra.css:
@font-face {
font-family:Luciole;
font-weight:400;
font-style:normal;
src:local("Luciole Regular"),
local("Luciole-Regular"),
url(Luciole-Regular.ttf) format("truetype");
}
html, body, h1, h2, h3, h4, h5, h6, p{
font-family: 'Luciole', 'Courier New', Courier, monospace;
}
Result: ModuleNotFoundError: No module named 'material'
After installing mkdocs-material: $> pip install mkdocs-material && mkdocs serve --dev-addr=localhost:8080 INFO - Building documentation... INFO - Cleaning site directory INFO - Documentation built in 0.33 seconds INFO - [12:15:35] Watching paths for changes: 'docs', 'mkdocs.yml' INFO - [12:15:35] Serving on http://localhost:8080/ INFO - [12:15:40] Browser connected: http://localhost:8080/
And that's all, no button, no pdf.
Thank you for the details you've provided.
It seems that your configuration misses the mkdocs/exporter/pdf
plugin.
Could you please try with something like this in your configuration:
plugins:
- mkdocs/exporter
- mkdocs/exporter/pdf
- mkdocs/exporter/extras:
buttons:
- title: Download as PDF
enabled: !!python/name:mkdocs_exporter.plugins.pdf.button.enabled
icon: !!python/name:mkdocs_exporter.plugins.pdf.button.icon
href: !!python/name:mkdocs_exporter.plugins.pdf.button.href
download: !!python/name:mkdocs_exporter.plugins.pdf.button.download
Note the mkdocs/exporter/pdf
plugin in between mkdocs/exporter
and mkdocs/exporter/extras
.
And I also tried like this: mkdocs.yml:
---
site_name: My Docs
theme:
name: readthedocs
extra_css: [extra.css]
nav:
- Home: index.md
- Setup:
- Setup flameshot: setup/flameshot.md
markdown_extensions:
- toc:
permalink:
plugins:
- mkdocs/exporter
- mkdocs/exporter/pdf:
concurrency: 8
covers:
front: resources/templates/covers/front.html.j2
stylesheets:
- resources/stylesheets/pdf.scss
- mkdocs/exporter/extras:
buttons:
- title: Download as PDF
enabled: !!python/name:mkdocs_exporter.plugins.pdf.button.enabled
icon: !!python/name:mkdocs_exporter.plugins.pdf.button.icon
href: !!python/name:mkdocs_exporter.plugins.pdf.button.href
download: !!python/name:mkdocs_exporter.plugins.pdf.button.download
And copy paste your "ressources" folder into my project, but now I have a:
Traceback (most recent call last):
File "/home/docs/venv/bin/mkdocs", line 8, in <module>
sys.exit(cli())
File "/home/docs/venv/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/home/docs/venv/lib/python3.8/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/home/docs/venv/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/docs/venv/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/docs/venv/lib/python3.8/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/home/docs/venv/lib/python3.8/site-packages/mkdocs/__main__.py", line 234, in serve_command
serve.serve(dev_addr=dev_addr, livereload=livereload, watch=watch, **kwargs)
File "/home/docs/venv/lib/python3.8/site-packages/mkdocs/commands/serve.py", line 83, in serve
builder(config)
File "/home/docs/venv/lib/python3.8/site-packages/mkdocs/commands/serve.py", line 76, in builder
build(config, live_server=live_server, dirty=dirty)
File "/home/docs/venv/lib/python3.8/site-packages/mkdocs/commands/build.py", line 329, in build
_build_page(file.page, config, doc_files, nav, env, dirty)
File "/home/docs/venv/lib/python3.8/site-packages/mkdocs/commands/build.py", line 234, in _build_page
output = config.plugins.run_event('post_page', output, page=page, config=config)
File "/home/docs/venv/lib/python3.8/site-packages/mkdocs/plugins.py", line 520, in run_event
result = method(item, **kwargs)
File "/home/docs/venv/lib/python3.8/site-packages/mkdocs_exporter/plugins/extras/plugin.py", line 26, in on_post_page
preprocessor.button(**{k: resolve(v) for k, v in button.items()})
File "/home/docs/venv/lib/python3.8/site-packages/mkdocs_exporter/plugins/extras/preprocessor.py", line 24, in button
self.html.find('article', {'class': 'md-content__inner'}).insert(0, button)
AttributeError: 'NoneType' object has no attribute 'insert'
EDIT: I just saw your message above, I have the same error about the traceback 'insert'
Thank you for all the details you have provided.
It definitely looks like a bug, I'm looking more closely and will provide updates accordingly.
Edit:
It seems that you're using the readthedocs
theme which hasn't been tested with this plugin, yet.
Support for this theme is planned and will come soon (by the end of the week).
As of now, only material
(mkdocs-material) is supported officially.
Hello @borrougagnou,
A quick message to notify you about the availability of the v2.0.0
release.
This version supports the Read the Docs theme and should solve your issue.
As such, I'll be closing this issue; feel free to reopen it if you experience any trouble.
Hello,
i tried to install your package on my readthedocs repository, but unfortunately it didn't work... and I don't see a "Download button" (same after adding the part)
The readme is also difficult to understand since there is no "back" file somewhere in the repository and same if I only add the "front" I have multiple python error There is also no information about how PDF are generated (during what process ? mkdocs serve? mkdocs build) and where to have it.
Into my
mkdocs.yml
file,docs
folder.my python version: 3.8 / mkdocs: the latest
Regards