Skip to content

Commit bbcb860

Browse files
author
Tim Bielawa
committed
Doc updates, make class references working links, fuss with some examples, update copyright
1 parent 5984770 commit bbcb860

8 files changed

Lines changed: 39 additions & 86 deletions

File tree

docsite/source/classes.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Initializing
119119

120120
:param int value: **Default: 0**. The value of the instance in
121121
*prefix units*. For example, if we were
122-
instantiating a ``bitmath.KiB`` object to
122+
instantiating a :class:`.KiB` object to
123123
represent 13.37 KiB, the ``value`` parameter
124124
would be **13.37**. For instance, ``k =
125125
bitmath.KiB(13.37)``.
@@ -163,8 +163,8 @@ Class Method: from_other()
163163
==========================
164164

165165
bitmath **class objects** have one public class method,
166-
:py:meth:`BitMathClass.from_other` which provides an
167-
alternative way to initialize a bitmath class.
166+
:py:meth:`.from_other` which provides an alternative way to initialize
167+
a bitmath class.
168168

169169
This method may be called on bitmath class objects directly. That is
170170
to say: you do not need to call this method on an instance of a
@@ -176,8 +176,8 @@ bitmath class, however that is a valid use case.
176176
Instantiate any ``BitMathClass`` using another instance as
177177
reference for it's initial value.
178178

179-
The ``from_other()`` class method has one required parameter: an
180-
instance of a bitmath class.
179+
The :py:meth:`.from_other` class method has one required parameter:
180+
an instance of a bitmath class.
181181

182182
:param BitMathInstance item: An instance of a bitmath class.
183183
:return: a bitmath instance of type ``BitMathClass`` equivalent in
@@ -204,7 +204,7 @@ bitmath class, however that is a valid use case.
204204
>>> print(a_mebibyte, a_mebibyte_sized_kibibyte)
205205
1.0 MiB 1024.0 KiB
206206
207-
Or, using the :py:meth:`BitMathClass.from_other` class method:
207+
Or, using the :py:meth:`.from_other` class method:
208208

209209
.. code-block:: python
210210
:linenos:

docsite/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
# General information about the project.
5050
project = u'bitmath'
51-
copyright = u'2014-2016, Tim Bielawa'
51+
copyright = u'2014-2023, Tim Bielawa'
5252

5353
# The version info for the project you're documenting, acts as replacement for
5454
# |version| and |release|, also used in various other places throughout the

docsite/source/conf.py.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ master_doc = 'index'
4848

4949
# General information about the project.
5050
project = u'bitmath'
51-
copyright = u'2014-2016, Tim Bielawa'
51+
copyright = u'2014-2023, Tim Bielawa'
5252

5353
# The version info for the project you're documenting, acts as replacement for
5454
# |version| and |release|, also used in various other places throughout the

docsite/source/index.rst

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -72,50 +72,32 @@ yourself <https://github.com/tbielawa/bitmath/tree/master/tests>`_.
7272
Installation
7373
############
7474

75-
The easiest way to install bitmath is via ``dnf`` (or ``yum``) if
76-
you're on a Fedora/RHEL based distribution. bitmath is available in
77-
the main Fedora repositories, as well as EPEL Repositories. As of 2023
78-
bitmath is only developed, tested, and supported for `currently
79-
supported <https://devguide.python.org/versions/>`_ Python releases.
75+
bitmath is available in Fedora and EPEL repositories, as well as
76+
directly available via `PyPI
77+
<https://pypi.python.org/pypi/bitmath>`_. As of 2023 bitmath is only
78+
developed, tested, and supported for `currently supported
79+
<https://devguide.python.org/versions/>`_ Python releases.
8080

81+
**Package Managers**
8182

8283
.. code-block:: bash
8384
8485
$ sudo dnf install python3-bitmath
86+
$ pip install --user bitmath
8587
8688
87-
**PyPi**:
89+
**Source**::
8890

89-
You could also install bitmath from `PyPi
90-
<https://pypi.python.org/pypi/bitmath>`_ if you like:
91-
92-
.. code-block:: bash
93-
94-
$ sudo pip install bitmath
95-
96-
.. note::
97-
98-
**pip** installs need pip >= 1.1. To workaround this, `download
99-
bitmath <https://pypi.python.org/pypi/bitmath/#downloads>`_, from
100-
PyPi and then ``pip install bitmath-x.y.z.tar.gz``. See `issue #57
101-
<https://github.com/tbielawa/bitmath/issues/57#issuecomment-227018168>`_
102-
for more information.
103-
104-
105-
106-
**Source**:
91+
NOTE: UPDATE THIS FOR THE NEW HATCH.TOML THING
10792

10893
Or, if you want to install from source:
10994

11095
.. code-block:: bash
11196
11297
$ sudo python ./setup.py install
11398
114-
If you want the bitmath manpage installed as well:
115-
116-
.. code-block:: bash
117-
118-
$ sudo make install
99+
If you want the ``/bin/bitmath`` manpage too, then ``sudo make
100+
install`` will install the Python library and the manpage.
119101

120102

121103
Contents

docsite/source/index.rst.in

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -72,50 +72,32 @@ yourself <https://github.com/tbielawa/bitmath/tree/master/tests>`_.
7272
Installation
7373
############
7474

