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
fix versionadded & version changed directives #982
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! It is so good to get this input from Sphinx users, as maintainers we mostly use rst2pdf directly. A couple of points before I'm ready to merge:
Could we get a test for this please so that we might spot if we regress it?
How does this change affect documents produced directly with rst2pdf, are these directives used in the rst2pdf output or just passed back to Sphinx? If so, please add a test showing that usage also.
I mostly deal with libraries that require actual hardware to perform tests, so I'm afraid I'm rather inexperienced with creating pytests.
This is a good question. I had assumed that pdfbuilder.py was specific to using sphinx (because of the sphinx-like term "builder"). More reason to perform tests (or in my case learn to use them). |
do you have a recommendation of how/where to get the test's reference comparison output pdf? From the Contributing guidelines:
As a pytest noob, I find this a little confusing. If I just use the first "passing" output from running the test, then it feels counterproductive to do a comparison when the test doesn't Also, I had no idea this lib was pinned to Sphinx v1.8.5. I'm afraid that might complicate the dependencies part of the proposed test. I found the commit that introduced the breaking change solved by this PR. That commit predates Sphinx v1.8.5 (specifically released in v1.7.2) |
The idea is to create a simple document inside So, the output pdf should differ from the reference one before your PR (making the test fail), but match it after the PR (making the test pass). Since, before your PR, this use case crashed rst2pdf it will generate an empty pdf causing the test to fail, which is fine, the procedure is the same :). |
Regarding Sphinx, if the breaking change was prior to version 1.8.5, then we should be fine testing your PR with this version. |
One last question before I have a go at making the test. Am I wrong in thinking that the I don't see them in the docutil's reStructuredText Markup Specification for directives. Nor do I see a link for base case specifications of rst to adhere in the Contributing Guidelines. |
No, you're right, they're Sphinx-only: https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html Feel free to reach out if you have any issue with creating the test. |
The number one reason I like to contribute to others' libraries is for learning opportunities; this PR is no exception 😊 . With that said, the new "sphinx-versionmodified" test passed on all 3 targeted versions of python. I chose the "sphinx-versionmodified" title for the test so its not as ambiguous as "sphinx-issue981". I noticed that in the Contributing guidelines, the instructions say to use a venv named Also, I looked at the pre-commit-config.yml and followed the link to an issue in the comment about using a workaround. It would seem that issue was addressed in May 2020 and released in August 2020. This might serve as a separate issue, and I'm not sure if the workaround is needed anymore (I'm also new to pre-commit). |
Be aware that we use |
The pdf I added to "tests/reference" does contain the expected output (using pytest on my fork's master branch of rst2pdf which should be based on upstream/master), but I understand there's more to a pdf than just the displayed contents. Does this mean I did something wrong? |
Nope. That's correct. The PDF in |
FYI tests still pass, but CI failed to upload artifacts from workflow. Normally I'd just re-run the workflow(s), but I don't see that option in the menus. |
Yeah, that happened to me recently as well. Whenever you push something the CI re-runs, so perhaps you could try force pushing again without changing anything? Though I'm not sure if a push with no change would really trigger the CI... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is in great shape, thanks so much for taking the time!
I'm confused about the state of the CI here and it's blocking me merging this right now. I'll come back to it when I can! |
Seems to me there is a difference between the current master branch's CI workflow and my fork's master branch's CI workflow. I think its related to the recent addition of building against python v3.9. I could rebase my fork's master branch to see if that helps, but that will likely require another PR approval as all current reviews would be disregarded. |
I think @lornajane meant that the PR wasn't mergeable 1 hour ago because the CI was waiting for approval first, before running the tests. It seems fine now, though. |
Mmmmmm, not sure what was going on there, I had to reduce some of the protection settings on the branch to be able to merge it. Those strange CI jobs that don't exist and therefore don't pass were blocking it. |
closes #981
I don't know when, but there was a change to how the
versionlabels
dict was declared (& possibly changed usage also) in Sphinx. This resulted in a failure to build a pdf when usingversionadded
,versionchanged
, anddeprecated
directives.See #981 for problematic output and concluding solution.
This PR fixes the pdfbuilder.py to compensate for the changes in Sphinx.