-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
API & documentation cleanup #27
Comments
cc: @laurmaedje @reknih @LaurenzV since you guys are, as it seems, most involved with pdf-writer. |
During work on #25, I stumbled upon a problem that is relevant for this. To be able to convert a field to a widget annotation, we must allow a way to construct an annotation from an already created I propose that the module structure should sort-of copy the structure of the PDF 1.7 spec. Related structs like these could then access each other's internals without exposing them to the whole crate: pub mod interactive {
pub mod annots {
pub struct Annotation {
pub(super) dict: Dict
}
}
pub mod forms {
pub struct Field {
pub(super) dict: Dict
}
impl Field {
pub fn merge_annot(self) -> Annotation {
Annotation { dict: self.dict }
}
}
}
} |
While the module structure maybe isn't ideal, I don't see the problem of a |
The proposed docs changes sound good. I'm also fine with having a few useful macros for generating methods as long as they are declarative macros and not proc-macros. I think these two changes would be a good start and we can then see about the module structure going from there (as this should already shorten the files considerably).
Sounds fine, in principle. Are there many occurances of this beyond annotations? |
That should work just fine, decl macros should suffice here.
In The question is how much type safety we want for a format that is not very type safe in practice. We pass I'm personally all for a statically safer API, but we also shouldn't flood API with a million subtypes. |
I don't have a strong opinion either way, but I do think that consistency's important here. So either annotations or functions should change. Type safety is nice, but in the end there's just too many ways to write an invalid PDF ... |
In wake of #26 the API would experience a breaking change, this unavoidable if we want to support interactive forms (#25).
If we break the API, we may as well make the best of it and bring some things into unity, there are small differences in the API that I'd like to clean up to provide an overall cleaner and more consistent API to the end user. While also allowing the average contributor to write less code.
Things I had in mind:
CODE_BLOCKS
I would like to take this issue to discuss changes to the API before the next update, so we can minimize the amount of breaking updates we have by thinking ahead.
The text was updated successfully, but these errors were encountered: