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/server/run.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'diplomacy/server/run.py') diff --git a/diplomacy/server/run.py b/diplomacy/server/run.py index f47ed4f..8f28e3d 100755 --- a/diplomacy/server/run.py +++ b/diplomacy/server/run.py @@ -16,20 +16,29 @@ # with this program. If not, see . # ============================================================================== """ Small module script to quickly start a server with pretty log-printing. + You can stop the server with keyboard interruption (Ctrl+C). Usage: - python -m diplomacy.server.run # run on port 8432. - python -m diplomacy.server.run --port= # run on given port. + + .. code-block:: bash + + # run on port 8432. + python -m diplomacy.server.run + + # run on given port. + python -m diplomacy.server.run --port= + """ import argparse from diplomacy import Server from diplomacy.utils import constants -PARSER = argparse.ArgumentParser(description='Run server.') -PARSER.add_argument('--port', '-p', type=int, default=constants.DEFAULT_PORT, - help='run on the given port (default: %s)' % constants.DEFAULT_PORT) -ARGS = PARSER.parse_args() +if __name__ == '__main__': + PARSER = argparse.ArgumentParser(description='Run server.') + PARSER.add_argument('--port', '-p', type=int, default=constants.DEFAULT_PORT, + help='run on the given port (default: %s)' % constants.DEFAULT_PORT) + ARGS = PARSER.parse_args() -try: - Server().start(port=ARGS.port) -except KeyboardInterrupt: - print('Keyboard interruption.') + try: + Server().start(port=ARGS.port) + except KeyboardInterrupt: + print('Keyboard interruption.') -- cgit v1.2.3