d2
This tool uses Dagger to render D2 diagrams within containerized environments.You can render a single D2 file or an entire directory of D2 files, specify the output
format (svg, png, pdf, pptx, gif), and pass extra arguments to the D2 command.
Example Usages:
dagger call --file=your-file.d2 render export --path=./out
dagger call --format='pdf' --file='your-file.d2' render export --path=./out
dagger call --format='gif' --file='your-file.d2' with-arg --arg='--animate-interval=100' render export --path=./out
For more details, refer to the README.md.
Installation
dagger install github.com/pjmagee/daggerverse/d2@686b0f41e55f3e32b2e43546f1adac33ac271eb1Entrypoint
Return Type
D2 !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| format | Enum | "svg" | No description provided |
| dir | Directory | - | No description provided |
| file | File | - | No description provided |
Example
dagger -m github.com/pjmagee/daggerverse/d2@686b0f41e55f3e32b2e43546f1adac33ac271eb1 call \
func (m *MyModule) Example() *dagger.D2 {
return dag.
D2()
}@function
def example() -> dagger.D2:
return (
dag.d2()
)@func()
example(): D2 {
return dag
.d2()
}Types
D2 🔗
args() 🔗
+private, extra arguments for d2 command
Return Type
[String ! ] ! Example
dagger -m github.com/pjmagee/daggerverse/d2@686b0f41e55f3e32b2e43546f1adac33ac271eb1 call \
argsfunc (m *MyModule) Example(ctx context.Context) []string {
return dag.
D2().
Args(ctx)
}@function
async def example() -> List[str]:
return await (
dag.d2()
.args()
)@func()
async example(): Promise<string[]> {
return dag
.d2()
.args()
}withArg() 🔗
Return Type
D2 !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| arg | String ! | - | No description provided |
Example
dagger -m github.com/pjmagee/daggerverse/d2@686b0f41e55f3e32b2e43546f1adac33ac271eb1 call \
with-arg --arg stringfunc (m *MyModule) Example(arg string) *dagger.D2 {
return dag.
D2().
WithArg(arg)
}@function
def example(arg: str) -> dagger.D2:
return (
dag.d2()
.with_arg(arg)
)@func()
example(arg: string): D2 {
return dag
.d2()
.withArg(arg)
}withFrmat() 🔗
Return Type
D2 !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| format | Enum ! | - | No description provided |
Example
dagger -m github.com/pjmagee/daggerverse/d2@686b0f41e55f3e32b2e43546f1adac33ac271eb1 call \
with-frmatfunc (m *MyModule) Example(format ) *dagger.D2 {
return dag.
D2().
WithFrmat(format)
}@function
def example(format: ) -> dagger.D2:
return (
dag.d2()
.with_frmat(format)
)@func()
example(format: ): D2 {
return dag
.d2()
.withFrmat(format)
}serve() 🔗
This doesn’t work, because the file is uploaded in the session and changes from the host machine are not sent +private
Return Type
Service !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| file | File ! | - | No description provided |
| port | Integer | 9000 | No description provided |
| host | String | "0.0.0.0" | No description provided |
Example
dagger -m github.com/pjmagee/daggerverse/d2@686b0f41e55f3e32b2e43546f1adac33ac271eb1 call \
serve --file file:pathfunc (m *MyModule) Example(file *dagger.File) *dagger.Service {
return dag.
D2().
Serve(file)
}@function
def example(file: dagger.File) -> dagger.Service:
return (
dag.d2()
.serve(file)
)@func()
example(file: File): Service {
return dag
.d2()
.serve(file)
}render() 🔗
renders the D2 file or directory to the given format format.
Return Type
Directory ! Example
dagger -m github.com/pjmagee/daggerverse/d2@686b0f41e55f3e32b2e43546f1adac33ac271eb1 call \
renderfunc (m *MyModule) Example() *dagger.Directory {
return dag.
D2().
Render()
}@function
def example() -> dagger.Directory:
return (
dag.d2()
.render()
)@func()
example(): Directory {
return dag
.d2()
.render()
}