-
-
Save edwinRNDR/917fe9398e8e0571e518f750df25b136 to your computer and use it in GitHub Desktop.
An idea for OPENRNDR documentation generated from Kotlin code. Wondering what kind of tooling I need and what exists to be able to achieve this.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// These are some simple annotations that are used to document the source code. | |
@Retention(AnnotationRetention.SOURCE) | |
annotation class ProgramDescription(val description:String, val media:Array<String>) | |
@Target(AnnotationTarget.EXPRESSION) | |
@Retention(AnnotationRetention.SOURCE) | |
annotation class SuppressInDocumentation | |
@Target(AnnotationTarget.EXPRESSION) | |
@Retention(AnnotationRetention.SOURCE) | |
annotation class ExpressionDescription(val description: String) | |
@Target(AnnotationTarget.EXPRESSION) | |
@Retention(AnnotationRetention.SOURCE) | |
annotation class ValueDescription(val description: String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- this is the generated documentation, in pseudo-html, just to demonstrate the process --> | |
<html> | |
<body> | |
<p> | |
This program shows the basics of OPENRNDR and 'Docgrams' (document + program) | |
</p> | |
<video src="Example001.mp4"></video> | |
<div class="code"> | |
fun main(args: Array<String>) = application { | |
<div description="describe a program"> | |
program { | |
<div description="extend the program with a drawing function"> | |
extend { | |
<div description="make a for-loop"> | |
for (i in 0 until 10) { | |
<div description="draw a circle"> | |
drawer.circle(100 + i * 10.0, 100.0, <div description="the radius, fixed at 40.0"> 40.0 </div>) | |
</div> | |
} | |
</div> | |
} | |
</div> | |
} | |
</div> | |
</div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is the input Docgram. It is runnable and processable using some to be defined tool. | |
import org.openrndr.application | |
import org.openrndr.ScreenRecorder | |
@ProgramDescription(""" | |
This program shows the basics of OPENRNDR and 'Docgrams' (document + program) | |
""", media = ["Example001.mp4"]) | |
fun main(args: Array<String>) = application { | |
@ExpressionDescription("describe a program") | |
program { | |
@SuppressInDocumentation | |
extend { | |
// these are mechanics that make the software write to an mp4 file that has a 1 second duration | |
ScreenRecorder("Example001.mp4", duration=1.0) | |
} | |
@ExpressionDescription("extend the program with a drawing function") | |
extend { | |
@ExpressionDescription("make a for-loop") | |
for (i in 0 until 10) { | |
@ExpressionDescription("draw a circle") | |
drawer.circle(100 + i * 10.0, 100.0, @ValueDescription("the radius, fixed at 40.0") 40.0) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This makes the Example001.kt file much harder to read.
If you go for this it would be nice it Example001.kt also get's exported to a file with the annotations removed.