2
1
Fork 0

typegen: add reference shorthand for functions and signals

This commit is contained in:
outfoxxed 2024-07-20 02:18:06 -07:00
parent 170d7d9252
commit 3fe7cf9bf9
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
2 changed files with 22 additions and 2 deletions

View file

@ -22,6 +22,20 @@
{{- else if eq .type "local" -}} {{- else if eq .type "local" -}}
{{- $link = printf "%s#prop.%s" $link .prop -}} {{- $link = printf "%s#prop.%s" $link .prop -}}
{{- end -}} {{- 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 -}}
{{- end -}}
{{- end -}} {{- end -}}
<a href="{{ $link }}">{{ .name }}{{ $member }}</a>{{ $of | safeHTML -}} <a href="{{ $link }}">{{ .name }}{{ $member }}</a>{{ $of | safeHTML -}}

View file

@ -658,7 +658,7 @@ fn parse_details(comment: Comment) -> String {
let mut split = ty.rsplit_once('.').unwrap_or(("", ty)); let mut split = ty.rsplit_once('.').unwrap_or(("", ty));
let prop = split let member = split
.1 .1
.chars() .chars()
.next() .next()
@ -671,6 +671,12 @@ fn parse_details(comment: Comment) -> String {
}) })
.unwrap_or(""); .unwrap_or("");
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 (mut module, name) = split; let (mut module, name) = split;
if module.is_empty() { if module.is_empty() {
@ -683,7 +689,7 @@ fn parse_details(comment: Comment) -> String {
}; };
accum += &format!( accum += &format!(
r#"{{{{< qmltypelink type="{linktype}" module="{module}" name="{name}" prop="{prop}" >}}}}"# r#"{{{{< qmltypelink type="{linktype}" module="{module}" name="{name}" prop="{prop}" func="{func}" signal="{signal}" >}}}}"#
); );
src = &src[end..]; src = &src[end..];
} }