Open dwysocki opened 5 years ago
I have a project with a number of command line tools implemented as static methods and class methods. It seems, however, not possible to tell sphinx-argparse how to access these parsers.
sphinx-argparse
Simplified example:
If we have a module cli.py
cli.py
import argparse class Foo(object): @staticmethod def make_parser(): parser = argparse.ArgumentParser() parser.add_argument("test") return parser @classmethod def main(cls): parser = cls.make_parser() args = parser.parse_args() print(args.test)
None of the ways I think could generate documentation for this seem to work.
One way:
Test Command ============ .. argparse:: :module: cli :func: Foo.make_parser :prog: command_name
produces the error:
/path/to/file.rst:4: WARNING: Module "cli" has no attribute "Foo.make_parser" Incorrect argparse :module: or :func: values?
Another way:
Test Command ============ .. argparse:: :ref: cli.Foo.make_parser :prog: command_name
produces the error
/path/to/file.rst:4: WARNING: Failed to import "make_parser" from "cli.Foo". No module named 'cli.foo'; 'cli' is not a package
Would it be possible to make this work somehow? Perhaps an additional directive is needed?
I have a project with a number of command line tools implemented as static methods and class methods. It seems, however, not possible to tell
sphinx-argparse
how to access these parsers.Simplified example:
If we have a module
cli.py
None of the ways I think could generate documentation for this seem to work.
One way:
produces the error:
Another way:
produces the error
Would it be possible to make this work somehow? Perhaps an additional directive is needed?