www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Graph rendering on dlang.org

reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.com> writes:
Currently we have a nice table at 
https://dlang.org/spec/const3.html#implicit_conversions documenting how 
implicit conversions work across qualifiers. While complete and 
informative, it doesn't quickly give an intuition.

A DAG like the sketch at http://imgur.com/a/VuxLT would be easy to 
follow - all paths are possible conversions.

What would be a nice tool to render this DAG online? Who'd want to work 
on inserting this? Ideally it would be some vector rendering.


Thanks,

Andrei
Jun 30
next sibling parent reply Brian Schott <briancschott gmail.com> writes:
On Friday, 30 June 2017 at 21:40:05 UTC, Andrei Alexandrescu 
wrote:
 What would be a nice tool to render this DAG online? Who'd want 
 to work on inserting this? Ideally it would be some vector 
 rendering.
Graphviz's "dot" tool can output svg. digraph "conversions" { "mutable" -> "const"; "inout const" -> "const"; "inout" -> "inout const"; "immutable" -> "inout const"; "immutable" -> "inout shared const"; "inout shared" -> "inout shared const"; "shared" -> "shared const"; "inout shared const" -> "shared const"; } dot -Tsvg conversions.dot > conversions.svg
Jun 30
next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 06/30/2017 05:52 PM, Brian Schott wrote:
 On Friday, 30 June 2017 at 21:40:05 UTC, Andrei Alexandrescu wrote:
 What would be a nice tool to render this DAG online? Who'd want to 
 work on inserting this? Ideally it would be some vector rendering.
Graphviz's "dot" tool can output svg. digraph "conversions" { "mutable" -> "const"; "inout const" -> "const"; "inout" -> "inout const"; "immutable" -> "inout const"; "immutable" -> "inout shared const"; "inout shared" -> "inout shared const"; "shared" -> "shared const"; "inout shared const" -> "shared const"; } dot -Tsvg conversions.dot > conversions.svg
Whoa, pretty nice: http://erdani.com/conversions.svg. How do I place the whole thing upside down? Thanks! -- Andrei
Jun 30
next sibling parent Brian Schott <briancschott gmail.com> writes:
On Friday, 30 June 2017 at 21:55:34 UTC, Andrei Alexandrescu 
wrote:
 Whoa, pretty nice: http://erdani.com/conversions.svg. How do I 
 place the whole thing upside down? Thanks! -- Andrei
digraph "conversion" { rankdir="BT"; ... }
Jun 30
prev sibling parent "H. S. Teoh via Digitalmars-d" <digitalmars-d puremagic.com> writes:
On Fri, Jun 30, 2017 at 05:55:34PM -0400, Andrei Alexandrescu via Digitalmars-d
wrote:
 On 06/30/2017 05:52 PM, Brian Schott wrote:
 On Friday, 30 June 2017 at 21:40:05 UTC, Andrei Alexandrescu wrote:
 What would be a nice tool to render this DAG online? Who'd want to
 work on inserting this? Ideally it would be some vector rendering.
Graphviz's "dot" tool can output svg. digraph "conversions" { "mutable" -> "const"; "inout const" -> "const"; "inout" -> "inout const"; "immutable" -> "inout const"; "immutable" -> "inout shared const"; "inout shared" -> "inout shared const"; "shared" -> "shared const"; "inout shared const" -> "shared const"; } dot -Tsvg conversions.dot > conversions.svg
Whoa, pretty nice: http://erdani.com/conversions.svg. How do I place the whole thing upside down? Thanks! -- Andrei
Like this: digraph { edge[dir="back"]; const; const -> mutable; const -> "inout const"; const -> inout; "inout const" -> immutable; "inout shared const" -> immutable; "inout shared const" -> "inout shared"; "shared const" -> "inout shared const"; "shared const" -> shared; } T -- Freedom: (n.) Man's self-given right to be enslaved by his own depravity.
Jun 30
prev sibling parent reply Patrick Schluter <Patrick.Schluter bbox.fr> writes:
On Friday, 30 June 2017 at 21:52:10 UTC, Brian Schott wrote:
 On Friday, 30 June 2017 at 21:40:05 UTC, Andrei Alexandrescu 
 wrote:
 What would be a nice tool to render this DAG online? Who'd 
 want to work on inserting this? Ideally it would be some 
 vector rendering.
