diff --git a/layouts/partials/qmltype.html b/layouts/partials/qmltype.html
index d5a923c..25ea2c4 100644
--- a/layouts/partials/qmltype.html
+++ b/layouts/partials/qmltype.html
@@ -1,7 +1,7 @@
{{- if eq .type "unknown" -}}
unknown
{{- else -}}
- {{- $link := "#ERROR" -}}
+ {{- $link := "" -}}
{{- if eq .type "qt" -}}
{{- $link = printf "https://doc.qt.io/qt-6/%s-%s.html" (lower (replace .module "." "-")) (lower .name) -}}
{{- else if eq .type "local" -}}
@@ -13,30 +13,39 @@
{{- $of = printf "<%s>" (partial "qmltype.html" .of) }}
{{- end -}}
+ {{- $prefix := "" -}}
{{- $member := "" -}}
- {{- if .prop -}}
- {{- $member = printf ".%s" .prop -}}
- {{- if eq .type "qt" -}}
- {{- $link = printf "%s#%s-prop" $link .prop -}}
- {{- else if eq .type "local" -}}
- {{- $link = printf "%s#prop.%s" $link .prop -}}
+ {{- if .mtype -}}
+ {{- if .type -}}
+ {{- $member = printf ".%s" .mname -}}
+ {{- else -}}
+ {{- $member = .mname -}}
{{- end -}}
- {{- else if .func -}}
- {{- $member = printf ".%s()" .func -}}
- {{- if eq .type "qt" -}}
- {{- $link = printf "%s#%s-method" $link .func -}}
- {{- else if eq .type "local" -}}
- {{- $link = printf "%s#func.%s" $link .func -}}
- {{- end -}}
- {{- else if .signal -}}
- {{- $member = printf ".%s()" .signal -}}
- {{- if eq .type "qt" -}}
- {{- $link = printf "%s#%s-signal" $link .signal -}}
- {{- else if eq .type "local" -}}
- {{- $link = printf "%s#signal.%s" $link .signal -}}
+
+ {{- if eq .mtype "prop" -}}
+ {{- if eq .type "qt" -}}
+ {{- $link = printf "%s#%s-prop" $link .mname -}}
+ {{- else -}}
+ {{- $link = printf "%s#prop.%s" $link .mname -}}
+ {{- end -}}
+ {{- else if eq .mtype "func" -}}
+ {{- $member = printf "%s()" $member -}}
+ {{- if eq .type "qt" -}}
+ {{- $link = printf "%s#%s-method" $link .mname -}}
+ {{- else -}}
+ {{- $link = printf "%s#func.%s" $link .mname -}}
+ {{- end -}}
+ {{- else if eq .mtype "signal" -}}
+ {{- $prefix = "[signal] " -}}
+ {{- $member = printf "%s()" $member -}}
+ {{- if eq .type "qt" -}}
+ {{- $link = printf "%s#%s-signal" $link .mname -}}
+ {{- else -}}
+ {{- $link = printf "%s#signal.%s" $link .mname -}}
+ {{- end -}}
{{- end -}}
{{- end -}}
- {{ .name }}{{ $member }}{{ $of | safeHTML -}}
+ {{ $prefix }}{{ .name }}{{ $member }}{{ $of | safeHTML -}}
{{- end -}}
diff --git a/typegen/src/parse.rs b/typegen/src/parse.rs
index 738807e..9d9644f 100644
--- a/typegen/src/parse.rs
+++ b/typegen/src/parse.rs
@@ -663,45 +663,62 @@ fn parse_details(comment: Comment) -> String {
})
.unwrap_or_else(|| (src.len(), src));
- let mut split = ty.rsplit_once('.').unwrap_or(("", ty));
-
- let member = split
- .1
- .chars()
- .next()
- .unwrap()
- .is_lowercase()
- .then(|| {
- let prop = split.1;
- split = split.0.rsplit_once('.').unwrap_or(("", split.0));
- prop
- })
- .unwrap_or("");
// special case for . as it is contained in valid types as well
if ty.ends_with('.') {
end -= 1;
ty = &ty[..ty.len() - 1];
}
- let (prop, func, signal) = match member {
- name if name.ends_with("()") => ("", &name[..name.len() - 2], ""),
- name if name.ends_with("(s)") => ("", "", &name[..name.len() - 3]),
- name => (name, "", ""),
+ let (ty, member) = match ty.chars().next() {
+ None => (None, None),
+ Some(c) if c.is_lowercase() => (None, Some(ty)),
+ Some(_) => {
+ let mut split = ty.rsplit_once('.').unwrap_or(("", ty));
+
+ let member = split
+ .1
+ .chars()
+ .next()
+ .unwrap()
+ .is_lowercase()
+ .then(|| {
+ let prop = split.1;
+ split = split.0.rsplit_once('.').unwrap_or(("", split.0));
+ prop
+ })
+ .unwrap_or("");
+
+ let (mut module, name) = split;
+
+ if module.is_empty() {
+ module = comment.module;
+ }
+
+ (Some((module, name)), Some(member))
+ },
};
- let (mut module, name) = split;
+ let (membertype, membername) = match member {
+ None => ("", ""),
+ Some(name) if name.ends_with("()") => ("func", &name[..name.len() - 2]),
+ Some(name) if name.ends_with("(s)") => ("signal", &name[..name.len() - 3]),
+ Some(name) => ("prop", name),
+ };
- if module.is_empty() {
- module = comment.module;
- }
+ let ((linktype, module), name) = match ty {
+ Some((module, name)) => {
+ let module = match module {
+ module if module.starts_with("Quickshell") => ("local", module.to_string()),
+ module => ("qt", format!("qml.{module}")),
+ };
- let (linktype, module) = match module.starts_with("Quickshell") {
- true => ("local", module.to_string()),
- false => ("qt", format!("qml.{module}")),
+ (module, name)
+ },
+ None => (("", String::new()), ""),
};
accum += &format!(
- r#"{{{{< qmltypelink type="{linktype}" module="{module}" name="{name}" prop="{prop}" func="{func}" signal="{signal}" >}}}}"#
+ r#"{{{{< qmltypelink type="{linktype}" module="{module}" name="{name}" mtype="{membertype}" mname="{membername}" >}}}}"#
);
src = &src[end..];
}