I'm trying to find the code that parses a kdoc com...
# compiler
j
I'm trying to find the code that parses a kdoc comment into a string by removing the syntactical decoration (i.e.,
/**
,
*
,
*/
, and such), and whether that is something available as public API or not
h
Couldn’t you just remove the first three characters of each line? Then you don’t need to handle nested stars.
j
Unfortunately, no. You can do
Copy code
/** Things
like
        this
*/
  class Hi
🤯 1
h
Curios if dokka handles such cases 🤔 if so, you could take a look at their implementation.
j
The IDE handles them pretty well. I was hoping there was something in the compiler that the IDE and Dokka shared so as to agree
o
Overall, kotlin compiler provides lazy PSI for parsed doc comment, I’m not sure though if it’s possible to take it as just string, but may be there is some function on PSI which will render it it’s possible to get kdoc from PSI here: https://github.com/JetBrains/kotlin/blob/22e4c624f285013dfcbcc2f84a7539d458d6ecd2/compiler/psi/src/org/jetbrains/kotlin/psi/KtDeclaration.java#L29
gratitude thank you 1
m
j
I'm currently, lazily doing this https://github.com/cashapp/redwood/blob/f0b39d4c3770746ad35b74b9e1558f42a22f8554/redwood-tooling-schema/src/main/kotlin/app/cash/redwood/tooling/schema/schemaParserFir.kt#L625-L630 I'll look at using the actual KDoc type and see what that gives me (when I get to a computer)