Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exclude_pages compatibility with awesome-pages #58

Closed
ErikThorsell opened this issue May 18, 2021 · 8 comments · Fixed by #63
Closed

exclude_pages compatibility with awesome-pages #58

ErikThorsell opened this issue May 18, 2021 · 8 comments · Fixed by #63
Labels
enhancement New feature or request

Comments

@ErikThorsell
Copy link

I have run into an issue which might be related to #46.

The problem is that I am unable to use exclude_pages together with awesome-pages. Basically, if I use the ... in my mkdocs.yaml file, to have awesome-pages automatically add pages to nav, the exclude_pages functionality stops working.

I have created MWE in this repository: https://github.com/ErikThorsell/mkdocs_with_pdf-exclude_pages-bug. The key thing is Line 26 in the mkdocs.yaml (link), please see the inline comment.

Please let me know if there's anything I can do to assist you further in debugging the issue.

@rtbs-dev
Copy link

rtbs-dev commented Jun 2, 2021

In addition, I think the plugin is not compatible with literate-nav. Specifically, I have added a set of nav entries together with an automatic entry for "anything in this folder". There's over a hundred files in there, so managing them with a complete nav is infeasible, but leaving out the nav option orders the sections incorrectly.

Would definitely like to see these add-ons supported in this plugin! 😃

@orzih
Copy link
Owner

orzih commented Jun 8, 2021

Hi @ErikThorsell. Sorry for the late reply.

The exclude_pages option does not support partial URLs.

Please set.

  - with-pdf:
      verbose: true
      exclude_pages:
        - a_folder/file_in_folder_1/
        # - a_folder/file_in_folder_2/

and check logs:

DEBUG   -   (post: [Overview]() 
DEBUG   -   (post: [Back](back/) 
INFO    -  Page skipped: [File 1 in a folder](a_folder/file_in_folder_1/)         <--- MATCH exclude_pages URL
DEBUG   -   (post: [File in folder 2](a_folder/file_in_folder_2/)                 <--- UN-MATCH
INFO    -  Number headings up to level 3. 

@ErikThorsell
Copy link
Author

Hi @orzih, thank you for getting back to me.

I tested your proposal and it does indeed achieve the wanted result. However, in my actual use case I maintain ~10 projects, each project with directories like (a_folder/) which in turn contain ~20 files, and the number of files keeps growing every week. Keeping the mkdocs.yml file up-to-date with each file will simply not be feasible.

Would it be possible to extend the plugin to support ignoring directories (and the content of the directory)? If you are willing to point me in the right direction I can start a PR and help out with the implementation.

@orzih
Copy link
Owner

orzih commented Jun 8, 2021

The code related to this issue can be found here:

def on_post_page(self, output_content: str, page, pdf_path: str) -> str:
""" on_post_page """
def is_excluded(url: str) -> bool:
return url in self._options.exclude_pages
if is_excluded(page.url):
self.logger.info(f'Page skipped: [{page.title}]({page.url})')
return f"<!-- skipped '{page}' -->"
else:
self.logger.debug(f' (post: [{page.title}]({page.url})')

and, Welcome to submit a PR.

@orzih
Copy link
Owner

orzih commented Jun 12, 2021

@ErikThorsell, PR Thanks.

As a result of checking, it was not possible to support 'use_directory_urls: false', so I changed it to pattern matching.
Please check it.

@ErikThorsell
Copy link
Author

@orzih, I see good that you caught it.

For the future, there are no tests anywhere that tests all combinations of settings, right?

Regarding your change (using re.Pattern); I have tested v.0.9.0 on the following Python versions:
❌ Python 3.6.10
✅ Python 3.7.10
✅ Python 3.9.4

In the release notes for v0.9.0 you wrote Drop support for Python 3.5., but it seems like it should really be: Drop support for Python < 3.7.

When I try to generate the .pdf-file with Python 3.6.10 I get the following error:

AttributeError: module 're' has no attribute 'Pattern'

I skimmed through the src difference between 3.6 and 3.7 and they have added line 264 to 3.7: Pattern = type(sre_compile.compile('', 0)).

I leave to you to decide whether you want the plugin to drop support for 3.6 as well.

@orzih
Copy link
Owner

orzih commented Jun 15, 2021

@ErikThorsell Thank you for your reporting.

For the future, there are no tests anywhere that tests all combinations of settings, right?

Yes. (...please anyone help ^^;)

I fixed a runtime bug in Python 3.6.x in v0.9.2.

@ErikThorsell
Copy link
Author

ErikThorsell commented Jun 15, 2021

@orzih, I verified 0.9.2 with 3.6.10, I think we can conclude this issue :)

GG WP 🤜🤛

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants