-
Notifications
You must be signed in to change notification settings - Fork 788
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
Document custom types used and actually show their definition #2168
Comments
I think the most straightforward solution would be to cover it in the docstrings. We do seem to be missing docstrings for |
So, to clarify, you are suggesting that the docstring for |
Yeah, if we can't somehow expand the |
Ok. I'll see what I can do. |
Ok, I can correctly export useful type aliases and I can have the docs cross-reference them automatically when they show up in signatures. (Thanks, Dave, for the work in #2287!) However, if you show a type alias in the docs, it won't expand its definition, even if you set the option So, do I manually add this duplicated info to the docstrings of those type aliases? |
What happens if we use the type in the docstring? i.e. something like this? CSS_PATH = ""
"""str | list[str] | None: Path to css files, or a list of paths.""" |
That's fine and it'll show up but it's duplicated... CSS_PATH: CSSPathType = ""
"""str | list[str] | None: Path to css files, or a list of paths.""" It wouldn't be terrible if we added it to the type alias: CSSPathType = Union[
str,
PurePath,
List[Union[str, PurePath]],
]
"""str | PurePath | List[str | PurePath]: Valid types to set the path to CSS files.""" it is still duplication, but it is less duplication for type aliases that are used more than once. |
I'll see what reply I get back from mkdocstrings/mkdocstrings#559 |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
I think we should document, perhaps in the API page, the custom types we use for things that are already documented.
For example,
App.CSS_PATH
shows up in the docs and is typed asCSSPathType
, and the type itself is pretty much all the documentation needed forApp.CSS_PATH
.However,
CSSPathType
isn't documented.In my opinion, we chould/should document these custom types in the module they are defined in, or they should all be collected in a “Types” API page, for example.
Note: I spent some time trying to do this for a single type (
CSSPathType
) and I managed to put it in a separate API page.However, I wasn't getting two important things:
App.CSS_PATH
wasn't linking toCSSPathType
.CSSPathType
show its signature, which is what I really wanted to have documented.The text was updated successfully, but these errors were encountered: