JacquesCarette / Drasil

Generate all the things (focusing on research software)
https://jacquescarette.github.io/Drasil
BSD 2-Clause "Simplified" License
136 stars 25 forks source link

Mermaid-based Chunk Diagram #3822

Open NoahCardoso opened 6 days ago

NoahCardoso commented 6 days ago

This is the Chunk diagram (https://app.diagrams.net/#G1kwox9THKnfZaWZgU9xsBMZOj9skH8I5p#%7B%22pageId%22%3A%221i8NugCu6lIxckssFHEs%22%7D) in mermaid


classDiagram

Hollow arrow means instance of 

class IdeaDict {
    UID
    NP
    Maybe String
}
IdeaDict <|-- "IdeaDict" QuantityDict
IdeaDict <|-- "IdeaDict" ConceptChunk

class QuantityDict{
    typ :: Space 
    symb :: Symbol
    unit :: UnitDefn
}
QuantityDict <|-- "QuantityDict" UnitaryChunk
QuantityDict <|-- "QuantityDict" CodeChunk
QuantityDict <|-- "QuantityDict" NamedArgument
QuantityDict <|-- "QuantityDict" ConstrainedChunk
QuantityDict <|-- "QuantityDict" MultiDefn e

class ConceptChunk{
    defn :: Sentence
    cdom :: [UID]
}
ConceptChunk <|-- "ConceptChunk" ConstraintSet e
ConceptChunk <|-- "ConceptChunk" RelationConcept
ConceptChunk <|-- "ConceptChunk" DefinedQuantityDict
ConceptChunk <|-- "ConceptChunk" ConceptInstance
ConceptChunk <|-- "ConceptChunk" UnitDefn
ConceptChunk <|-- "ConceptChunk" DifferentialModel

class UnitaryChunk {
    unitdefn :: UnitDefn
}

class CodeChunk {
    kind :: VarOrFunc
}
CodeChunk <|-- "CodeChunk" CodeDefinition
CodeChunk <|-- "CodeChunk" CodeVarChunk
CodeChunk <|-- "CodeChunk" CodeIdea
CodeChunk <|-- "CodeChunk" ParameterChunk

class NamedArgument

class ConstrainedChunk {
    constr :: [ConstraintE]
    reasV :: Maybe Expr
}
ConstrainedChunk <|-- "ConstrainedChunk" UncertainChunk

class MultiDefn e {
    rUid :: UID
    rDesc :: Sentence
    rvs :: NonEmpty (DefiningExpr e)
}

class ConstraintSet e {
    exp :: e
}

class RelationConcept {
    relation :: ModelExpr
}

class DefinedQuantityDict {
    symb :: Symbol
    spa :: Space
    unit :: Mabye UnitDefn
}
DefinedQuantityDict <|-- "DefinedQuantityDict" QDefinition e
DefinedQuantityDict <|-- "DefinedQuantityDict" ConstrConcept
DefinedQuantityDict <|-- "DefinedQuantityDict" UnitalChunk

class ConceptInstance {
    ra :: String
    shnm :: ShortName
}

class UnitDefn {
    cas :: UnitSymbol
    cu :: [UID]
}

class DifferentialModel {
    depVar :: ConstrConcept
    indepVar :: UnitalChunk
    coefficients :: [[Expr]]
    unknowns :: [Unknown]
    constant :: [Expr]
}

class QDefinition e {
    QDef Expression :: e
    cdom :: [UID]
}
QDefinition e <|-- "QDefinition" DataDefinition 

class ConstrConcept {
    constr :: [ConstraintE]
    reasV :: Maybe Expr
}
ConstrConcept <|-- "ConstrConcept" UncertQ 

class UnitalChunk {
    unitdef :: UnitDefn
}

class CodeDefinition {
    defn :: CodeExpr
    auxExprs :: [CodeExpr]
    defType  :: DefinitionType
}

class CodeVarChunk {
    obv :: Maybe CodeChunk
}

class CodeIdea {
    codeName :: String
    codeExpr :: CodeExpr
}

class ParameterChunk {
    passBy :: PassBy
}

class UncertainChunk {
    unc :: Uncertainty
}

class DataDefinition {
    pktST :: ScopeType
    pktDR :: [DecRef]
    pktMD :: Maybe Derivation
    pktSN :: ShortName
    pktS  :: String
    pktSS :: [Sentence]
}

class UncertQ {
    unc :: Uncertainty
}

class Reference {
    ui :: UID
    ra :: LblType
    sn :: ShortName
}
Reference <|-- "Reference" LabelledContent
Reference <|-- "Reference" Section

class LabelledContent {
    ctype :: RawContent
}

class Section {
    tle  :: Title
    cons :: [SecCons]
}

class Choices {
    lang :: [Lang]
    architecture :: Architecture
    dataInfo :: DataInfo
    maps :: Maps
    optFeats :: OptionalFeatures
    srsConstraints :: Constraints
    extLibs :: [ExtLib]
    icNames :: InternalConcept -> Name
    folderVal :: Int
}
Choices <|-- "Choices" Lang
Choices <|-- "Choices" Architecture
Choices <|-- "Choices" DataInfo
Choices <|-- "Choices" Maps
Choices <|-- "Choices" OptionalFeatures
Choices <|-- "Choices" Constraints

class Lang {
    Cpp | CSharp | Java | Python | Swift
}

class Architecture {
    modularity :: Modularity
    impType :: ImplementationType
}

class DataInfo {
    inputStructure :: Structure
    constStructure :: ConstantStructure
    constRepr :: ConstantRepr
}

class Maps {
    conceptMatch :: ConceptMatchMap
    spaceMatch :: SpaceMatch
}

class OptionalFeatures {
    docConfig :: DocConfig
    logConfig :: LogConfig
    auxFiles :: [AuxFile]
}

class Constraints {
    onSfwrConstraint :: ConstraintBehaviour
    onPhysConstraint :: ConstraintBehaviour
}

Theory
style ConstraintSete fill:#7030A0,stroke:#333,stroke-width:4px
style DataDefinition fill:#7030A0,stroke:#333,stroke-width:4px
style MultiDefne fill:#7030A0,stroke:#333,stroke-width:4px
style MultiDefn e fill:#7030A0,stroke:#333,stroke-width:4px

Code
style NamedArgument fill:#00B050,stroke:#333,stroke-width:4px
style CodeDefinition fill:#00B050,stroke:#333,stroke-width:4px
style ParameterChunk fill:#00B050,stroke:#333,stroke-width:4px
style Choices fill:#00B050,stroke:#333,stroke-width:4px
style Lang fill:#00B050,stroke:#333,stroke-width:4px
style Architecture fill:#00B050,stroke:#333,stroke-width:4px
style DataInfo fill:#00B050,stroke:#333,stroke-width:4px
style Maps fill:#00B050,stroke:#333,stroke-width:4px
style OptionalFeatures fill:#00B050,stroke:#333,stroke-width:4px
style Constraints fill:#00B050,stroke:#333,stroke-width:4px
balacij commented 6 days ago

This looks great! Thank you, @NoahCardoso.

@smiths, @NoahCardoso and I discussed this very briefly in person today. @NoahCardoso found two main issues (but he can further clarify if needed):

  1. the diagrams producible with Mermaid are just a bit too rigidly to the UML spec. (we need easier colouring, nodes without function boxes, more custom arrows, notes arbitrarily placed, and a legend),
  2. the interactivity of Mermaid diagrams is a bit problematic at our size due to awkward diagram navigation. Specifically, it only allows navigation through some awkwardly placed buttons on the bottom-right-side of the screen which don't have any key binds, there are no key shortcuts, and there is no mouse interactivity (i.e., Pan & Zoom, which looks to only be enabled for the reference editor), so we're left rather slow and frustrating navigation. The diagram in the PR only contains select chunks from a few of our packages (-lang, -code, and -theory) and navigating the diagram has become cumbersome.

That being said, the final product looks very visually pleasing! I definitely think that we should try to generate these later on. However, I'm a bit skeptical that we can use these to demo the chunk hierarchy effectively right now. We might be able to get away with splitting up the diagram into a few files, but I'm not sure. Do you have any thoughts on this?

In all honesty, the Pan & Zoom feature is the only 'real' problem -- we can get around everything else.

smiths commented 6 days ago

Thank you @balacij and @NoahCardoso. That is great that you tried mermaid. Sounds like it is a great fit for visualization in our issues, but it isn't the best fit for a large complex UML-like diagram. I don't think we should use mermaid for our chunk graph. Navigation is the important part and it is awkward with mermaid.

Some of the undergrads use plantuml. Is that an option for drawing our more complex diagrams?