sphinx-doc / sphinx-doc/sphinx-argparse
Specifying parser in a function using non-module reference
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 38
- Forks
- 33
- PR merge metrics
- No merged PRs in 30d
Description
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!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in sphinxarg/ext.py around the failing run method and compare its :func: lookup with the get_args() and parser definitions shown in the issue. Reproduce the Sphinx build using the submit.py and argparse directive, then confirm the intended behavior for a parser created inside a function.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100