typegen: further reference shorthand for members of current class
This commit is contained in:
parent
1f47b15963
commit
1fc815f73e
|
@ -1,7 +1,7 @@
|
||||||
{{- if eq .type "unknown" -}}
|
{{- if eq .type "unknown" -}}
|
||||||
unknown
|
unknown
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
{{- $link := "#ERROR" -}}
|
{{- $link := "" -}}
|
||||||
{{- if eq .type "qt" -}}
|
{{- if eq .type "qt" -}}
|
||||||
{{- $link = printf "https://doc.qt.io/qt-6/%s-%s.html" (lower (replace .module "." "-")) (lower .name) -}}
|
{{- $link = printf "https://doc.qt.io/qt-6/%s-%s.html" (lower (replace .module "." "-")) (lower .name) -}}
|
||||||
{{- else if eq .type "local" -}}
|
{{- else if eq .type "local" -}}
|
||||||
|
@ -13,30 +13,39 @@
|
||||||
{{- $of = printf "<%s>" (partial "qmltype.html" .of) }}
|
{{- $of = printf "<%s>" (partial "qmltype.html" .of) }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- $prefix := "" -}}
|
||||||
{{- $member := "" -}}
|
{{- $member := "" -}}
|
||||||
|
|
||||||
{{- if .prop -}}
|
{{- if .mtype -}}
|
||||||
{{- $member = printf ".%s" .prop -}}
|
{{- if .type -}}
|
||||||
{{- if eq .type "qt" -}}
|
{{- $member = printf ".%s" .mname -}}
|
||||||
{{- $link = printf "%s#%s-prop" $link .prop -}}
|
{{- else -}}
|
||||||
{{- else if eq .type "local" -}}
|
{{- $member = .mname -}}
|
||||||
{{- $link = printf "%s#prop.%s" $link .prop -}}
|
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- else if .func -}}
|
|
||||||
{{- $member = printf ".%s()" .func -}}
|
{{- if eq .mtype "prop" -}}
|
||||||
{{- if eq .type "qt" -}}
|
{{- if eq .type "qt" -}}
|
||||||
{{- $link = printf "%s#%s-method" $link .func -}}
|
{{- $link = printf "%s#%s-prop" $link .mname -}}
|
||||||
{{- else if eq .type "local" -}}
|
{{- else -}}
|
||||||
{{- $link = printf "%s#func.%s" $link .func -}}
|
{{- $link = printf "%s#prop.%s" $link .mname -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- else if .signal -}}
|
{{- else if eq .mtype "func" -}}
|
||||||
{{- $member = printf ".%s()" .signal -}}
|
{{- $member = printf "%s()" $member -}}
|
||||||
{{- if eq .type "qt" -}}
|
{{- if eq .type "qt" -}}
|
||||||
{{- $link = printf "%s#%s-signal" $link .signal -}}
|
{{- $link = printf "%s#%s-method" $link .mname -}}
|
||||||
{{- else if eq .type "local" -}}
|
{{- else -}}
|
||||||
{{- $link = printf "%s#signal.%s" $link .signal -}}
|
{{- $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 -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
<a href="{{ $link }}">{{ .name }}{{ $member }}</a>{{ $of | safeHTML -}}
|
<a href="{{ $link }}">{{ $prefix }}{{ .name }}{{ $member }}</a>{{ $of | safeHTML -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
|
@ -663,6 +663,16 @@ fn parse_details(comment: Comment) -> String {
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|| (src.len(), src));
|
.unwrap_or_else(|| (src.len(), src));
|
||||||
|
|
||||||
|
// special case for . as it is contained in valid types as well
|
||||||
|
if ty.ends_with('.') {
|
||||||
|
end -= 1;
|
||||||
|
ty = &ty[..ty.len() - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
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 mut split = ty.rsplit_once('.').unwrap_or(("", ty));
|
||||||
|
|
||||||
let member = split
|
let member = split
|
||||||
|
@ -677,17 +687,6 @@ fn parse_details(comment: Comment) -> String {
|
||||||
prop
|
prop
|
||||||
})
|
})
|
||||||
.unwrap_or("");
|
.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 (mut module, name) = split;
|
let (mut module, name) = split;
|
||||||
|
|
||||||
|
@ -695,13 +694,31 @@ fn parse_details(comment: Comment) -> String {
|
||||||
module = comment.module;
|
module = comment.module;
|
||||||
}
|
}
|
||||||
|
|
||||||
let (linktype, module) = match module.starts_with("Quickshell") {
|
(Some((module, name)), Some(member))
|
||||||
true => ("local", module.to_string()),
|
},
|
||||||
false => ("qt", format!("qml.{module}")),
|
};
|
||||||
|
|
||||||
|
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),
|
||||||
|
};
|
||||||
|
|
||||||
|
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}")),
|
||||||
|
};
|
||||||
|
|
||||||
|
(module, name)
|
||||||
|
},
|
||||||
|
None => (("", String::new()), ""),
|
||||||
};
|
};
|
||||||
|
|
||||||
accum += &format!(
|
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..];
|
src = &src[end..];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue