Skip to content

Commit

Permalink
Adds more docs re: custom elements and views.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbrowndotje committed Oct 6, 2024
1 parent 66ed3a0 commit 95efb79
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 3 deletions.
9 changes: 7 additions & 2 deletions dsl/14-language.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ The interval is a number of seconds (default 60s), and the timeout is a number o

## element

The `element` keyword defines a [custom element](https://structurizr.com/help/custom-elements) (this is only available on the Structurizr cloud service/on-premises installation/Lite).
The `element` keyword defines a custom element that sits outside of the C4 model.

```
element <name> [metadata] [description] [tags] {
Expand All @@ -371,6 +371,8 @@ The following tags are added by default:

- `Element`

See [DSL cookbook - Custom elements](/dsl/cookbook/custom-elements) for an example.

Permitted children:

- [description](#description)
Expand Down Expand Up @@ -846,14 +848,17 @@ Permitted children:

## custom view

The `custom` keyword is used to define a [custom view](/ui/diagrams/custom-view) (this is only available on the Structurizr cloud service/on-premises installation/Lite).
The `custom` keyword is used to define a [custom view](/ui/diagrams/custom-view).
Only [custom elements](#element) are permitted to be included on a custom view.

```
custom [key] [title] [description] {
...
}
```

See [DSL cookbook - Custom view](/dsl/cookbook/custom-view) for an example.

Permitted children:

- [include](#include)
Expand Down
17 changes: 17 additions & 0 deletions dsl/cookbook/custom-elements/example-1.dsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
workspace {

model {
a = softwareSystem "A"
b = element "B" "Hardware System"

a -> b "Sends control signals to"
}

views {
systemContext a "Diagram1" {
include *
autoLayout lr
}
}

}
Binary file added dsl/cookbook/custom-elements/example-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions dsl/cookbook/custom-elements/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
layout: default
title: Custom elements
parent: Cookbook
grand_parent: Structurizr DSL
permalink: /dsl/cookbook/custom-elements/
---

# Custom elements

The DSL [element](/dsl/language#element) keyword can be used to define elements that sit outside of the C4 model.
For example, perhaps a software system named A controls a hardware system named B.

```
workspace {
model {
a = softwareSystem "A"
b = element "B" "Hardware System"
a -> b "Sends control signals to"
}
views {
systemContext a "Diagram1" {
include *
autoLayout lr
}
}
}
```

[![](example-1.png)](http://structurizr.com/dsl?src=https://docs.structurizr.com/dsl/cookbook/custom-elements/example-1.dsl)

## Links

- [DSL language reference - element](/dsl/language#element)
18 changes: 18 additions & 0 deletions dsl/cookbook/custom-view/example-1.dsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
workspace {

model {
a = element "A" "Type A" "A description of A."
b = element "B" "Type B" "A description of B."

a -> b "Depends upon"
}

views {
custom "Diagram1" {
title "A custom view"
include *
autoLayout lr
}
}

}
Binary file added dsl/cookbook/custom-view/example-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions dsl/cookbook/custom-view/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
layout: default
title: Custom view
parent: Cookbook
grand_parent: Structurizr DSL
permalink: /dsl/cookbook/custom-view/
---

# Custom view

A [custom view](/ui/diagrams/custom-view) provides a way to create ad hoc diagrams, based upon the
same model+view approach and rendering engine.

```
workspace {
model {
a = element "A" "Type A" "A description of A."
b = element "B" "Type B" "A description of B."
a -> b "Depends upon"
}
views {
custom "Diagram1" {
title "A custom view"
include *
autoLayout lr
}
}
}
```

This DSL defines a custom view showing a couple of custom elements.

[![](example-1.png)](http://structurizr.com/dsl?src=https://docs.structurizr.com/dsl/cookbook/custom-view/example-1.dsl)

## Links

- [DSL language reference - element](/dsl/language#element)
- [DSL language reference - custom](/dsl/language#custom-view)
7 changes: 6 additions & 1 deletion ui/diagrams/custom-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ included on your diagram key/legend. Custom elements can also be used on custom

![System context diagram with additional custom elements](images/custom-view-1.png)

![Diagram key/legend for system context diagram with additional custom elements](images/custom-view-2.png)
![Diagram key/legend for system context diagram with additional custom elements](images/custom-view-2.png)

## Links

- [DSL cookbook - Custom elements](/dsl/cookbook/custom-elements)
- [DSL cookbook - Custom view](/dsl/cookbook/custom-view)

0 comments on commit 95efb79

Please sign in to comment.