sphinx-argparse
sphinx-argparse copied to clipboard
Specifying parser in a function using non-module reference
I have a function in a file which parses arguments:
def get_args():
#Set up parser and top level args
parser = argparse.ArgumentParser(description='ASCENT: Automated Simulations to Characterize Electrical Nerve Thresholds')
parser.add_argument('run_indices', nargs = '+', help = 'Space separated indices to submit NEURON sims for')
parser.add_argument('-p','--partition', help = 'If submitting on a cluster, overrides default partition assignment')
args = parser.parse_args()
return args
This file is not part of a module, therefore I am using the filename to point to the function:
Command-Line Arguments
***********************
submit.py
---------
.. argparse::
:filename: ../../src/neuron/submit.py
:func: parser
:prog: submit.py
This results in the following error:
Exception occurred:
File "/home/docs/checkouts/readthedocs.org/user_builds/ascent-docs/envs/latest/lib/python3.7/site-packages/sphinxarg/ext.py", line 476, in run
func = mod[attr_name]
KeyError: 'parser'
I am assuming since it is contained within a function, sphinx-argparse cannot find the parser object. How can I point to the parser within the function get_args()?
Thanks!