sphinxcontrib-mermaid icon indicating copy to clipboard operation
sphinxcontrib-mermaid copied to clipboard

Does not fully render `classDiagram` and does not render `sequenceDiagram`

Open FFY00 opened this issue 4 years ago • 1 comments

I have the following file:

*********************
Architecture overview
*********************

Class Diagram
#############

.. mermaid::

    classDiagram

    class Device {
        +str name
        +info Tuple[int, int, int]
        +rdescs List[List[int]]
        +report_rate int
        +endpoints List[Endpoint]
        +actuators List[Actuator]
        +hw Dict[str, HWComponent]
        +fw Firmware

        +destroy()
        +transform_action(action) %% Passes the action by the actuators and returns the transformed result ()
        +send_hid_action(action) %% Sends HID action to all endpoints (create_report -> call_input_event)
        +simulate_action(action) %% Transforms high-level action into HID timed events and sends them ()
    }

    class UHIDDevice

    UHIDDevice --|> Endpoint : inherits
    class Endpoint {
        -_owner Device
        -_hid_properties List[HIDProperty]
        +rdesc List[int]
        +name str
        +number int
        +uhid_dev_is_ready bool

        -_update_hid_properties() %% Parses the report descriptor and populates _hid_properties ()
        -_receive(data, size, rtype) %% HID data receive callback (triggers the firmware callback)
        +send(data) %% Sends HID data ()
        +create_report(action, skip_empty) %% Creates a report based on the HID data ()
        +populate_hid_data(action, packets) %% Uses the _hid_properties to populate HID events ()
    }
    Device --> Endpoint : owns

    class Firmware {
        -_owner Device

        +hid_receive(data, size, rtype, endpoint)
        +hid_send(data, endpoint)
    }
    Device --> Firmware : owns

    class Actuator {
        -keys List[str]

        +transforms(action) %% Transform a high-level action ()
    }
    Device --o Actuator : uses (actuators)

    class HWComponent
    Device --o HWComponent : uses (hw)

    class HIDProperty {
        -keys List[str]

        +populate(action) %% Transform a high-level action ()
    }
    Endpoint --o HIDProperty : uses (_hid_properties)


`simulate_action()` Sequence Diagram
####################################

.. mermaid::

    sequenceDiagram

    participant API User
    participant Device
    participant Actuator
    participant Endpoint
    participant HIDProperty

    API User->>Device: simulate_action(action)

    Device->>+Device: hid_action = transform_action(action)
    loop actuators
        Device-->>Actuator: transform(data)
    end
    Device-->>-Device: 

    Device->>+Endpoint: populate_hid_data(hid_action, packets)
    loop HID properties
        Endpoint-->>HIDProperty: populate(hid_action, packets)
    end
    Endpoint-->>-Device: 

    loop packets
        Device->>Endpoint: send(create_report(packet))
    end

    Device-->>API User: 

Here's what is being generated: https://pkgbuild.com/~ffy00/documentation/ratbag-emu-sphix-demo/design.html

FFY00 avatar Mar 25 '20 17:03 FFY00

Hello @FFY00 I had the same problem with class diagrams not rendering class members, it works for me with the alternate syntax though:

Actuator : -keys List[str]
Actuator : +transforms(action) %% Transform a high-level action ()
Device --o Actuator

instead of:

class Actuator {
    -keys List[str]

    +transforms(action) %% Transform a high-level action ()
}
Device --o Actuator : uses (actuators)

monsieurTut avatar Oct 15 '20 08:10 monsieurTut