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

Log warnings about files that would have been processed by disabled readers #3321

Merged
merged 1 commit into from
Jun 25, 2024

Conversation

boxydog
Copy link
Contributor

@boxydog boxydog commented May 31, 2024

Resolves: 1868

  • Ensured tests pass and (if applicable) updated functional test output
  • Conformed to code style guidelines by running appropriate linting tools
  • Added tests for changed code
  • Updated documentation for changed code

This is a proof of concept of producing legible warning messages if markdown is not installed.

Example output:

WARNING ./sample.md: Could not import markdown.Markdown. Have you installed the markdown package? readers.py:688
Done: Processed 0 articles, 0 drafts, 0 hidden articles, 0 pages, 0 hidden pages and 0 draft pages in 0.07 seconds.

If this PR looks good, I can try to write at least one unit test of the new functionality.

Some downsides:

  1. this is not super simple
  2. it will produce one warning per file

I don't think 2 is a big deal. I think 1 is a judgment call, I'm interested in opinions.

It would probably be easier to just require the markdown package?

@boxydog
Copy link
Contributor Author

boxydog commented May 31, 2024

Looking at the failing tests..

@boxydog boxydog force-pushed the warn_about_markdown branch 5 times, most recently from 1d68cc3 to 2094714 Compare May 31, 2024 20:10
Copy link
Member

@justinmayer justinmayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, @boxydog! I made a couple of minor comments.

pelican/readers.py Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
@justinmayer justinmayer requested review from offbyone, avaris and a team June 1, 2024 09:22
@boxydog boxydog force-pushed the warn_about_markdown branch 2 times, most recently from ec511f2 to d96e1d0 Compare June 1, 2024 13:36
Copy link
Member

@justinmayer justinmayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! 👍 Any further comments from @getpelican/reviewers before merging?

@justinmayer
Copy link
Member

@boxydog said:

If this PR looks good, I can try to write at least one unit test of the new functionality.

Do you think it would be worthwhile to add additional unit test coverage to this PR before it is merged?

@boxydog
Copy link
Contributor Author

boxydog commented Jun 16, 2024

@boxydog said:

If this PR looks good, I can try to write at least one unit test of the new functionality.

Do you think it would be worthwhile to add additional unit test coverage to this PR before it is merged?

Yes, I think that's a good idea, otherwise I'll forget. I'll work on it.

Fyi, my personal philosophy is "epsilon testing", my term for, "write some tests, more than zero", meaning I don't aim for 100% coverage (as that can feel like more work than it's worth to me).

@boxydog
Copy link
Contributor Author

boxydog commented Jun 17, 2024

Coverage on master:

TOTAL                                  3918    984    75%

Required test coverage of 74% reached. Total coverage: 74.89%

Coverage on this branch with added tests:

TOTAL                                  3950    982    75%

Required test coverage of 74% reached. Total coverage: 75.14%

I'm happy for you to merge this if you like it.

However, FYI, if I were emperor of pelican, I'd just require the markdown library. Less code, simpler to explain. We want to support markdown anyway, so we'll want to support that "optional" dependency.

@boxydog
Copy link
Contributor Author

boxydog commented Jun 17, 2024

Ugh, tests failed! I'll look..

@boxydog boxydog force-pushed the warn_about_markdown branch 3 times, most recently from 7f30c4b to 548b0ef Compare June 17, 2024 13:29
@boxydog
Copy link
Contributor Author

boxydog commented Jun 17, 2024

Ugh, tests will be more complicated than I had hoped. I changed Markdown.enabled to False, but presumably if some other test is running at the same time it gets disturbed. So probably I have to mock a Markdown class that has a different enabled.

@boxydog
Copy link
Contributor Author

boxydog commented Jun 17, 2024

However, FYI, if I were emperor of pelican, I'd just require the markdown library. Less code, simpler to explain. We want to support markdown anyway, so we'll want to support that "optional" dependency.

.. and then I'd close this PR instead of merge it.

Again, whatever you want, I just want to move important things forward.

@justinmayer
Copy link
Member

Given the continued interest in alternative Markdown parsers (e.g., #3344), there may be value in leaving Python-Markdown as an optional dependency. I am therefore inclined to merge this.

Many thanks for this enhancement, @boxydog! 🏅

@justinmayer justinmayer merged commit f89f889 into getpelican:master Jun 25, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants