https://kotlinlang.org logo
#dokka
Title
# dokka
s

simon.vergauwen

02/13/2023, 2:36 PM
Not sure if this is the right channel to ask, but can you manipulate where
knit
generates it's files 🤔 Currently I have some snippets
md
inside a
docusaurus
project,
rootDir/content/blog/my-doc.md
and I have a Gradle project with KotlinX Knit setup in
rootDir
. My goal is to have a
rootDir/guide
submodule with Kotlin setup, and have KotlinX Knit generate the code in there. Currently the only way I found. to do this is to move the generated Knit files into the
rootDir/guide
, but that seems like a ugly hack 😞
It currently makes a
guide
sub directory in
rootDir/content/blog/
. While it should be in
rootDir/guide
It works if I use
<!--- KNIT example-knit-01.kt -->
but I'd like to use
> You can get the full code [here](guide/src/test/kotlin/example/example-basic-01.kt)
a

Adam S

02/13/2023, 2:52 PM
have you tried the
test.dir
and
knit.dir
properties? from memory, Knit will read the
knit.properties
file in each dir https://github.com/Kotlin/kotlinx-knit#tests
s

simon.vergauwen

02/13/2023, 2:53 PM
Yes, I have
knit.dir
setup, and it works correctly when using
<!--- KNIT example-knit-01.kt -->
but using a link it completely ignores that path. So I guess it's a bug in Knit 🤔
a

Adam S

02/13/2023, 3:00 PM
so this is what you want to have?
Copy code
└── /
    ├── content/
    │   └── blog/
    │       ├── my-doc.md
    │       └── knit.properties
    └── guide/
        └── src/test/kotlin/example/
            └── example-basic-01.kt
what happens if you set
Copy code
knit.dir=../../guide/src/test/kotlin/example
?
s

simon.vergauwen

02/13/2023, 3:07 PM
Yes, that is indeed the structure I have. Let me try.
Then it only works the other way around. I can now use
Copy code
> You can get the full code [here](../../guide/src/test/kotlin/examples/example-basic-01.kt)
but breaks
<!--- KNIT example-basic-02.kt -->
😞
a

Adam S

02/13/2023, 3:23 PM
hmmm
there are also some knit Gradle settings https://github.com/Kotlin/kotlinx-knit#dokka-setup
s

simon.vergauwen

02/13/2023, 3:25 PM
I moved the
knit.properties
to
content/blog
, and I can duplicate it between different folders 🤔 But now I cannot reference
test.template
by doing
../../
nor using
symlinks
..
Getting somewhere though
I guess the templateloader cannot see symlinks
a

Adam S

02/13/2023, 3:29 PM
I’m also using Docusaurus + Knit in kxs-ts-gen https://adamko-dev.github.io/kotlinx-serialization-typescript-generator/docs/examples/basic-classes I got this working by having separate Gradle projects for Knit (
./docs/
) and Docusaurus (
./site/
). The Knit project generates the examples & tests internally (
./docs/src/test
,
./docs/src/examples/
), and shares the files to the Docusaurus project via Gradle Configurations. And the Docusaurus project fixes the links with a regex.
👀 1
s

simon.vergauwen

02/13/2023, 3:30 PM
Interesting, thanks for sharing!
a

Adam S

02/13/2023, 3:31 PM
no problem! Any questions, please ask
s

simon.vergauwen

02/14/2023, 11:07 AM
I think I got it to work without any
Sync
or copy like tasks needed ☺️ Thanks for your help @Adam S! Wouldn't have been able to set it up in this way without it 🙏
Copy code
└── /
    ├── content/
    │   └── blog/
    │       ├── my-doc.md
    │       └── knit.properties
    │       └── knit.test.template
    └── guide/
        └── build.gradle.kts
        └── src/test/kotlin/example/
            └── example-basic-01.kt
        └── src/test/kotlin/example/test
            └── BasicTest.kt
    ├── knit.properties
    ├── build.gradle.kts
    ├── settings.gradle.kts
This is the structure I ended up with
a

Adam S

02/14/2023, 3:37 PM
nice! What did you put
knit.properties
? Did you have to do any
knit {}
Gradle config?
s

simon.vergauwen

02/14/2023, 4:16 PM
In the
root/knit.properties
I am pointing to
guide/src/test/kotlin/examples/
and in the nested
content/blog/knit.properties
I am pointing to the same directory
../../guide/src/test/kotlin/examples/
. My
knit { }
configured is the default, I only applied
siteRoot
.
👍 1
4 Views