atviriduomenys / spinta

Spinta is a framework to describe, extract and publish data (a DEP Framework).
MIT License
10 stars 4 forks source link

Generate mermaid class diagram #634

Closed sirex closed 1 day ago

sirex commented 3 weeks ago

Create a new Manifest, that can output model as mermaid diagram.

For example if we have following DSA table:

d | r | b | m | property    | type    | ref     | prepare
datasets/gov/rc/ar/ws       |         |         |
  |   |   | Administration  |         | id      |
  |   |   |   | id          | integer |         |
  |   |   |   | name        | string  |         |
  |   |   |   | type        | string  |         |
  |   |   |   |             | enum    |         | "country"
  |   |   |   |             |         |         | "municipality"
  |   |   |   |             |         |         | "eldership"

Command spinta copy dsa.csv -o dsa.mmd shoudl create a dsa.mmd file with following content:

classDiagram
  class Administration {
    + id: integer [1..1]
    + name: string [1..1]
  }

  class AdministrationType {
    <<enumeration>> 
    country
    municipality
  }

  Administration ..> "[1..1]" AdministrationType : type

Which can be imported to draw.io and should be displayed as:

classDiagram
  class Administration {
    + id: integer [1..1]
    + name: string [1..1]
  }

  class AdministrationType {
    <<enumeration>> 
    country
    municipality
  }

  Administration ..> "[1..1]" AdministrationType : type

Documentation for Mermaid class diagrams: https://mermaid.js.org/syntax/classDiagram.html

Other relationships are:

dependency - relationship between two models that have references (ref or backref) to each other. It's indicated by this type of arrow: -->

inheritance - relationship between a model and it's base model. It's indicated by this type of arrow: --|>

karina-klinkeviciute commented 1 week ago

Ar savybė type turi būti prie Administration ar neturi?

t.y. ar turi būti kaip viršuj parodyta, ar taip?

classDiagram
  class Administration {
    + id: integer [1..1]
    + name: string [1..1]
    + type: string [1..1]
  }

  class AdministrationType {
    <<enumeration>> 
    country
    municipality
  }

  Administration ..> "[1..1]" AdministrationType : type
sirex commented 1 week ago

Pagal UML, type nereikia pridėti prie klasės, jis turėtu būti prie asociacijos (rodyklės).

karina-klinkeviciute commented 1 week ago

bet mes tada "pametam" type tipą. Bet jei taip tinka, tai galiu taip padaryti.

sirex commented 6 days ago

bet mes tada "pametam" type tipą. Bet jei taip tinka, tai galiu taip padaryti.

Nepametam, type tipas yra ref, kuris rodo į modelį su rodykle.

karina-klinkeviciute commented 6 days ago

Bet type yra string: | | | | type | string | |

Aišku, gal šitoje situacijoje nėra būtina? O gal pridėti kažkur kitur?