Graphviz's "dot" tool can output svg. digraph "conversions" { "mutable" -> "const"; "inout const" -> "const"; "inout" -> "inout const"; "immutable" -> "inout const"; "immutable" -> "inout shared const"; "inout shared" -> "inout shared const"; "shared" -> "shared const"; "inout shared const" -> "shared const"; } dot -Tsvg conversions.dot > conversions.svg
That's what doxygen uses to generate call graphs, callee graphs, include hierarchies and other stuff. The dot language can also be embedded directly in the comments. It would be nice if the D document generator also used it.
Jul 01
parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 07/01/2017 03:56 AM, Patrick Schluter wrote:
 On Friday, 30 June 2017 at 21:52:10 UTC, Brian Schott wrote:
 On Friday, 30 June 2017 at 21:40:05 UTC, Andrei Alexandrescu wrote:
 What would be a nice tool to render this DAG online? Who'd want to 
 work on inserting this? Ideally it would be some vector rendering.
Graphviz's "dot" tool can output svg. digraph "conversions" { "mutable" -> "const"; "inout const" -> "const"; "inout" -> "inout const"; "immutable" -> "inout const"; "immutable" -> "inout shared const"; "inout shared" -> "inout shared const"; "shared" -> "shared const"; "inout shared const" -> "shared const"; } dot -Tsvg conversions.dot > conversions.svg
That's what doxygen uses to generate call graphs, callee graphs, include hierarchies and other stuff. The dot language can also be embedded directly in the comments. It would be nice if the D document generator also used it.
That's a cool idea. (Do it!) At least at a point someone generated the global import graph for phobos. It would be great to have that available permanently so we know how to improve it. -- Andrei
Jul 01
prev sibling next sibling parent reply Jonathan Marler <johnnymarler gmail.com> writes:
On Friday, 30 June 2017 at 21:40:05 UTC, Andrei Alexandrescu 
wrote:
 Currently we have a nice table at 
 https://dlang.org/spec/const3.html#implicit_conversions 
 documenting how implicit conversions work across qualifiers. 
 While complete and informative, it doesn't quickly give an 
 intuition.

 A DAG like the sketch at http://imgur.com/a/VuxLT would be easy 
 to follow - all paths are possible conversions.

 What would be a nice tool to render this DAG online? Who'd want 
 to work on inserting this? Ideally it would be some vector 
 rendering.


 Thanks,

 Andrei
There's also mermaid. They have a live editor here: https://knsv.github.io/mermaid/live_editor/ You can view the diagram here: https://knsv.github.io/mermaid/live_editor/#/view/Z3JhcGggQlQKCiUlIERlY2xhcmUgTm9kZXMgV2l0aCBTcGFjZXMgaW4gdGhlaXIgTmFtZQppbm91dF9jb25zdFtpbm91dCBjb25zdF0Kc2hhcmVkX2NvbnN0W3NoYXJlZCBjb25zdF0KaW5vdXRfc2hhcmVkX2NvbnN0W2lub3V0IHNoYXJlZCBjb25zdF0KaW5vdXRfc2hhcmVkW2lub3V0IHNoYXJlZF0KCiUlIExlZnQgaGFuZCBzaWRlIG9mIGdyYXBoCm11dGFibGUgLS0-IGNvbnN0Cmlub3V0X2NvbnN0IC0tPiBjb25zdAppbm91dCAtLT4gaW5vdXRfY29uc3QKaW1tdXRhYmxlIC0tPiBpbm91dF9jb25zdAoKJSUgUmlnaHQgaGFuZCBzaWRlIG9mIGdyYXBoCmltbXV0YWJsZSAtLT4gaW5vdXRfc2hhcmVkX2NvbnN0Cmlub3V0X3NoYXJlZCAtLT4gaW5vdXRfc2hhcmVkX2NvbnN0CnNoYXJlZCAtLT4gc2hhcmVkX2NvbnN0Cmlub3V0X3NoYXJlZF9jb25zdCAtLT4gc2hhcmVkX2NvbnN0 The syntax to create the given graph would be: graph BT %% Declare Nodes With Spaces in their Name inout_const[inout const] shared_const[shared const] inout_shared_const[inout shared const] inout_shared[inout shared] %% Left hand side of graph mutable --> const inout_const --> const inout --> inout_const immutable --> inout_const %% Right hand side of graph immutable --> inout_shared_const inout_shared --> inout_shared_const shared --> shared_const inout_shared_const --> shared_const
Jul 01
parent reply Cym13 <cpicard openmailbox.org> writes:
On Saturday, 1 July 2017 at 19:19:09 UTC, Jonathan Marler wrote:
 On Friday, 30 June 2017 at 21:40:05 UTC, Andrei Alexandrescu 
 wrote:
 [...]
