::: type_inherit_mkdocs
Created
August 14, 2023 12:51
-
-
Save sverhoeven/4d4b354e53f473b90378e2f18f30e914 to your computer and use it in GitHub Desktop.
Gist to see how mkdocstring inherits types from superclass attribute
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Vehicle: | |
"""A vehicle class | |
Attributes: | |
weight: The weight of the vehicle | |
""" | |
weight: float = 0.0 | |
def __init__(self, weight: float) -> None: | |
self.weight = weight | |
class Car(Vehicle): | |
"""A car class | |
Attributes: | |
weight: The weight of the vehicle | |
wheels: The number of wheels on the car | |
""" | |
wheels: int = 4 | |
def __init__(self, weight: float, wheels: int) -> None: | |
super().__init__(weight) | |
self.wheels = wheels | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
site_name: My Docs | |
plugins: | |
- mkdocstrings: | |
default_handler: python | |
handlers: | |
python: | |
paths: [src] | |
options: | |
members_order: source | |
show_source: false | |
watch: [src] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[build-system] | |
requires = ["setuptools>=61.0"] | |
build-backend = "setuptools.build_meta" | |
[project] | |
name = "type-inherit-mkdocs" | |
version = "0.1.0" | |
requires-python = ">=3.10" | |
dependencies = [ | |
"mkdocs", | |
"mkdocstrings[python]>=0.18", | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment