Git Product home page Git Product logo

dooble's Introduction

dooble

image

image

Dooble is a marble diagram generator from text. It eases the documentation of ReactiveX standard and custom operators, in a consitent way.

Installation

pip install dooble

A sphinx plugin is also available:

pip install sphinxcontrib-dooble

Usage

The text grammar allows to easilly define observables and operators. The map operator with an input observable and an output observable is described the following way:

--1--2--3--4-->
[ map(i: i*2) ]
--2--4--6--8-->

save this text in a file named map.txt and then render it to an image:

dooble --input map.txt --output map.png

The generated image looks like this:

image

Higher order observables can also be documented easilly:

--a-b-c---d-e-f-->
[     window     ]
--+-------+------>
          +d-e-f-|
  +a-b-c-|

save this text in a file named window.txt and then render it to an image:

dooble --input window.txt --output window.png

The generated image looks like this:

image

For operators that take several observables as input, it is possible to label them:

--1--2--3--*
         a-7-8-|
[   catch(a)   ]
--1--2--3--7-8-|

save this text in a file named catch.txt and then render it to an image:

dooble --input catch.txt --output catch.png

The generated image looks like this:

image

Full grammar

  • Each text line represents either an observable, or an operator
  • Observables are defined with dash lines
  • If an Observable starts with a letter, this letter is considered as a label
  • Each character represent a time span
  • Character | indicates an observable completion
  • Character * indicates an observable error
  • Character > indicates an observable continutation
  • The + character is used to define anchors of higher order observables
  • operators start with a [ and end with a ]

The full grammar is the following one (in tatsu pseudo ebnf syntax):

@@grammar::dooble

start = { layer } $ ;

layer
=
| obs:observable
| op:operator
;

observable = {skipspan}* [prefix] {lifetime}* completion ;
operator = '[' description ']' ;

prefix = '+' | label ;

label = /[a-z]/ ;

lifetime
=
| ts:timespan
| item:item
;

completion = /[>|*]/ ;

skipspan = ' ' ;
timespan = '-' ;
item = /[a-zA-Z0-9+.,]+/ ;

description = /[a-zA-Z0-9,:+*() <>_]+/ ;

dooble's People

Contributors

dbrattli avatar erikkemperman avatar mainro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dooble's Issues

Operator description to restrictive

  • dooble version: 0.6.0
  • Python version: 3.7
  • Operating System: OS X

Description

This is a really great project. Trying to use Dooble with F# and the regexp for the description of the operator do not allow chars like -, {and }. But it would be nice to also have e.g /, $, =, % to support other programming languages and their ways of writing lambda expressions.

What I Did

    .. marble::
        :alt: map

        ---1---2---3---4--->
        [ map (fun i -> i*2) ]
        ---2---4---6---8--->

Traceback

Exception occurred:
  File "/usr/local/lib/python3.7/site-packages/tatsu/contexts.py", line 453, in _error
    raise self._make_exception(item, exclass=exclass)
tatsu.exceptions.FailedToken: (2:14) expecting ']' :
[ map (fun i -> i*2) ]
             ^

Some ideas

So I've been playing around with dooble for a while, really nice work!

I have some ideas, but would like to discuss a bit -- don't want to put too much effort into things that you might not like...

  • On MacOS the default matplotlib is interactive, I think it might be good to default to non-interactive backend.
  • Actually, it might be good to use different backends for different image formats -- I think it would be nice, for example, to use .svg images for the html documentation and .eps images for latex.
  • Can we set the minimum required matplotlib to version 3, since python2 is not supported by dooble anyway?
  • If a large number of marble diagrams are being rendered, things get kind of slow. I think it would be nice to implement a sort of "batch" or "async" mode, using multiple threads and/or processes.

Curious what you think!

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.