File: mermaid_demo.py

package info (click to toggle)
python-pdoc 15.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,192 kB
  • sloc: python: 8,013; javascript: 1,156; makefile: 18; sh: 3
file content (35 lines) | stat: -rw-r--r-- 648 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
A small `pdoc` example using Mermaid diagrams.

The relationship for Pet and Dog follows the UML diagram:

```mermaid
classDiagram
    class Dog~Pet~{
        -__init__(str name) None
        +bark(bool loud) None
    }
    Dog <|-- Pet
    Pet : +str name
    Pet : +List[Pet] friends
```
"""


class Pet:
    name: str
    """The name of our pet."""
    friends: list["Pet"]
    """The friends of our pet."""

    def __init__(self, name: str):
        """Make a Pet without any friends (yet)."""
        self.name = name
        self.friends = []


class Dog(Pet):
    """🐕"""

    def bark(self, loud: bool = True):
        """*woof*"""