Simplify API documentation by using doctests#73
Simplify API documentation by using doctests#73rytilahti merged 12 commits intopython-kasa:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #73 +/- ##
===========================================
+ Coverage 61.33% 72.30% +10.96%
===========================================
Files 9 9
Lines 1169 1177 +8
Branches 177 180 +3
===========================================
+ Hits 717 851 +134
+ Misses 413 292 -121
+ Partials 39 34 -5
Continue to review full report at Codecov.
|
| def emeter_today(self) -> Optional[float]: | ||
| """Return today's energy consumption in kWh.""" | ||
| if not self.has_emeter: | ||
| raise SmartDeviceException("Device has no emeter") |
There was a problem hiding this comment.
I know this WIP, but shouldn't this be in a separate PR?
There was a problem hiding this comment.
I think it's such a minor change (just to avoid crashing if someone tries to access those), that it doesn't really matter.
There was a problem hiding this comment.
Ah, so this is related, and not a separate bugfix. Makes sense then!
There was a problem hiding this comment.
So, there are a few minor things I noticed thanks to having those doctests (like this one, and the invalid return value for SmartStripPlug's is_on), that I think were worth fixing here rather than separately.
|
|
||
| device_class = Discover._get_device_class(info) | ||
| device = device_class(ip) | ||
| asyncio.ensure_future(device.update()) |
There was a problem hiding this comment.
This changes behavior, so that there is no need to separately call update on the discovered devices, which is reasonable, I think.
…is fixes the tests
The code is just fine, but some reason the mocking behaves differently between 3.7 and 3.8. The latter seems to accept a discrete object for asyncio.run where the former expects a coroutine..
|
I merged this prior to publishing the docs at readthedocs as that's easier to test when the sphinx docs are already in place. |
The README.md has grown over time very heavy, so it's time to move (at least most) of API instructions out from it to the code base. Besides making the readme more approachable (tangentially related to #60), this allows us to introduce doctests (using xdoctest) to verify that the code examples are really runnable and working.
The generated api docs could be uploaded to readthedocs after the rest of the devices are also converted and the README.md is cleaned.
TODO: