How to add formatting such as bold, italic, underscore, etc. to Kotlin documenation (KDoc)

8.9k views Asked by At

I found the page Documenting Kotlin Code in the official Kotlin Reference.

Yet, I could not find out how to highlight certain parts of the documentation, e.g., marking it as italic or bold.

I am new to Kotlin, coming from Java, and have previously only been using JavaDoc, where we used <i> and <b> HTML tags to highlight parts in the documentation.

1

There are 1 answers

0
Markus Weninger On BEST ANSWER

As I wrote this question, I found the answer to it. Silly me, the link I was looking for even was on the page I referenced in the question.

So, I will write an answer to my own question, probably someone else can profit from it in the future.

The documentation states:

Inline Markup For inline markup, KDoc uses the regular Markdown syntax, extended to support a shorthand syntax for linking to other elements in the code.

So, to highlight a few points of Markdown:

  • Markdown treats asterisks (*) and underscores (_) as indicators of emphasis. Text wrapped with one * or _ will be wrapped with an HTML <em> tag; double *’s or _’s will be wrapped with an HTML <strong> tag. Typically, a single asterik results in italic, while double asterik results in bold.
  • Headers can be started with # (h1), ## (h2), or ### (h3). For example: # This is an H1
  • Code can be wrapped in backticks
  • Quotes start with a right arrow (>)
  • Markdown also supports unordered and ordered lists
  • ... and more