pdb: better deprecated message, assuming it can be a function, GEGL op…

… or a content to use as-is.

Until now, it was assuming the deprecated content was a function. So if
I want to deprecate in favor of a GEGL op (e.g. "gimp:levels"), we'd
have warnings showing a "Deprecated: Use gimp:levels() instead".

Now it will try to recognize the type of suggested replacement with a
basic heuristic: if there is a space, it'll just use the replacement
text as-is; else if there is a colon, it'll assume it's a filter name.
Else it assumes it's a replacement function, as it used to.
This commit is contained in:
Jehan 2026-02-01 19:19:55 +01:00
parent 250469dd05
commit 1d167ce611
2 changed files with 39 additions and 5 deletions

View file

@ -935,13 +935,29 @@ sub generate {
$help .= "Deprecated: There is no replacement for this procedure.";
}
else {
my $replacement = $proc->{deprecated};
chomp $replacement;
if ($replacement =~ / /) {
# Use the deprecated string as-is.
$replacement =~ s/"/\\"/g;
}
elsif ($replacement =~ /:/) {
# Replacement is a GEGL operation.
$replacement = "filter \\\"$replacement\\\"";
}
else {
# Replacement is another function.
$replacement =~ s/-/_/g;
$replacement .= '()';
}
if (!$blurb) {
$blurb = "Deprecated: Use '$proc->{deprecated}' instead.";
}
if ($help) {
$help .= "\n\n";
}
$help .= "Deprecated: Use '$proc->{deprecated}' instead.";
$help .= "Deprecated: Use $replacement instead.";
}
}
@ -980,9 +996,14 @@ sub generate {
CODE
if ($proc->{deprecated}) {
my $replacement = $proc->{deprecated};
chomp $replacement;
if ($replacement =~ /"/) {
$replacement =~ s/"/\\"/g;
}
$out->{register} .= <<CODE;
gimp_procedure_set_deprecated (procedure,
"$proc->{deprecated}");
"$replacement");
CODE
}

View file

@ -561,8 +561,21 @@ CODE
"for this procedure.");
}
else {
my $underscores = $proc->{deprecated};
$underscores =~ s/-/_/g;
my $replacement = $proc->{deprecated};
chomp $replacement;
if ($replacement =~ / /) {
# Use the deprecated string as-is.
#$replacement =~ s/"/\\"/g;
}
elsif ($replacement =~ /:/) {
# Replacement is a GEGL operation.
$replacement = "filter \"$replacement\"";
}
else {
# Replacement is another function.
$replacement =~ s/-/_/g;
$replacement .= '()';
}
if ($proc->{blurb}) {
$procdesc = &desc_wrap($proc->{blurb}) . "\n *\n";
@ -571,7 +584,7 @@ CODE
$procdesc .= &desc_wrap($proc->{help}) . "\n *\n";
}
$procdesc .= &desc_wrap("Deprecated: " .
"Use $underscores() instead.");
"Use $replacement instead.");
}
}
else {