Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NotImplementedError: <class 'defopt._parse_docstring.<locals>.Visitor'> visiting unknown node type: definition_list #122

Open
nh13 opened this issue Jun 6, 2023 · 3 comments

Comments

@nh13
Copy link

nh13 commented Jun 6, 2023

defopt 6.4.0

import defopt


def main(*, arg: int) -> None:
    """Short tool description

    longer description

    Args:
        arg: description
    
    Output Format 1:
        - detail 1
        - detail 2:
            - sub-detail 2.2
        - detail 3
    """
    pass


if __name__ == '__main__':
    defopt.run(main)
@anntzer
Copy link
Owner

anntzer commented Jun 6, 2023

I don't mind adding support for definition_lists (or rather taking a PR that does so), but I suspect what you really want to write here is

import defopt

def main(*, arg: int) -> None:
    """Short tool description

    longer description

    Args:
        arg: description

    Output Format 2:

    - detail 1

    - detail 2

        - sub-detail 2.2

    - detail 3
    """
    pass

if __name__ == '__main__':
    defopt.run(main)

which I agree is a lot of whitespace, but that's rst's syntax (AFAICT) and I'm not going to change that here.

Now the above form does run into the error you reported at #123 and #123 (comment) does help, but the output's whitespace is pretty messed up so I'd much prefer a solution that yields better whitespace.

@nh13
Copy link
Author

nh13 commented Jun 6, 2023

@anntzer I'll add it my list to make a PR for definition_list. Perhaps we can add to the docs that the description should be in RST. Are there other formats (e.g. github-flavored markdown, others)?

@anntzer
Copy link
Owner

anntzer commented Jun 6, 2023

Oops, I realize the requirement for rst is not documented anywhere, indeed (I guess this is implied by the statement "Docstrings can use the standard Sphinx-style ... or Google- and Numpy-style docstrings (see examples/styles.py), which are converted using Napoleon [1]." at the top of features.rst).
I added that information explicitly to the docstring of run().

Adding support for markdown likely means plugging something like myst-parser (as I'll likely not want to get away from using docutils as core), which may require some work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants