Giter VIP home page Giter VIP logo

mdoc-d2's Introduction

D2 diagrams in your Mdoc files

Mdoc is the tool for compiled documentation in Scala projects

D2 is a declarative diagram definition language

This project is a simple plugin for mdoc that allows you to embed D2 diagrams in your markdown files.

Installation

  • SBT: libraryDependencies += "com.indoorvivants" %% "mdoc-d2" % "0.0.1"
  • Mill: def ivyDeps = Agg(ivy"com.indoorvivants::mdoc-d2:0.0.1")
JVM
Scala 2.12
Scala 2.13
Scala 3

Usage

Note that Github intentionally doesn't render images which are specified using the data: source - it's done for security reasons, and as such you won't see the diagrams rendered on this page. Please refer to the website insteadh which hosts a copy of this documentation

You don't need to install D2, it will be bootstrapped by Yank.

Simple use the scala mdoc:d2 language in your markdown snippets and enjoy:

```scala mdoc:d2
direction:right
dogs -> cats -> mice: chase
replica 1 <-> replica 2
a -> b: To err is human, to moo bovine {
  source-arrowhead: 1
  target-arrowhead: * {
    shape: diamond
  }
}
```

will be rendered as an image:

You can also pass the parameters directly to D2 CLI tool, by using the special #! comments. For example, here we set layout to ELK and theme to 100:

```scala mdoc:d2
#!layout=elk
#!theme=100
direction:right
dogs -> cats -> mice: chase
replica 1 <-> replica 2
a -> b: To err is human, to moo bovine {
  source-arrowhead: 1
  target-arrowhead: * {
    shape: diamond
  }
}
```

will be rendered as an image:

Contributing

If you want to update this documentation file, don't edit it directly - edit docs/README.in.md and run sbt updateDocs. It's annoying, but this document contains compiled snippets of code which I want to prevent from going out of date

mdoc-d2's People

Contributors

keynmol avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.