Skip to content

Commit

Permalink
Merge pull request #57 from owulveryck/refacto
Browse files Browse the repository at this point in the history
Refacto
  • Loading branch information
owulveryck authored Oct 23, 2023
2 parents 94f7478 + 9639a0f commit 045ef30
Show file tree
Hide file tree
Showing 10 changed files with 1,423 additions and 95 deletions.
7 changes: 6 additions & 1 deletion examples/example/example1.cue
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,18 @@ sampleSystem: c4.#System & {
]
}

admin2: c4.#Person & {
id: "admin2"
label: "Administrator"
}

admin: c4.#Person & {
id: "admin"
label: "Administrator"
}

C1: c4.#C1 & {
Persons: [admin]
Persons: [admin2, admin]
Systems: [sampleSystem]
layout: "landscape"
relations: [
Expand Down
6 changes: 6 additions & 0 deletions examples/example/plantuml_tool.cue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ command: genpuml: {
text: template.Execute(c4.plantumlTemplate, C1)
}
}
command: genmermaid: {
c1: cli.Print & {
//text: template.Execute(_plantUMLC4Template.contents, C1)
text: template.Execute(c4.mermaidTemplate, C1)
}
}
//_plantUMLC4Template: file.Read & {
// filename: "plantuml_c4.tmpl"
// contents: string
Expand Down
1 change: 1 addition & 0 deletions examples/example/test.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
126 changes: 126 additions & 0 deletions examples/tags/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
This sample code:

```cue
package main
import (
"github.com/owulveryck/cue4puml4c4/technology/gcp"
"github.com/owulveryck/cue4puml4c4/technology/dev"
"github.com/owulveryck/cue4puml4c4/technology/stdlib"
"github.com/owulveryck/cue4puml4c4:c4"
)
// Tags
elementsTags: [ID=_]: c4.#ElementTag & {
id: "\(ID)"
}
relationsTags: [ID=_]: c4.#RelationTag & {
id: "\(ID)"
}
elementsTags: aSupprimer: {
legendText: "A Migrer en React"
bgColor: "#f0239c"
borderColor: "#ff0239c"
technology: dev.React
shadowing: true
shape: "eightsided"
}
relationsTags: myTest: {lineStyle: "bold"}
relationsTags: autreFleche: {lineColor: "#ff0000"}
// Containers
myWebApp: c4.#Container & {
id: "web_appp"
label: "Web Application"
description: "Allows users to compare multiple Twitter timelines"
technology: dev.CUE
tags: [elementsTags.aSupprimer]
}
myothercontainer: c4.#Container & {
id: "othercontainer"
label: "Cool2"
technology: stdlib.Kafka
}
othersample: c4.#Container & {
id: "sample2"
label: "Twitter2"
technology: gcp.Pubsub
link: "https://www.twitter.com"
}
twitter: c4.#System & {
id: "twitter"
label: "Twitter"
technology: gcp.Vertexai
link: "https://www.twitter.com"
}
sampleSystem: c4.#System & {
id: "c1"
label: "Sample System"
containers: [myWebApp, othersample, myothercontainer]
technology: gcp.CloudSql
systems: [twitter]
}
admin: c4.#Person & {
id: "admin"
label: "Administrator"
}
C1: c4.#C1 & {
elementTags: elementsTags
relationTags: relationsTags
Persons: [admin]
Systems: [sampleSystem]
Relations: [
{source: admin, dest: myWebApp, description: "Uses", protocol: "HTTPS ", tags: [relationsTags.myTest]},
{source: myWebApp, dest: twitter, description: "Get tweets from", protocol: "HTTPS ", link: "https://plantuml.com/link"},
]
}
```

Generates this plantuml file:

