-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
MAINT: Consistent terminology for outline items #1156
Conversation
dc29db0
to
2b94e60
Compare
Codecov Report
@@ Coverage Diff @@
## main #1156 +/- ##
==========================================
- Coverage 92.24% 92.08% -0.16%
==========================================
Files 24 24
Lines 4811 4866 +55
Branches 991 996 +5
==========================================
+ Hits 4438 4481 +43
- Misses 231 242 +11
- Partials 142 143 +1
Continue to review full report at Codecov.
|
Wow, very nice! I've seen that you followed the the PyPDF2 deprecation process I think for I've just noticed |
2b94e60
to
2a6b7c5
Compare
Good catch. I didn't even think about deprecating the types. I've amended the last commit with changes to address this issue. I pushed a second commit to add unit tests for the decorator function. There are 3 (could be more, but I thought this was enough).
|
772ec0c
to
ebed584
Compare
ebed584
to
80ff23b
Compare
So many nits (all the forced pushes). I hope @MartinThoma you and the other repo managers don't get emailed for every failed CI like I do. If so, I'll be more thorough with unit testing on my end before pushing to GitHub. 😳 |
Don't worry about that 😄 However, you don't need to make force-pushes. I will make a squashing commit in the end in any case and adjust the commit message. So it doesn't make a difference if you make normal pushes or force pushes. |
@mtd91429 I've adjusted your first comment so that it contains the deprecations. That comment will be used as a commit message when I squash the commits of this PR. |
@pubpub-zz @MasterOdin Do you want to have a look at the PR? To you agree with the renamings? |
looks good |
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.
Fine with the rename, some slight review comments.
""" | ||
deprecate_with_replacement("getOutlines", "outlines") | ||
return self._get_outlines(node, outlines) | ||
deprecate_with_replacement("getOutlines", "outline") |
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.
Unrelated to the PR renaming, but this isn't a true replacement since there's no way to pass the optional parameters of this method to the property? Just no one uses them so it's fine?
PyPDF2/_reader.py
Outdated
Use :py:attr:`outline` instead. | ||
""" | ||
deprecate_with_replacement("outlines", "outline") | ||
return self._get_outline() |
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.
Personally, I'd rather see this call the replacement than the underlying internal function, just so if we decide to alter self.outline
, then won't potentially need to also change self.outlines
.
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.
Using the replacement also makes it more clear how to use the replacement / not use use the internal function. It's not a big overhead as well 👍
@MasterOdin Thank you for the thorough review 🙏 |
@mtd91429 I see that you've already spent a lot of time with this awesome PR / preparing it with the issue before. Thank you 🙏 All of the comments @MasterOdin added make a lot of sense to me. Especially the fact of moving some internal functions to the internal From my side, this PR is ready. I would appreciate it a lot if you incorporated the changes suggested by MasterOdin. However, if you prefer I can also do that after merging. Just let me know :-) In any way, this will be merged soon :-) |
@MasterOdin thank you for the thorough review as well with so many lines of code changed, I'm glad there were more eyes on this. @MartinThoma I am perfectly happy to allow you to make any of the changes. I won't be able to do them until tomorrow, so don't wait for me. I also agree with @MasterOdin suggestions. |
I'm actually uncertain if I can do it before the weekend 😄 Let's see who is faster 😄 🚀 |
use .outlines in tests formatting
@mtd91429 Thank you so much for all of the effort you put into this topic 🤗 You improved PyPDF2 🎉 ❤️ I'll make a release tomorrow :-) |
New Features (ENH): - Add ability to add hex encoded colors to outline items (#1186) - Add support for pathlib.Path in PdfMerger.merge (#1190) - Add link annotation (#1189) - Add capability to filter text extraction by orientation (#1175) Bug Fixes (BUG): - Named Dest in PDF1.1 (#1174) - Incomplete Graphic State save/restore (#1172) Documentation (DOC): - Update changelog url in package metadata (#1180) - Table extraction (#1179) - Mention pyHanko for signing PDF documents (#1178) - We now have CMAP support (#1177) Maintenance (MAINT): - Consistant usage of warnings / log messages (#1164) - Consistent terminology for outline items (#1156) Code Style (STY): - Apply pre-commit (#1188) Full Changelog: 2.8.1...2.9.0
Also don't use a default for the deprecation functions: If the version is mentioned explicitly with every call, we can more easily search for it. Bookmarks: `MAINT: Consistent terminology for outline items` (#1156, pypdf==2.9.0) introduced it. Meaning in pypdf==4.0.0 we can remove them
This PR makes sure PyPDF2 uses a consistent nomenclature for the outline:
Concretely, this means that some names will be deprecated to ensure consistency:
PdfReader
outlines
➔outline
_build_outline()
➔_build_outline_item()
PdfWriter
get_outline_root()
add_bookmark_dict()
➔add_outline()
add_bookmark()
➔add_outline_item()
PdfMerger
_write_bookmarks()
➔_write_outline()
_write_bookmark_on_page()
➔_write_outline_item_on_page()
_associate_bookmarks_to_pages()
➔_associate_outline_items_to_pages()
find_bookmark()
➔find_outline_item()
_trim_outline()
generic.py
Bookmark
➔OutlineItem
Closes #1098