doc: use sphinx-argparse

pull/9/head
Sebastien Bourdeauducq 2015-01-23 00:52:13 +08:00
parent 47aa634ab5
commit 9fb42e4952
16 changed files with 95 additions and 34 deletions

View File

@ -19,7 +19,7 @@ def clear_screen():
sys.stdout.write("\x1b[2J\x1b[H")
def _get_args():
def get_argparser():
parser = argparse.ArgumentParser(description="ARTIQ CLI client")
parser.add_argument(
"-s", "--server", default="::1",
@ -80,7 +80,7 @@ def _get_args():
"what",
help="select object to show: queue/timed/devices/parameters")
return parser.parse_args()
return parser
def _parse_arguments(arguments):
@ -226,7 +226,7 @@ def _show_dict(args, notifier_name, display_fun):
def main():
args = _get_args()
args = get_argparser().parse_args()
action = args.action.replace("-", "_")
if action == "show":
if args.what == "queue":

View File

@ -5,18 +5,18 @@ import argparse
from artiq.protocols.pc_rpc import Client
def _get_args():
def get_argparser():
parser = argparse.ArgumentParser(
description="ARTIQ controller identification tool")
parser.add_argument("server",
help="hostname or IP of the controller to connect to")
parser.add_argument("port", type=int,
help="TCP port to use to connect to the controller")
return parser.parse_args()
return parser
def main():
args = _get_args()
args = get_argparser().parse_args()
remote = Client(args.server, args.port, None)
try:
target_names, id_parameters = remote.get_rpc_id()

View File

