Giter VIP home page Giter VIP logo

deepprint's People

Contributors

brady-aiello avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

deepprint's Issues

Automate Publishing

This will involve

  1. Uploading some Sonatype secrets for GH Actions
  2. Creating a publishing GH Action
  3. Triggering this action when pushing a commit with a tag that conforms to semantic versioning. Looking at this one from KMM-ViewModel as an example.

Make the indent configurable

DeepPrint currently just uses 4 space indentation. It would be nice if users could configure indentation to suit other coding styles and needs.

WithAList(
    name = "some list",
    items = listOf<Int>( 0, 1, 2, 3, 4,),
)
WithAList(
  name = "some list",
  items = listOf<Int>( 0, 1, 2, 3, 4,),
)

Add support for external data classes or non-data classes

If we have a data class we don't own, we should be able to deep print it somehow.
Given:

data class SomeExternalClass(val name: String, val age: Int)

Not sure the best way to do this.

  1. we might be able to generate SomeExternalClass.deepPrint() exactly once, and place it in a package that matches its declaration, if any instances are the properties of an annotated class, without any modification:
@DeepPrint
data class MyClass(val externalClass: SomeExternalClass)
  1. or we give the processor a heads up about the class we need to generate it for:
@DeepPrint
data class MyClass(@DeepPrint val externalClass: SomeExternalClass)
  1. or we can manually create a deep print function, and pass it as an optional parameter:
@DeepPrint
data class MyClass(@DeepPrint(with = ::myExternalClassDeepPrintFunction)val externalClass: SomeExternalClass)
fun myEternalClassDepPrintFunction(externalClass: SomeExternalClass) {
    println("""
        SomeExternalClass(
            val someProperty = ${externalClass.someProperty}
        )
    """).trimIndent()
}

Options 1 or 2 would be ideal, as it would require little to no extra work from the caller. The main issue with options 1 and 2 is getting enough information about the externally declared class. KSP is not being run on compiled code, and there is just less type information available. There might be a way to do this still, so it's worth taking another stab at.

Option 3 is probably the easiest to implement, and the most flexible. It would allow for any class from any module to be deep-printable. It does require an extra step. But, depending on the class in question, the benefit might outweigh the cost of writing another function.

Add a reflection-based implementation

Background: https://twitter.com/HandstandSam/status/1625653445045673984

Using KSP is cool because it works on all platforms, and printing should be faster than with reflection. However, the KSP approach is limited because it requires annotation of all data classes in an object tree. Besides adding extra work, it may also be impossible to get everything printing correctly if it contains a data class from an external library.

Making a lighter-weight reflection-based version of the library could cover more use cases for JVM-only consumers.

To start, we'll just cover data classes and primitives, and will add collections in another ticket + PR.

Add support for Maps

Like tests with lists, which are supported:

WithAList(
    name = "some list",
    items = listOf<Int>( 0, 1, 2, 3, 4,),
)

We should also support maps:

WithAMap(
    name = "some map",
    items = mapOf('a' to 5, 'b' to 23, 'c' to 11),
)

Set up publishing

Need to publish the deep-print-annotations module and the deep-print-processor module so they can actually be used ๐Ÿ™ƒ

Add Gradle setup documentation

Describe how to:

  • apply the KSP plugin
  • add runtime dependencies
  • configure KSP generated code locations for:
    • single platform Kotlin projects
    • multiplatform Kotlin projects

Make sure to add references

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.