{{ $fqcn := (.Get 0) }}
{{- /* Extract the package and class name from the fully qualified class name */ -}}
{{- $package := split $fqcn "." -}}
{{- $kotlinClass := index $package (sub (len $package) 1) -}}
{{ $display := (.Get 1) | default $kotlinClass }}

{{- $module := "" }}
{{- if hasPrefix $fqcn "viaduct.service" }}
  {{- $module = "service/service/service-api" -}}
{{- else if hasPrefix $fqcn "viaduct.api" }}
  {{- $module = "tenant-api/tenant-api" -}}
{{- end -}}

{{- $kotlinClassURIFragment := replaceRE `([A-Z])` `-$1` $kotlinClass | lower | urlize -}}
{{- $packageURIFragment := delimit (first (sub (len $package) 1) $package) "." | urlize -}}

{{- $kdocLink := absURL (printf "apis/%s/%s/%s/" $module $packageURIFragment $kotlinClassURIFragment) -}}

<a class="kdoc-link" href="{{ $kdocLink }}"><code>{{ $display }}</code></a>
