orzih / mkdocs-with-pdf

Generate a single PDF file from MkDocs repository.
MIT License
332 stars 77 forks source link

Config for theme_handler_path #26

Closed AbdealiLoKo closed 4 years ago

AbdealiLoKo commented 4 years ago

Hi, first off - amazing project. Ive been struggling with creating PDFs with mkdocs for a few weeks now, and came across this by chance. Worked flawlessly (with material) on the first attempt.

I was trying to customize the location of the "Download PDF" button as we want to keep it in a different location, and I dug through the code to find the theme_handler_path config where I can define my own inject-html function to do this

I found that the theme_handler_path is being read from the configs twice - and it looked like a bug so, I thought I'd report it.

I created theme/pdf_handler/material.py and copied contents from: https://github.com/orzih/mkdocs-with-pdf/blob/master/mkdocs_with_pdf/themes/pdf_handler.py To test things out ...

Attempt 1 - in plugins

https://github.com/orzih/mkdocs-with-pdf/blob/v0.7.5/mkdocs_with_pdf/options.py#L57

site_name: MyDocs
theme:
  name: material
plugins:
  - with-pdf:
    cover_title: MyDocs-PDFVersion
    theme_handler_path: theme/pdf_handler.py

This had no effect. I realized that this config is being over written by a global config by the same name

Attempt 2 - global config

https://github.com/orzih/mkdocs-with-pdf/blob/v0.7.5/mkdocs_with_pdf/options.py#L96

site_name: MyDocs
theme:
  name: material
plugins:
  - with-pdf:
    cover_title: MyDocs-PDFVersion
theme_handler_path: theme/pdf_handler.py

I could not use the --strict when I tried this, because it gave the error - WARNING - Config value: 'theme_handler_path'. Warning: Unrecognised configuration name: theme_handler_path This works find after removing --strict

orzih commented 4 years ago

Thanks.