Git Product home page Git Product logo

reftree's People

Contributors

gitter-badger avatar hejfelix avatar malduarte avatar rajcspsg avatar sakshamsharma avatar sbrunk avatar stanch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

reftree's Issues

Unescaped special characters

While trying to print an AST of a program, I tried renaming a node to < for instance.

Reftree does not fail on that, but when it tries to render the resulting dotfile using dot, the error is thrown by dot. Oh, and no, it isn't a clear error.

Perhaps special characters needed by dot should be escaped somehow?

Vertical sequential list

Can we have an implicit for drawing a vertical sequential list?
Something like:

abcd
    |
efgh
    |
ijkl
    |
end

I was using something like this, but it crashes on some very simple inputs (flowName is a string)

  implicit def cfListDrawer: ToRefTree[List[CFEnum]] = ToRefTree[List[CFEnum]] {
    case x::xs => RefTree.Ref(x, Seq(xs.refTree)).rename(x.flowName)
    case Nil => RefTree.Ref("", Seq()).rename("End")
  }

Would be useful for vertical flow diagrams.

Rename doesn't work when composing multiple case classes

So I'm generating these two images from the code below:

"integer.png"
integer

"application_with_integer"
application_with_integer

In the first case, my integer case class is correctly renamed to bob. In the second case, no renaming happens.

implicit val tint: ToRefTree.DerivationConfig[Integer] =
  ToRefTree
    .DerivationConfig[Integer]
    .rename("bob")
    .omitField("i")

val renderer = Renderer(
  renderingOptions = RenderingOptions(density = 75),
  animationOptions = AnimationOptions(interpolationDuration = 3.seconds, framesPerSecond = 1),
  directory = Paths.get("images")
)
renderer.render("application_with_integer", Diagram(Application(Integer(42), Identifier("x"))))
renderer.render("integer", Diagram(Integer(42)))

I am not sure if I am using the API correctly, but I can see that the "i" field is omitted in both cases, i.e. some of the options must be picked up in both cases.

No 2.12 support

I was going to give it a spin, but no 2.12 support stopped me. 2.12 has been our for a long time, how come it's only released as 2.11?

NoClassDefFoundError fastparse.all$ when running in current Ammonite

$ coursier launch com.lihaoyi:ammonite_2.12.7:1.4.2 --main ammonite.Main

Loading...
Welcome to the Ammonite Repl 1.4.2
(Scala 2.12.7 Java 1.8.0_181)
If you like Ammonite, please support our development at www.patreon.com/lihaoyi
@ import $ivy.`io.github.stanch::reftree:1.2.1` 
import $ivy.$                                

@ import reftree.render.{Renderer, RenderingOptions} 
import reftree.render.{Renderer, RenderingOptions}

@ val renderer = Renderer(
    renderingOptions = RenderingOptions(density = 75),
  ) 
java.lang.NoClassDefFoundError: fastparse/all$
  reftree.geometry.Color$.<init>(Color.scala:100)
  reftree.geometry.Color$.<clinit>(Color.scala)
  reftree.render.RenderingOptions$.apply$default$2(Options.scala:19)
  ammonite.$sess.cmd2$.<init>(cmd2.sc:2)
  ammonite.$sess.cmd2$.<clinit>(cmd2.sc)
java.lang.ClassNotFoundException: fastparse.all$
  java.net.URLClassLoader.findClass(URLClassLoader.java:382)
  ammonite.runtime.SpecialClassLoader.findClass(ClassLoaders.scala:215)
  java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  reftree.geometry.Color$.<init>(Color.scala:100)
  reftree.geometry.Color$.<clinit>(Color.scala)
  reftree.render.RenderingOptions$.apply$default$2(Options.scala:19)
  ammonite.$sess.cmd2$.<init>(cmd2.sc:2)
  ammonite.$sess.cmd2$.<clinit>(cmd2.sc)

First guess: Ammonite depends on fastparse 2.0.5 (via scalaparse), so perhaps that's on the classpath instead of the older version required by reftree.

I cannot run demo

I am trying the project out but I cannot run sbt demo if always fails. Any ideas?

update dependency versions

update the below dependencies

  1. shapeless - 2.3.3
  2. sourcecode - 0.2.7
  3. fastparse - 2.3.0
  4. scribe - 2.7.9
  5. scala-xml - 1.2.0
  6. batik-transcoder - 1.14
  7. scrimage-core - 4.0.18
  8. fingertree - 1.5.5

Color.fromRgbaString does not accept uppercase Hex Chars

Color.fromRgbaString( "#F44336" )

yields the following error:

[error] (run-main-18) java.lang.ExceptionInInitializerError
java.lang.ExceptionInInitializerError
	at com.liefery.courier_android_app.reftree.Render.main(Render.scala)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
Caused by: fastparse.core.ParseError: found "#F44336", expected transparent | white | rgba at index 0
#F44336
^
	at fastparse.core.Parsed$class.get(Parsing.scala:32)
	at fastparse.core.Parsed$Failure.get(Parsing.scala:74)
	at reftree.geometry.Color$.fromRgbaString(Color.scala:95)
	at com.liefery.courier_android_app.reftree.Render$.<init>(Render.scala:18)
	at com.liefery.courier_android_app.reftree.Render$.<clinit>(Render.scala:12)
	at com.liefery.courier_android_app.reftree.Render.main(Render.scala)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)

Changing the color hex to lower case fixes the error.

The line which is causing this is val x = CharIn(('0' to '9') ++ ('a' to 'f')) here

How to add pointers to indices into array

I have the following image generated:
arraydeque

This is the code I am using:

