From abb42dcd4886705d6ba8af27f68ef605218ac67c Mon Sep 17 00:00:00 2001 From: Philip Paquette Date: Wed, 11 Sep 2019 12:58:45 -0400 Subject: Added ReadtheDocs documentation for the public API - Reformatted the docstring to be compatible - Added tests to make sure the documentation compiles properly - Added sphinx as a pip requirement Co-authored-by: Philip Paquette Co-authored-by: notoraptor --- diplomacy/integration/webdiplomacy_net/orders.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'diplomacy/integration/webdiplomacy_net/orders.py') diff --git a/diplomacy/integration/webdiplomacy_net/orders.py b/diplomacy/integration/webdiplomacy_net/orders.py index afacf03..8fa966c 100644 --- a/diplomacy/integration/webdiplomacy_net/orders.py +++ b/diplomacy/integration/webdiplomacy_net/orders.py @@ -18,9 +18,10 @@ LOGGER = logging.getLogger(__name__) def is_adjacent_for_convoy(loc_1, loc_2, map_object): """ Checks if two locations are adjacent (for convoy purposes) - - If loc_1 and loc_2 are water, loc_1 and loc_2 must be adjacent - - If loc_1 or loc_2 is land, then they are not adjacent - - If loc_1 or loc_2 are coast, then the other locations needs to be a water loc at most 1 loc away + + - If loc_1 and loc_2 are water, loc_1 and loc_2 must be adjacent + - If loc_1 or loc_2 is land, then they are not adjacent + - If loc_1 or loc_2 are coast, then the other locations needs to be a water loc at most 1 loc away :type map_object: diplomacy.Map """ @@ -48,6 +49,7 @@ def is_adjacent_for_convoy(loc_1, loc_2, map_object): def find_convoy_path(src, dest, map_object, game=None, including=None, excluding=None): """ Finds a convoy path from src to dest + :param src: The source location (e.g. 'BRE') :param dest: The destination location (e.g. 'LON') :param map_object: A diplomacy.Map object representation of the current map @@ -55,7 +57,7 @@ def find_convoy_path(src, dest, map_object, game=None, including=None, excluding :param including: Optional. A single province (e.g. 'NAO') or a list of provinces that must be in the path. :param excluding: Optional. A single province (e.g. 'NAO') or a list of provinces that must NOT be in the path. :return: Either an empty list if a convoy is not possible between src and dest - or a list of [src, fleet1, fleet2, ..., fleet_n, dest] to use to convoy A `src` - `dest`. + or a list of [src, fleet1, fleet2, ..., fleet_n, dest] to use to convoy A `src` - `dest`. :type map_object: diplomacy.Map :type game: diplomacy.Game """ @@ -122,11 +124,12 @@ def find_convoy_path(src, dest, map_object, game=None, including=None, excluding return [] -class Order(): +class Order: """ Class to convert order from string representation to dictionary (webdiplomacy.net) representation """ def __init__(self, order, map_id=None, map_name=None, phase_type=None, game=None): """ Constructor + :param order: An order (either as a string 'A PAR H' or as a dictionary) :param map_id: Optional. The map id of the map where orders are submitted (webdiplomacy format) :param map_name: Optional. The map name of the map where orders are submitted. @@ -162,6 +165,7 @@ class Order(): def _build_from_string(self, order, game=None): """ Builds this object from a string + :type order: str :type game: diplomacy.Game """ @@ -444,6 +448,7 @@ class Order(): def _build_from_dict(self, order): """ Builds this object from a dictionary + :type order: dict """ # pylint: disable=too-many-return-statements -- cgit v1.2.3