From 26ac52644c5a08e3671e5facf9eef262180576fa Mon Sep 17 00:00:00 2001 From: GaboFDC Date: Tue, 8 Mar 2016 10:33:39 -0500 Subject: [PATCH] Updated docstring to use rst format --- asterisk/agi.py | 9 ++++++--- asterisk/agitb.py | 30 ++++++++++++++++++++---------- asterisk/config.py | 16 +++++++++++++--- asterisk/fastagi.py | 18 +++++++++++++----- asterisk/manager.py | 11 ++++++++++- 5 files changed, 62 insertions(+), 22 deletions(-) diff --git a/asterisk/agi.py b/asterisk/agi.py index 90ed288..6336f14 100755 --- a/asterisk/agi.py +++ b/asterisk/agi.py @@ -1,8 +1,9 @@ #!/usr/bin/env python2 # vim: set et sw=4: -"""agi - -This module contains functions and classes to implment AGI scripts in python. +""" +.. module:: agi + :synopsis: This module contains functions and classes to implment AGI scripts in python. + pyvr {'agi_callerid' : 'mars.putland.int', @@ -17,6 +18,8 @@ pyvr 'agi_request' : 'pyst', 'agi_type' : 'IAX'} +Specification +------------- """ import sys diff --git a/asterisk/agitb.py b/asterisk/agitb.py index a712194..cdd3be9 100644 --- a/asterisk/agitb.py +++ b/asterisk/agitb.py @@ -1,20 +1,27 @@ -"""More comprehensive traceback formatting for Python scripts. +""" +.. module:: agitb + :synopsis: More comprehensive traceback formatting for Python scripts. + +Example +------- To enable this module, do: - import asterisk.agitb, asterisk.agi - asterisk.agitb.enable(display = False, logdir = '/var/log/asterisk/') +.. code-block:: python - agi = asterisk.agi.AGI() - asterisk.agitb.enable(agi, False, '/var/log/asterisk') + import asterisk.agitb, asterisk.agi + asterisk.agitb.enable(display = False, logdir = '/var/log/asterisk/') + + agi = asterisk.agi.AGI() + asterisk.agitb.enable(agi, False, '/var/log/asterisk') at the top of your script. The optional arguments to enable() are: - agi - the agi handle to write verbose messages to - display - if true, tracebacks are displayed on the asterisk console - (used with the agi option) - logdir - if set, tracebacks are written to files in this directory - context - number of lines of source code to show for each stack frame +* agi - the agi handle to write verbose messages to +* display - if true, tracebacks are displayed on the asterisk console + (used with the agi option) +* logdir - if set, tracebacks are written to files in this directory +* context - number of lines of source code to show for each stack frame By default, tracebacks are displayed but not saved, and the context is 5 lines. @@ -27,6 +34,9 @@ for you, call agitb.handler(). The optional argument to handler() is a If you do not pass anything to handler() it will use sys.exc_info(). This script was adapted from Ka-Ping Yee's cgitb. + +Specification +------------- """ __author__ = 'Matthew Nicholson' diff --git a/asterisk/config.py b/asterisk/config.py index b86a9ae..7c53b0b 100644 --- a/asterisk/config.py +++ b/asterisk/config.py @@ -1,13 +1,19 @@ #!/usr/bin/env python # vim: set expandtab: """ -Parse Asterisk configuration files. +.. module:: config + :synopsis: Parse Asterisk configuration files. This module provides parsing functionality for asterisk config files. +Example +---------- + +.. code-block:: python + import asterisk.config import sys - + # load and parse the config file try: config = asterisk.config.Config('/etc/asterisk/extensions.conf') @@ -17,13 +23,17 @@ This module provides parsing functionality for asterisk config files. except IOError as e: print "Error opening file: %s" % e.strerror sys.exit(1) - + # print our parsed output for category in config.categories: print '[%s]' % category.name # print the current category for item in category.items: print ' %s = %s' % (item.name, item.value) + + +Specification +------------- """ import sys diff --git a/asterisk/fastagi.py b/asterisk/fastagi.py index db76608..2e137fd 100755 --- a/asterisk/fastagi.py +++ b/asterisk/fastagi.py @@ -1,9 +1,17 @@ #!/usr/bin/env python -# FastAGI service for Asterisk -# Requires modified pyst2 to support reading stdin/out/err -# -# Copyright 2011 VOICE1, LLC -# By: Ben Davis + +""" +.. module:: fastagi + :synopsis: FastAGI service for Asterisk + +Requires modified pyst2 to support reading stdin/out/err + + Copyright 2011 VOICE1, LLC + By: Ben Davis + +Specification +------------- +""" import sys import SocketServer diff --git a/asterisk/manager.py b/asterisk/manager.py index 2f84f68..60e70d0 100644 --- a/asterisk/manager.py +++ b/asterisk/manager.py @@ -2,10 +2,16 @@ # vim: set expandtab shiftwidth=4: """ -Python Interface for Asterisk Manager +.. module:: manager + :synopsis: Python Interface for Asterisk Manager This module provides a Python API for interfacing with the asterisk manager. +Example +------- + +.. code-block:: python + import asterisk.manager import sys @@ -50,6 +56,9 @@ Remember all header, response, and event names are case sensitive. Not all manager actions are implmented as of yet, feel free to add them and submit patches. + +Specification +------------- """ import sys