```plantuml
@startuml MyName
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
!include https://raw.githubusercontent.com/owulveryck/PlantUML-icons-GCP/master/official/GCPCommon.puml
!include https://raw.githubusercontent.com/owulveryck/cue4puml4c4/main/assets/cue.puml
!include https://raw.githubusercontent.com/owulveryck/PlantUML-icons-GCP/master/official/cloud_sql/cloud_sql.puml
!include https://raw.githubusercontent.com/owulveryck/PlantUML-icons-GCP/master/official/pubsub/pubsub.puml
!include https://raw.githubusercontent.com/owulveryck/PlantUML-icons-GCP/master/official/vertexai/vertexai.puml
!include https://raw.githubusercontent.com/plantuml-stdlib/gilbarbara-plantuml-sprites/master/sprites/./kafka.puml
/'Relation Tags'/
AddRelTag("autreFleche",$lineColor="#ff0000")
AddRelTag("myTest",$lineStyle=BoldLine())
/'Element Tags'/
AddElementTag("aSupprimer",$bgColor="#f0239c",$borderColor="#ff0239c",$shadowing="true",$shape="EightSidedShape()",$legendText="A Migrer en React",$techn="React",$sprite="react")
/' Persons '/
Person(admin,"Administrator")
/' Systems '/
System(c1,"Sample System","Google Cloud Sql","cloud_sql"){
Container(web_appp,"Web Application","CUE","Allows users to compare multiple Twitter timelines","cue_logo",$tags="aSupprimer+ ")
ContainerQueue(sample2,"Twitter2","Google Pubsub","","pubsub",$link="https://www.twitter.com")
Container(othercontainer,"Cool2","Kafka","","kafka")
System(twitter,"Twitter","Google Vertexai","vertexai",$link="https://www.twitter.com")
}
/' Relations '/
Rel("admin","web_appp","Uses","HTTPS ",$tags="myTest+ ")
Rel("web_appp","twitter","Get tweets from","HTTPS ",$link="https://plantuml.com/link")
SHOW_LEGEND()
@enduml
```

Which give this picture:

![](sample.svg)
94 changes: 94 additions & 0 deletions examples/tags/example1.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package main

import (
"github.com/owulveryck/cue4puml4c4/technology/gcp"
"github.com/owulveryck/cue4puml4c4/technology/aws"
"github.com/owulveryck/cue4puml4c4/technology/dev"
"github.com/owulveryck/cue4puml4c4/technology/stdlib"
"github.com/owulveryck/cue4puml4c4:c4"
)

aSupprimer: c4.#ElementTag & {
id: "aSupprimer"
legendText: "Rebuild in Rust"
bgColor: "#f0235c"
borderColor: "#ff0239c"
technology: dev.Rust
shadowing: true
shape: "eightsided"
}
myTest: c4.#RelationTag & {id: "myTest", lineStyle: "bold"}
autreFleche: c4.#RelationTag & {id: "autreFleche", lineColor: "#ff0000"}

// Containers

appEngine: c4.#System & {
id: "appEngine"
label: "App Engine"
technology: gcp.AppEngine
containers: [myWebApp]
}

myWebApp: c4.#Container & {
id: "web_appp"
label: "Web Application"
description: """
Allows users
to compare multiple Twitter timelines
"""
technology: dev.Go
tags: [aSupprimer]
}

mysample2: c4.#Container & {
id: "mysample2"
label: "mysample2"
description: "mysample2"
technology: aws.EC2
}
myothercontainer: c4.#Container & {
id: "othercontainer"
label: "Cool2"
technology: stdlib.Kafka
}

othersample: c4.#Container & {
id: "sample2"
label: "Event Source"
technology: gcp.Pubsub
link: "https://www.twitter.com"
}

twitter: c4.#System & {
id: "twitter"
label: "Twitter"
technology: gcp.ComputeEngine
link: "https://www.twitter.com"
containers: [{
id: "myDatabase"
technology: dev.Postgresql
label: "My Awesome DB"
}]
}

sampleSystem: c4.#System & {
id: "c1"
label: "Sample System"
isBoundary: true
containers: [myWebApp]
}

admin2: c4.#Person & {
id: "admin2"
label: "Administrator"
}

admin: c4.#Person & {
id: "admin"
label: "Administrator"
}

C1: c4.#C1 & {
Persons: [admin]
Systems: [sampleSystem]
}
25 changes: 25 additions & 0 deletions examples/tags/plantuml_tool.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
"tool/cli"
"text/template"
// "tool/file"
"github.com/owulveryck/cue4puml4c4:c4"
)

command: genpuml: {
c1: cli.Print & {
//text: template.Execute(_plantUMLC4Template.contents, C1)
text: template.Execute(c4.plantumlTemplate, C1)
}
}
command: genmermaid: {
c1: cli.Print & {
//text: template.Execute(_plantUMLC4Template.contents, C1)
text: template.Execute(c4.mermaidTemplate, C1)
}
}
//_plantUMLC4Template: file.Read & {
// filename: "plantuml_c4.tmpl"
// contents: string
//}
Loading

0 comments on commit 045ef30

Please sign in to comment.