bavovanachte / sphinx-wavedrom

A sphinx extension that allows including wavedrom diagrams by using its text-based representation
MIT License
34 stars 18 forks source link

WIP: Wavedrom cli integration #26

Closed bavovanachte closed 4 years ago

bavovanachte commented 4 years ago

PR for issue #23 . So far it seems to roughly work for html and pdf builds, but the conversion between svg and pdf looks messed up. Need to investigate that further.

TODO:

As this change effectively makes wavedrom-cli the default image renderer over wavedrompy, this could break existing builds. It will be released with a major version bump

bavovanachte commented 4 years ago

Investigate pdf conversion issues with cairosvg

I've done some checking and I've tried with different tools (svglib, cairosvg and inkscape). Overall, the rendering is ok, issues start to arise when more complex svg styling is applied, like in the json below:

{"signal": [
        {"name":"clk", "wave": "p.....PPPPp...." },
        {"name":"dat", "wave": "x....2345x.....", "data": "a b c d" },
        {"name":"req", "wave": "0....1...0....." }
],
"head": {"text":
        ["tspan",
                ["tspan", {"class":"error h1"}, "error "],
                ["tspan", {"class":"warning h2"}, "warning "],
                ["tspan", {"class":"info h3"}, "info "],
                ["tspan", {"class":"success h4"}, "success "],
                ["tspan", {"class":"muted h5"}, "muted "],
                ["tspan", {"class":"h6"}, "h6 "],
                "default ",
                ["tspan", {"fill":"pink", "font-weight":"bold", "font-style":"italic"}, "pink-bold-italic"]
        ]
},
"foot": {"text":
        ["tspan", "E=mc",
                ["tspan", {"dy":"-5"}, "2"],
                ["tspan", {"dy": "5"}, ". "],
                ["tspan", {"font-size":"25"}, "B "],
                ["tspan", {"text-decoration":"overline"},"over "],
                ["tspan", {"text-decoration":"underline"},"under "],
                ["tspan", {"baseline-shift":"sub"}, "sub "],
                ["tspan", {"baseline-shift":"super"}, "super "]
        ],"tock":-5
}
}

For now, I'm going to stick with cairosvg. I really want to avoid adding inkscape as a dependency (I think @wallento had the same idea), and I doubt the lack of fancy formatting is a real issue. I'm not 100% sure the fault is with cairosvg either (don't know enough about svg to judge). If someone really needs it, I could add an "inkscape rendering mode" later on

bavovanachte commented 4 years ago

Added tests for wavedrompy and wavedrom-cli pdf builds separately.

bavovanachte commented 4 years ago

I will merge this and push a 3.0.0 alfa release to facilitate testing.