implicit def `ArrayDeque RefTree`: ToRefTree[mutable.ArrayDeque[Char]] = ToRefTree {ds =>
    val array = ds.privateField[Array[AnyRef]]("array").map(c => Option(c).getOrElse('␀').asInstanceOf[Char])
    val start = ds.privateField[Int]("start")
    val end = ds.privateField[Int]("end")

    val arrayRef = {
      val arrayFields = array.zipWithIndex map { case (a, i) =>
        val name = i match {
          case `start` if start == end => s"start=end=$i"
          case `start` => s"start=$i"
          case `end` => s"end=$i"
          case _ => i.toString
        }
        a.refTree.withHighlight(i == start || i == end).toField.withName(name)
      }
      RefTree.Ref(array, arrayFields).rename(s"char[${array.length}]")
    }

    RefTree.Ref(ds, Seq(
      start.refTree.withHighlight(true).toField.withName("start"),
      end.refTree.withHighlight(true).toField.withName("end"),
      arrayRef.toField.withName("array")
    ) ++ ds.toArray.zipWithIndex.map({case (a, i) => a.refTree.toField.withName(i.toString)}))
  }

But, it would be nice to have start and end have arrows into the array. Is it possible?

Minimal example is not complete

In https://stanch.github.io/reftree/#minimal-example the example uses ImagePath but does not define it.

It would be easier if a URL was provided:

import java.nio.file.Paths

import reftree.diagram.Diagram
import reftree.render.{Renderer, RenderingOptions}

object Main {
  def main(args: Array[String]): Unit = {
    val imagePath = Paths.get("images") // current relative path + "images"
    val renderer = Renderer(
      renderingOptions = RenderingOptions(density = 75),
      directory = imagePath.resolve("overview")
    )

    import renderer._

    case class Person(firstName: String, age: Int)

    Diagram.sourceCodeCaption(Person("Bob", 42)).render("example")
    val file = directory.resolve("example.png")

    println(s"Open with Browser ${file.toUri}")
    println(s"Open with IntelliJ IDEA http://localhost:63342/api/file/${file.toString}")
  }
}

Publish for Scala 2.12

Currently this project is only published for Scala 2.11. I would love to use it for generating some documentation in Scala 2.12.

Allow custom formatting of value type fields

In some cases, the predefined options for formatting value fields are insufficient. E.g.

  • showing a long as a binary number might take too much space
  • you might want to emphasise that some bits to not matter. 00010100111xxxx

In these cases it would be useful to be able to provide a custom toString method or have another method to customise display of inline fields.

Internal macro error building reftree

Exception building diagram (on scala 2.12.5)

[info] Compiling 1 Scala source to /home/wsargent/work/scala-capabilities/images/target/scala-2.12/classes ...
[error] /home/wsargent/work/scala-capabilities/images/src/main/scala/Main.scala:90:44: Internal error: unable to find the outer accessor symbol of class anon$Generic Coproduct RefTree$macro$14
[error]     val diagram = Diagram(nameChanger)
[error]                                            ^
[error] ## Exception when compiling 1 sources to /home/wsargent/work/scala-capabilities/images/target/scala-2.12/classes
[error] null
[error] java.lang.String.valueOf(String.java:2994)

code is as follows

import java.nio.file.{Path, Paths}

import reftree.diagram.Diagram
import reftree.render.{Renderer, RenderingOptions}

object Main {

  // #definition
  final class Document(private var name: String) {
    private object capabilities {
      val nameChanger = new Document.NameChanger {
        override def changeName(newName: String): Unit =  {
          name = newName
        }
      }
    }
    override def toString: String = s"Document($name)"
  }
  // #definition

  // #access
  object Document {
    sealed trait NameChanger {
      def changeName(name: String): Unit
    }

    // Policy controls who has access to what
    class Access private {
      def nameChanger(doc: Document): NameChanger = {
        doc.capabilities.nameChanger
      }
    }

    object Access {
      def apply(): Access = new Access
    }
  }
  // #access

  // https://www.youtube.com/watch?v=6mWaqGHeg3g

  def main(args: Array[String]): Unit = {
    val imagePath = Paths.get("images") // current relative path + "images"
    implicit val renderer = Renderer(
      renderingOptions = RenderingOptions(),
      directory = imagePath.resolve("overview")
    )

    import renderer._

    def render(name: String, diagram: Diagram): Path = {
      diagram.render(name)
      directory.resolve(s"$name.${renderer.format}")
    }

    def display(path: Path) = {
      println(s"Open with Browser ${path.toUri}")
      println(s"Open with IntelliJ IDEA http://localhost:63342/api/file/${path.toString}")
    }

    val document = new Document("will")
    val access = Document.Access()
    val nameChanger = access.nameChanger(document)
    println(s"result = $document")

    val diagram = Diagram(nameChanger)

    display(render("nameChanger", diagram))
  }
}

Installation instructions incomplete, no cross-publishing for 1.2.0

When I look at the https://stanch.github.io/reftree/#including-in-your-project it says 1.2.0 is the latest.
In addition, the documentation does not specify that you are using bintray and so need to add a bintray resolver:

resolvers += Resolver.bintrayRepo("stanch", "reftree"),

The latest version on mvnrepository is 1.1.3:

https://mvnrepository.com/artifact/org.stanch/reftree

If I go to bintray directly then it does tell me it's 1.2.0:

https://bintray.com/stanch/maven/reftree/1.2.0

But it appears that 1.2.0 was only published for Scala 2.11, not 2.12 (it was not cross-published):

Finally, the gitbook demo is flaky -- if I type "makeSite" twice in a row then it fails with some npm exception. Not sure what's up with that.

Add support for Scala 2.13

Hey there! Is there any chance to publish this library for Scala 2.13? Or maybe if there is a PR from the community, would it be possible to merge it (asking for a friend 😄)?

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.