@ -13,7 +13,7 @@ from artiq.gui.parameters import ParametersWindow
from artiq.gui.rt_results import RTResults
def _get_args():
def get_argparser():
parser = argparse.ArgumentParser(description="ARTIQ GUI client")
parser.add_argument(
"-s", "--server", default="::1",
@ -24,11 +24,11 @@ def _get_args():
parser.add_argument(
"--port-control", default=3251, type=int,
help="TCP port to connect to for control")
return parser.parse_args()
return parser
def main():
args = _get_args()
args = get_argparser().parse_args()
asyncio.set_event_loop_policy(gbulb.GtkEventLoopPolicy())
loop = asyncio.get_event_loop()

View File

@ -11,7 +11,7 @@ from artiq.master.scheduler import Scheduler
from artiq.master.rt_results import RTResults
def _get_args():
def get_argparser():
parser = argparse.ArgumentParser(description="ARTIQ master")
parser.add_argument(
"--bind", default="::1",
@ -22,11 +22,11 @@ def _get_args():
parser.add_argument(
"--port-control", default=3251, type=int,
help="TCP port to listen to for control")
return parser.parse_args()
return parser
def main():
args = _get_args()
args = get_argparser().parse_args()
ddb = FlatFileDB("ddb.pyon")
pdb = FlatFileDB("pdb.pyon")

View File

@ -31,7 +31,7 @@ class SimpleParamLogger:
print("Parameter change: {} -> {}".format(name, value))
def _get_args():
def get_argparser():
parser = argparse.ArgumentParser(
description="Local experiment running tool")
@ -49,7 +49,7 @@ def _get_args():
parser.add_argument("arguments", nargs="*",
help="run arguments")
return parser.parse_args()
return parser
def _parse_arguments(arguments):
@ -61,7 +61,7 @@ def _parse_arguments(arguments):
def main():
args = _get_args()
args = get_argparser().parse_args()
ddb = FlatFileDB(args.ddb)
pdb = FlatFileDB(args.pdb)

View File

@ -5,18 +5,20 @@ import argparse
from artiq.protocols.pc_rpc import Client
def main():
def get_argparser():
parser = argparse.ArgumentParser()
parser.add_argument('-s', '--server', default="::1",
parser.add_argument("-s", "--server", default="::1",
help="hostname or IP of the controller to connect to")
parser.add_argument('-p', '--port', default=3253, type=int,
parser.add_argument("-p", "--port", default=3253, type=int,
help="TCP port to use to connect to the controller")
parser.add_argument('-a', '--attenuation', type=float,
parser.add_argument("-a", "--attenuation", type=float,
help="attenuation value to set")
args = parser.parse_args()
return parser
def main():
args = get_argparser().parse_args()
remote = Client(args.server, args.port, "lda")
try:
if args.attenuation is None:
print("Current attenuation: {}".format(remote.get_attenuation()))

View File

@ -6,7 +6,7 @@ from artiq.devices.lda.driver import Lda, Ldasim
from artiq.protocols.pc_rpc import simple_server_loop
def main():
def get_argparser():
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--device', default="LDA-102",
choices=["LDA-102", "LDA-602", "sim"])
@ -16,13 +16,15 @@ def main():
help="TCP port to listen to")
parser.add_argument('-s', '--serial', default=None,
help="USB serial number of the device")
args = parser.parse_args()
return parser
def main():
args = get_argparser().parse_args()
if args.device == "sim":
lda = Ldasim()
else:
lda = Lda(args.serial, args.device)
simple_server_loop({"lda": lda},
args.bind, args.port)

View File

@ -11,7 +11,7 @@ import numpy as np
from artiq.protocols.pc_rpc import Client
def _get_args():
def get_argparser():
parser = argparse.ArgumentParser(description="""PDQ2 client.
Evaluates times and voltages, interpolates and uploads
them to the controller.""")
@ -49,11 +49,11 @@ def _get_args():
action="store_true", help="do reset before")
parser.add_argument("-b", "--bit", default=False,
action="store_true", help="do bit test")
return parser.parse_args()
return parser
def main():
args = _get_args()
args = get_argparser().parse_args()
dev = Client(args.server, args.port, "pdq2")
dev.init()

View File

@ -7,7 +7,7 @@ from artiq.devices.pdq2.driver import Pdq2
from artiq.protocols.pc_rpc import simple_server_loop
def _get_args():
def get_argparser():
parser = argparse.ArgumentParser(description="PDQ2 controller")
parser.add_argument("--bind", default="::1",
help="hostname or IP address to bind to")
@ -19,11 +19,11 @@ def _get_args():
parser.add_argument(
"-d", "--debug", default=False, action="store_true",
help="debug communications")
return parser.parse_args()
return parser
def main():
args = _get_args()
args = get_argparser().parse_args()
if args.debug:
logging.basicConfig(level=logging.DEBUG)

View File

@ -32,6 +32,7 @@ import os
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.mathjax',
'sphinxarg.ext',
]
# Add any paths that contain templates here, relative to this directory.
@ -48,7 +49,7 @@ master_doc = 'index'
# General information about the project.
project = 'ARTIQ'
copyright = '2014, M-Labs / NIST Ion Storage Group'
copyright = '2014-2015, M-Labs / NIST Ion Storage Group'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the

View File

@ -17,6 +17,13 @@ Each driver is run in a separate "controller" that exposes a RPC interface (base
.. automodule:: artiq.devices.pdq2
:members:
.. argparse::
:ref: artiq.frontend.pdq2_controller.get_argparser
:prog: pdq2_controller
.. argparse::
:ref: artiq.frontend.pdq2_client.get_argparser
:prog: pdq2_client
:mod:`artiq.devices.lda` module
---------------------------------
@ -24,6 +31,14 @@ Each driver is run in a separate "controller" that exposes a RPC interface (base
.. automodule:: artiq.devices.lda.driver
:members:
.. argparse::
:ref: artiq.frontend.lda_controller.get_argparser
:prog: lda_controller
.. argparse::
:ref: artiq.frontend.lda_client.get_argparser
:prog: lda_client
Default TCP port list
---------------------

View File

@ -9,8 +9,10 @@ Contents:
installing
getting_started
writing_a_driver
management_system
core_language_reference
core_drivers_reference
protocols_reference
drivers_reference
utilities
fpga_board_ports

View File

@ -0,0 +1,23 @@
Management system
=================
Master
------
.. argparse::
:ref: artiq.frontend.artiq_master.get_argparser
:prog: artiq_master
Command-line client
-------------------
.. argparse::
:ref: artiq.frontend.artiq_client.get_argparser
:prog: artiq_client
GUI client
----------
.. argparse::
:ref: artiq.frontend.artiq_gui.get_argparser
:prog: artiq_gui

View File

@ -1,5 +1,5 @@
Management reference
====================
Protocols reference
===================
:mod:`artiq.protocols.asyncio_server` module
--------------------------------------------

16
doc/manual/utilities.rst Normal file
View File

@ -0,0 +1,16 @@
Utilities
=========
Local running tool
------------------
.. argparse::
:ref: artiq.frontend.artiq_run.get_argparser
:prog: artiq_run
Controller identification tool
------------------------------
.. argparse::
:ref: artiq.frontend.artiq_ctlid.get_argparser
:prog: artiq_ctlid

View File

@ -15,7 +15,7 @@ setup(
long_description=open("README.rst").read(),
license="BSD",
install_requires=[
"sphinx", "pyserial", "numpy", "scipy", "prettytable"
"sphinx", "sphinx-argparse", "pyserial", "numpy", "scipy", "prettytable"
],
extras_require={},
dependency_links=[],