image-rs / imageproc

Image processing operations
MIT License
738 stars 145 forks source link

Add usage examples to docs #190

Open theotherphil opened 7 years ago

theotherphil commented 7 years ago

Checked modules are complete.

rmcqueen commented 7 years ago

I will work on this.

Is it preferred to keep all example usages within examples/, or as an example comment, such as the example within src/region_labelling.rs::connected_components?

theotherphil commented 7 years ago

Great! Thus far I've only been adding doctests (so the latter). There's scope for adding more to /examples too - the main goal was improving the rustdoc documentation, but unit tests aren't great for showing visual effects so more /examples would also help.

Nearly all of the functions in this library have trivial APIs (pass in an image to transform, plus a few options, get an image back), so the doctests should ideally help clarify what the function does rather than just how to call it.

If you've not got much experience with rustdoc doctests, the lines starting # might be a bit confusing. These are hidden in the final docs, but we need them in most of the tests so that we can import the gray_image (and rgb_image, etc.) macros for use in the tests.

It might not be possible to add helpful doctests for all functions, but we can certainly add more than we have now. Most of the current doctests started life in the tests module in the file containing the function and were just moved into doctests with some comments added. There might be a few more tests lying around that can just be moved.

Thanks!

mtn commented 5 years ago

Where are rgb_image and similar macros defined? Sorry for resurrecting an old issue.

Edit: Oops, I see how they're working now. For some reason they weren't coming back in search.