-
First check
DescriptionI have written a typer CLI and I have created automated documentation for it using sphinx and autodoc. But I have encountered an issue where the documentation reads:
where I would like it to say:
Is it possible to expose the standard value to autodoc? I found a potential fix in https://stackoverflow.com/questions/12082570/override-function-declaration-in-autodoc-for-sphinx/12087750#12087750 |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 2 replies
-
|
Did you get further on your quest? Do you mind share how you are doing autodoc? Looking for the same |
Beta Was this translation helpful? Give feedback.
-
|
The rst for the autodocs page is .. _cli-reference:
Command-line Interface
======================
.. automodule:: mvi.cli.cli
:members:
:undoc-members:
:show-inheritance:and the following extensions in extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"sphinx_rtd_theme",
"sphinx.ext.doctest",
"sphinx_multiversion",
]The result ends up looking like this: https://vikinganalytics.github.io/mvi-docs/0.4.3/content/api_reference/cli.html I also found this answer on stack overflow about how to change the signature in the rst, but it has to be updated everytime we make a change in the signature of a CLI command, so we opted to not do it: https://stackoverflow.com/questions/5365684/is-it-possible-to-override-sphinx-autodoc-for-specific-functions/5368194#5368194 It might be possible to write a custom extension for sphinx that can handle typer function signatures a bit nicer, but it is not something that we have prioritized. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for this! Very nice for api-doc (which I'm also going to do). I'm fairly new to sphinx, and this looks like a great module! I'm not sure yet, but I think i'm ending up with just using |
Beta Was this translation helpful? Give feedback.
-
|
I know it is not autodoc but it might help people in a similar spot that do not have a hard requirement on that. Since typer uses click under the hood, you can use this by exposing the .. click:: path.to.module:typer_click_object
:prog: prog_name
:nested: fullHope someone finds this helpful. |
Beta Was this translation helpful? Give feedback.
-
|
That is awesome @edthamm ! If that works, it completely solves my problem! Thanks for sharing |
Beta Was this translation helpful? Give feedback.
-
|
@xeor it works well enough for me. My use case is pretty light weight so it might well be that there are some things that do not work. Just saying YMMV. Anyways, happy to help. One caveat I noticed for example is that the help text of arguments is not displayed in line with the arguments. Options work perfectly fine though. That is not a big deal for me as I do not use arguments often or at all in my application. And in case I do I document them in the doc-string as well. |
Beta Was this translation helpful? Give feedback.
-
|
Is it worth putting this comment in the docs? If so, I'd be happy to make a PR (but then I also think the credit would go at least slightly in the wrong place!) |
Beta Was this translation helpful? Give feedback.
I know it is not autodoc but it might help people in a similar spot that do not have a hard requirement on that.
I actually like the documentation provided by sphinx_click.
Since typer uses click under the hood, you can use this by exposing the
typer_click_objectas input for that.How to get that is described here
and using it works like this
Hope someone finds this helpful.