Skip to content

Commit

Permalink
Doctests weren't run any longer (#93)
Browse files Browse the repository at this point in the history
Closes #86
  • Loading branch information
regebro committed Jun 11, 2022
1 parent d43af9f commit 7b17340
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Expand Up @@ -7,6 +7,8 @@ Changelog

- Allow numbers with decimal point but no decimals, because other parsers do.

- Re-enabled the README.rst doctest, which got lost when switching to pytest


6.1 (2022-06-09)
----------------
Expand Down
18 changes: 15 additions & 3 deletions README.rst
Expand Up @@ -16,7 +16,7 @@ All coordinate values for these classes are given as ``complex`` values,
where the ``.real`` part represents the X coordinate, and the ``.imag`` part
representes the Y coordinate::

>>> from svg.path import Path, Line, Arc, CubicBezier, QuadraticBezier, Close
>>> from svg.path import Path, Move, Line, Arc, CubicBezier, QuadraticBezier, Close

All of these objects have a ``.point()`` function which will return the
coordinates of a point on the path, where the point is given as a floating
Expand Down Expand Up @@ -74,9 +74,9 @@ with a sequence of path segments:
The ``Path`` class is a mutable sequence, so it behaves like a list.
You can add to it and replace path segments etc::

>>> path = Path(Line(100+100j,300+100j), Line(100+100j,300+100j))
>>> path = Path(Move(200+100j), Line(200+100j,100+200j), Line(100+200j,300+100j))
>>> path.append(QuadraticBezier(300+100j, 200+200j, 200+300j))
>>> path[0] = Line(200+100j,300+100j)
>>> path[0] = Move(200+100j)
>>> del path[1]

The path object also has a ``d()`` method that will return the
Expand All @@ -85,6 +85,18 @@ SVG representation of the Path segments::
>>> path.d()
'M 200,100 L 300,100 Q 200,200 200,300'

Note that there currently is no internal consistency checks when you
manipulate lines this way. This path now has an internal representation that
it's different from it's d() path. Notice how the `Line()` segment starts in
a different location from where the `Move()` segments say. This **may**
change in future releases, and the Path manipulation methods **may** be
changed to ensure consistency.

>>> path
Path(Move(to=(200+100j)), Line(start=(100+200j), end=(300+100j)),
QuadraticBezier(start=(300+100j), control=(200+200j), end=(200+300j),
smooth=False))


Examples
........
Expand Down
5 changes: 2 additions & 3 deletions src/svg/path/tests/test_doc.py
@@ -1,6 +1,5 @@
import doctest


def load_tests(loader, tests, ignore):
tests.addTests(doctest.DocFileSuite("README.rst", package="__main__"))
return tests
def test_readme():
doctest.testfile("../../../../README.rst")

0 comments on commit 7b17340

Please sign in to comment.