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

Unify cli validation interfaces #467

Closed
stefanv opened this issue Jun 29, 2023 · 8 comments · Fixed by #537
Closed

Unify cli validation interfaces #467

stefanv opened this issue Jun 29, 2023 · 8 comments · Fixed by #537

Comments

@stefanv
Copy link
Contributor

stefanv commented Jun 29, 2023

See #454

python -m numpydoc
python -m numpydoc.hooks.validate_docstrings

These CLI interfaces do slightly different things, but one could imagine a command word interface a-la git.

Also, it would be good to expose this as an executable user-script numpydoc.

/cc @stefmolin

@stefmolin
Copy link
Contributor

I'll tackle this one after #466

@stefmolin
Copy link
Contributor

stefmolin commented Mar 23, 2024

Is there a preference between these two options?

$ numpydoc render           # runs the current numpydoc CLI's render_object()
$ numpydoc validate         # runs the current --validate
$ numpydoc validate --ast   # runs the current numpydoc.hooks.validate_docstrings

OR to not affect current users:

$ numpydoc                    # runs the current numpydoc CLI's render_object()
$ numpydoc --validate         # runs the current --validate
$ numpydoc --ast-validation   # runs the current numpydoc.hooks.validate_docstrings

I'm calling the hook method "ast" because it uses the abstract syntax tree unlike the original validation, but let me know if we should use something else.

@stefanv
Copy link
Contributor Author

stefanv commented Mar 23, 2024

How about:

$ numpydoc  # alias for numpydoc render
$ numpydoc render
$ numpydoc validate

@stefmolin
Copy link
Contributor

And numpydoc validate would have the flag to trigger the hook version?

@stefanv
Copy link
Contributor Author

stefanv commented Mar 23, 2024

Or just drop the alias; it's not like this is done so often by hand.

@stefmolin
Copy link
Contributor

Looking at this more, I actually don't think the --validate logic should be combined with the hook logic because they operate on different inputs: the hook takes files and the --validate option takes a dotted path, which could be to anything.

How about having separate subcommands for each?

$ numpydoc render
$ numpydoc validate
$ numpydoc hook

@stefanv
Copy link
Contributor Author

stefanv commented Mar 23, 2024

Nice and clean; I prefer that too.

@stefanv
Copy link
Contributor Author

stefanv commented Mar 23, 2024

hook is perhaps not a super intuitive name; numpydoc lint?

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

Successfully merging a pull request may close this issue.

2 participants