Skip to main content

Blockdiag preprocessor for Foliant doc maker. Supports blockdiag, seqdiag, actdiag, and nwdiag.

Project description

# Blockdiag Preprocessor for Foliant

[Blockdiag](http://blockdiag.com/) is a tool to generate diagrams from plain text. This preprocessor finds diagram definitions in the source and converts them into images on the fly during project build. It supports all Blockdiag flavors: blockdiag, seqdiag, actdiag, and nwdiag.


## Installation

```shell
$ pip install foliantcontrib.blockdiag
```


## Config

To enable the preprocessor, add `blockdiag` to `preprocessors` section in the project config:

```yaml
preprocessors:
- blockdiag
```

The preprocessor has a number of options:

```yaml
preprocessors:
- blockdiag:
cache_dir: !path .diagramscache
blockdiag_path: blockdiag
seqdiag_path: seqdiag
actdiag_path: actdiag
nwdiag_path: nwdiag
params:
...
```

`cache_dir`
: Path to the directory with the generated diagrams. It can be a path relative to the project root or a global one; you can use `~/` shortcut.

> **Note**
>
> To save time during build, only new and modified diagrams are rendered. The generated images are cached and reused in future builds.

`*_path`
: Paths to the `blockdiag`, `seqdiag`, `actdiag`, and `nwdiag` binaries. By default, it is assumed that you have these commands in `PATH`, but if they're installed in a custom place, you can define it here.

`params`
: Params passed to the image generation commands (`blockdiag`, `seqdiag`, etc.). Params should be defined by their long names, with dashes replaced with underscores (e.g. `--no-transparency` becomes `no_transparency`); also, `-T` param is called `format` for readability:

preprocessors:
- blockdiag:
params:
antialias: true
font: !path Anonymous_pro.ttf

To see the full list of params, run `blockdiag -h`.


## Usage

To insert a diagram definition in your Markdown source, enclose it between `<<blockdiag>...</blockdiag>`, `<<seqdiag>...</seqdiag>`, `<actdiag>...</actdiag>`, or `<nwdiag>...</nwdiag>` tags (indentation inside tags is optional):

```markdown
Here's a block diagram:

<<blockdiag>
blockdiag {
A -> B -> C -> D;
A -> E -> F -> G;
}
</blockdiag>

Here's a sequence diagram:

<<seqdiag>
seqdiag {
browser -> webserver [label = "GET /index.html"];
browser <-- webserver;
browser -> webserver [label = "POST /blog/comment"];
webserver -> database [label = "INSERT comment"];
webserver <-- database;
browser <-- webserver;
}
</seqdiag>
```

To set a caption, use `caption` option:

```markdown
Diagram with a caption:

<<blockdiag caption="Sample diagram from the official site">
blockdiag {
A -> B -> C -> D;
A -> E -> F -> G;
}
</blockdiag>
```

You can override `params` values from the preprocessor config for each diagram:

```markdown
By default, diagrams are in png. But this diagram is in svg:

<<blockdiag caption="High-quality diagram" format="svg">
blockdiag {
A -> B -> C -> D;
A -> E -> F -> G;
}
</blockdiag>
```


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

foliantcontrib.blockdiag-1.0.2.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

foliantcontrib.blockdiag-1.0.2-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file foliantcontrib.blockdiag-1.0.2.tar.gz.

File metadata

File hashes

Hashes for foliantcontrib.blockdiag-1.0.2.tar.gz
Algorithm Hash digest
SHA256 131fdfdeafbd109bac30582cf10e4b6ba87d03c3afc455f31edaec242439ef4d
MD5 9e01840d8c4a3e724343a0dadba89454
BLAKE2b-256 202204885b5d5e2565c83dce3e7f7c3aaa05d85d3fdc42ea475fa804d3e73476

See more details on using hashes here.

File details

Details for the file foliantcontrib.blockdiag-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for foliantcontrib.blockdiag-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 087b23b8dd936c068006eac0a25ffb7a74a03bef4927749fd88696f56f75b193
MD5 700a49e951b964951e70dc18a22fdec1
BLAKE2b-256 986df9ef9861cb1239c471b6ed6f3633cc866ab68cecbcfe1c3fa75782582881

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page