Skip to content

Commit

Permalink
Fix readme and add docs build to CI suite
Browse files Browse the repository at this point in the history
  • Loading branch information
codingjoe authored Apr 18, 2020
1 parent 0978a66 commit b1d391f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ jobs:
- run: python -m pip install black
- run: black --check --diff .

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v1
- run: sudo apt-get install -y graphviz
- uses: actions/checkout@v2
- run: git fetch --prune --unshallow
- run: python setup.py develop
- run: python setup.py build_sphinx -W

pytest:
needs:
- isort
Expand Down
14 changes: 12 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Python measurement

**High precision unit-aware measurement objects in Python.**

.. code-block:: python
>>> from measurement import measures
>>> measures.Distance("12 megaparsec")["British yard"]
Decimal('404948208659679393828910.8771')
Expand Down Expand Up @@ -33,6 +35,8 @@ Using Measurement Objects
You can import any of the above measures from `measurement.measures`
and use it for easily handling measurements like so:

.. code-block:: python
>>> from measurement.measures import Mass
>>> m = Mass(lb=135) # Represents 135 lbs
>>> print(m)
Expand All @@ -44,10 +48,12 @@ You can create a measurement unit using any compatible unit and can transform
it into any compatible unit. See :doc:`measures` for information about which
units are supported by which measures.

.. seealso::
.. note::
Should you be planing to go to Mars, you might need to increase your
`decimal precision`_, like so:

.. code-block:: python
>>> import decimal
>>> decimal.getcontext().prec = 28
Expand All @@ -58,7 +64,9 @@ Guessing Measurements

If you happen to be in a situation where you are processing a list of
value/unit pairs (like you might find at the beginning of a recipe), you can
use the `guess` function to give you a measurement object.:
use the :func:`.guess` function to give you a measurement object.:

.. code-block:: python
>>> from measurement.utils import guess
>>> m = guess(10, "mg")
Expand All @@ -71,6 +79,8 @@ measures checked (or your own measurement classes, too) to make sure
that your measurement is not mis-guessed, and you can do that by specifying
the ``measures`` keyword argument:

.. code-block:: python
>>> from measurement.measures import Distance, Temperature, Volume
>>> m = guess(24, "°F", measures=[Distance, Volume, Temperature])
>>> print(repr(m))
Expand Down
8 changes: 8 additions & 0 deletions docs/measures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,11 @@ Supported Measures and Units
:members:
:undoc-members:
:imported-members:

Units
-----

.. automodule:: measurement.utils
:members:
:undoc-members:
:imported-members:

0 comments on commit b1d391f

Please sign in to comment.