75-
The easiest way to install bitmath is via ``dnf`` (or ``yum``) if
76-
you're on a Fedora/RHEL based distribution. bitmath is available in
77-
the main Fedora repositories, as well as EPEL Repositories. As of 2023
78-
bitmath is only developed, tested, and supported for `currently
79-
supported <https://devguide.python.org/versions/>`_ Python releases.
75+
bitmath is available in Fedora and EPEL repositories, as well as
76+
directly available via `PyPI
77+
<https://pypi.python.org/pypi/bitmath>`_. As of 2023 bitmath is only
78+
developed, tested, and supported for `currently supported
79+
<https://devguide.python.org/versions/>`_ Python releases.
8080

81+
**Package Managers**
8182

8283
.. code-block:: bash
8384

8485
$ sudo dnf install python3-bitmath
86+
$ pip install --user bitmath
8587

8688

87-
**PyPi**:
89+
**Source**::
8890

89-
You could also install bitmath from `PyPi
90-
<https://pypi.python.org/pypi/bitmath>`_ if you like:
91-
92-
.. code-block:: bash
93-
94-
$ sudo pip install bitmath
95-
96-
.. note::
97-
98-
**pip** installs need pip >= 1.1. To workaround this, `download
99-
bitmath <https://pypi.python.org/pypi/bitmath/#downloads>`_, from
100-
PyPi and then ``pip install bitmath-x.y.z.tar.gz``. See `issue #57
101-
<https://github.com/tbielawa/bitmath/issues/57#issuecomment-227018168>`_
102-
for more information.
103-
104-
105-
106-
**Source**:
91+
NOTE: UPDATE THIS FOR THE NEW HATCH.TOML THING
10792

10893
Or, if you want to install from source:
10994

11095
.. code-block:: bash
11196

11297
$ sudo python ./setup.py install
11398

114-
If you want the bitmath manpage installed as well:
115-
116-
.. code-block:: bash
117-
118-
$ sudo make install
99+
If you want the ``/bin/bitmath`` manpage too, then ``sudo make
100+
install`` will install the Python library and the manpage.
119101

120102

121103
Contents

docsite/source/instances.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ bitmath objects have several instance attributes:
2121

2222
.. code-block:: python
2323
24-
>>> b = bitmath.Byte(1337)
25-
>>> print(b.base)
24+
>>> print(bitmath.Byte(1337).base)
2625
2
26+
>>> print(bitmath.kB(1337).base)
27+
10
2728
2829
.. py:attribute:: BitMathInstance.binary
2930

docsite/source/module.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ bitmath.getsize()
3030
:param bool bestprefix: **Default:** ``True``, the returned
3131
instance will be in the best human-readable
3232
prefix unit. If set to ``False`` the result
33-
is a ``bitmath.Byte`` instance.
33+
is a :class:`.Byte` instance.
3434
:param system: **Default:** :py:data:`bitmath.NIST`. The preferred
3535
system of units for the returned instance.
3636
:type system: One of :py:data:`bitmath.NIST` or :py:data:`bitmath.SI`
@@ -110,7 +110,7 @@ bitmath.listdir()
110110
:py:func:`os.path.realpath` to normalize path
111111
references
112112
:param bool bestprefix: **Default:** ``False``, returns
113-
``bitmath.Byte`` instances. Set to ``True``
113+
:class:`.Byte` instances. Set to ``True``
114114
to return the best human-readable prefix
115115
unit for representation
116116
:param system: **Default:** :py:data:`bitmath.NIST`. Set a prefix
@@ -123,7 +123,7 @@ bitmath.listdir()
123123
* This function does **not** return tuples for directory
124124
entities. Including directories in results is `scheduled for
125125
introduction <https://github.com/tbielawa/bitmath/issues/27>`_
126-
in the upcoming 1.1.0 release.
126+
in an upcoming release.
127127
* Symlinks to **files** are followed automatically
128128

129129

@@ -224,8 +224,6 @@ bitmath.parse_string()
224224

225225
.. function:: parse_string(str_repr)
226226

227-
.. versionadded:: 1.1.0
228-
229227
Parse a string representing a unit into a proper bitmath
230228
object. All non-string inputs are rejected and will raise a
231229
:py:exc:`ValueError`. Strings without units are also rejected. See
@@ -337,14 +335,14 @@ bitmath.parse_string()
337335
forgiving with input. Please read the documentation carefully so
338336
you understand the risks you assume using the ``unsafe`` parser.
339337

338+
.. versionadded:: 1.1.0
339+
340340

341341
bitmath.parse_string_unsafe()
342342
=============================
343343

344344
.. function:: parse_string_unsafe(repr[, system=bitmath.SI])
345345

346-
.. versionadded:: 1.3.1
347-
348346
Parse a string or number into a proper bitmath object. This is the
349347
less strict version of the :py:func:`bitmath.parse_string`
350348
function. While :py:func:`bitmath.parse_string` only accepts SI and
@@ -472,6 +470,7 @@ bitmath.parse_string_unsafe()
472470
Capital **G** followed by a lower-case **i** ending with a capital
473471
**B**, ``GiB``.
474472
473+
.. versionadded:: 1.3.1
475474
476475
477476
bitmath.query_device_capacity()

docsite/source/real_life_examples.rst

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -411,17 +411,6 @@ object with the ``query_device_capacity`` function. Here's an example
411411
where we read the capacity of device ``sda``, the first device on the
412412
example system.
413413

414-
.. code-block:: python
415-
416-
>>> import bitmath
417-
>>> fh = open('/dev/sda', 'r')
418-
>>> sda_capacity = bitmath.query_device_capacity(fh)
419-
>>> fh.close()
420-
>>> print(sda_capacity.best_prefix())
421-
238.474937439 GiB
422-
423-
We can simplify this so that the file handle is automatically closed
424-
for us by using the ``with`` context manager.
425414

426415
.. code-block:: python
427416

0 commit comments

Comments
 (0)