Skip to content

Instantly share code, notes, and snippets.

@sverhoeven
Created August 14, 2023 12:51
Show Gist options
  • Save sverhoeven/4d4b354e53f473b90378e2f18f30e914 to your computer and use it in GitHub Desktop.
Save sverhoeven/4d4b354e53f473b90378e2f18f30e914 to your computer and use it in GitHub Desktop.
Gist to see how mkdocstring inherits types from superclass attribute
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

Reference

::: type_inherit_mkdocs

site_name: My Docs
plugins:
- mkdocstrings:
default_handler: python
handlers:
python:
paths: [src]
options:
members_order: source
show_source: false
watch: [src]
[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