There's also mermaid. They have a live editor here: https://knsv.github.io/mermaid/live_editor/ [...]
Graphviz looks nicer both as diagram and markup honnestly; the separation in two halves make it harder to read for me compared to the more direct approach of graphviz.
Jul 01
next sibling parent reply Jonathan Marler <johnnymarler gmail.com> writes:
On Saturday, 1 July 2017 at 20:53:07 UTC, Cym13 wrote:
 On Saturday, 1 July 2017 at 19:19:09 UTC, Jonathan Marler wrote:
 On Friday, 30 June 2017 at 21:40:05 UTC, Andrei Alexandrescu 
 wrote:
 [...]
There's also mermaid. They have a live editor here: https://knsv.github.io/mermaid/live_editor/ [...]
Graphviz looks nicer both as diagram and markup honnestly; the separation in two halves make it harder to read for me compared to the more direct approach of graphviz.
I'm not an expert, but from what I've read mermaid has some nice tools that make it easy to integrate into websites such as styling via CSS and javascript libraries that convert mermaid to SVG. This allows graphics to be generated on the client side (kinda cool). Since the graphs are styled via CSS a website could make sure all their graphs are styled consistently, and the style can be changed without having to regenerate the graphic. I've used both GraphViz and Mermaid a little, I opted to use mermaid recently because of the live editor, didn't have to download any tools and saw my results right away which was very convenient. I've also used GraphViz which was nice but had it's own quirks. I'm also not sure if GraphViz supports sequence diagrams, that might be why I found mermaid in the first place. Not sure which one is better, would be good to get an opinion from someone who was a good amount of experience with both. I'm not sure what you meant in your comment by "the separation in two halves make it harder to read"....I've rewritten the same graph so it looks more like the GraphViz version: graph BT mutable --> const inout_const[inout const] --> const inout --> inout_const immutable --> inout_const immutable --> inout_shared_const[inout shared const] inout_shared[inout shared] --> inout_shared_const shared --> shared_const[shared const] inout_shared_const --> shared_const
Jul 01
parent Cym13 <cpicard openmailbox.org> writes:
On Saturday, 1 July 2017 at 22:09:49 UTC, Jonathan Marler wrote:
 I'm not sure what you meant in your comment by "the separation 
 in two halves make it harder to read"....I've rewritten the 
 same graph so it looks more like the GraphViz version:

 graph BT
   mutable --> const
   inout_const[inout const] --> const
   inout --> inout_const
   immutable --> inout_const
   immutable --> inout_shared_const[inout shared const]
   inout_shared[inout shared] --> inout_shared_const
   shared --> shared_const[shared const]
   inout_shared_const --> shared_const
That does look way nicer, thanks!
Jul 01
prev sibling parent Mark <smarksc gmail.com> writes:
On Saturday, 1 July 2017 at 20:53:07 UTC, Cym13 wrote:
 On Saturday, 1 July 2017 at 19:19:09 UTC, Jonathan Marler wrote:
 On Friday, 30 June 2017 at 21:40:05 UTC, Andrei Alexandrescu 
 wrote:
 [...]
There's also mermaid. They have a live editor here: https://knsv.github.io/mermaid/live_editor/ [...]
Graphviz looks nicer both as diagram and markup honnestly; the separation in two halves make it harder to read for me compared to the more direct approach of graphviz.
My experience with GraphViz is that it's okay for simple, small diagrams but when I want to make something more complex it can be incredibly frustrating to make the digram look the way you want. I didn't try Mermaid or any other visualization tools, though.
Jul 02
prev sibling parent Mario =?UTF-8?B?S3LDtnBsaW4=?= <linkrope github.com> writes:
Try http://plantuml.com/ (based on dot). Paste

 startuml
hide circle
hide empty attributes
hide empty methods

class "mutable"
class "const"
class "inout"
class "inout const"
class "immutable"
class "shared"
class "shared const"
class "inout shared const"

"mutable" -up-> "const"
"inout const" -up-> "const"
"inout" -up-> "inout const"
"immutable" -up-> "inout const"
"immutable" -up-> "inout shared const"
"inout shared" -up-> "inout shared const"
"shared" -up-> "shared const"
"inout shared const" -up-> "shared const"
 enduml

http://www.plantuml.com/plantuml/svg/bOyz2i0W38LtJn7SUuNUnMf0GMinSUZjIuTA4wJGpVV3yqjC0S6dvZEQUB-n77o2OsvfwupqTWjoh86CyTaHWIsTtPRHFjhNdNYejDUk5AX6qGiKNSEW94nsGKPciC3IZsKTBEBVQJPSGVXY-vTBBc5-DrNdOqTT8ymB
Jul 01