but if I wish to include samples, and things like ...
# dokka
b
but if I wish to include samples, and things like that, I can't find any documentation on that (and dokka itself doesn't seem to have documentation on its own code…)
e
you mean code samples? Dokka supports Markdown, so you can use backticks to format code
b
I found @sample <class>, but it doesn't have any syntax highlighting
I see that it supports… things… but I can't really find examples
e
how do you expect @sample tag to be rendered? if it’s a link to a specific class then the standard Markdown link syntax should do it, e.g.
[Sample](com.example.Sample)
b
if I type @sample net.nprod.rdf4k.examples.model.Example02BuildModel
I see the code from that specific file in my documentation
but that code is not syntax highlighted. I also don't understand where to put external markdown files
looks like some doc: https://bjonnh.github.io/rdf4k/
I'll see if I can include some js syntax highlighter and customize the stylesheets.
m
I’m currently working through the @sample myself. Take a look at the Kotlin docs. https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/drop-while.html See the executable code snippet at the bottom? That’s from an @sample. The samples are actual kt code, and NOT markdown. It appears you can build them as a test of sorts, that then is executed to ensure it’s valid, but modified slightly to be added to documentation. I’m looking at the kotlin project itself, but having a hard time configuring aspects of it in my own project due to the complexity of the kotlin project itself. If you want a really simple example, create a Samples.kt file and put a single function in it. Add the kt file directly to the
samples
configuration of Dokka plugin, and then you can refer to the function in the @sample directly by name. That will get you started on how I think @sample is supposed to be used. BUT totally agree the documentation is very lacking
b
Really cool! Thanks!
m
I can't share my current project but I've figured out a number of things and will create a project I can share. Haven't figured out how kotlin docs are converting test code into snippets with execution linked in but at least the samples.do show up as coded inside the function.
b
could it just be a JS they have that makes that and talk to try kotlin?
m
It's deeper than that because in the sample one can put 'assertEquals(list.size, 5)' and the docs will show. 'List.size. //5'. So some form of replacement or something going on. Could be js for that or something I'm not seeing yet in processing.