add doc for unit

This commit is contained in:
Prodesire 2017-12-20 06:25:10 +08:00
parent 9c4cef040f
commit 759dff99e4
3 changed files with 17 additions and 1 deletions

View File

@ -36,3 +36,4 @@ Content
request
set
string
unit

15
docs/unit.rst Normal file
View File

@ -0,0 +1,15 @@
Unit
----
.. py:class:: pydu.unit.Bytes(bytes)
Supply several methods dealing with bytes.
.. py:method:: convert(self, unit=None, multiple=1024)
Convert bytes in give ``unit``.
If ``unit`` is None, convert bytes in suitable unit.
Convert ``multiple`` is default to be 1024.
>>> Bytes(1024).convert()
(1, 'KB')

View File

@ -12,7 +12,7 @@ class Bytes(object):
def convert(self, unit=None, multiple=1024):
"""
Convert bytes in give unit.
Convert bytes in give ``unit``.
If `unit` is None, convert bytes in suitable unit.
Convert `multiple` is default to be 1024.
"""