From 759dff99e4fba583e78a75a03118b053365cb108 Mon Sep 17 00:00:00 2001 From: Prodesire Date: Wed, 20 Dec 2017 06:25:10 +0800 Subject: [PATCH] add doc for unit --- docs/index.rst | 1 + docs/unit.rst | 15 +++++++++++++++ pydu/unit.py | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 docs/unit.rst diff --git a/docs/index.rst b/docs/index.rst index 4a0f387..3da9cb3 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -36,3 +36,4 @@ Content request set string + unit \ No newline at end of file diff --git a/docs/unit.rst b/docs/unit.rst new file mode 100644 index 0000000..97be75b --- /dev/null +++ b/docs/unit.rst @@ -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') diff --git a/pydu/unit.py b/pydu/unit.py index 851a523..8614050 100644 --- a/pydu/unit.py +++ b/pydu/unit.py @@ -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. """