[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Fri, 10 May 2024 18:25:34 -0400 (EDT) |
branch: master
commit 114143f99be391ae54147a1e41fb1f2b0d3eaea1
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat May 11 00:08:38 2024 +0200
* tp/Texinfo/Convert/DocBook.pm (%def_argument_types_docbook)
(_convert), tp/Texinfo/Convert/TexinfoMarkup.pm (_convert),
tp/Texinfo/Convert/Utils.pm (definition_arguments_content)
(definition_category_tree), tp/Texinfo/Translations.pm
(complete_indices), tp/Texinfo/XS/main/convert_utils.c
(definition_arguments_content, definition_category_tree),
tp/Texinfo/XS/parsetexi/indices.c (complete_indices): use directly the
type of definition line argument containers instead of def_role.
---
ChangeLog | 11 +++++++++++
tp/Texinfo/Convert/DocBook.pm | 14 +++++++-------
tp/Texinfo/Convert/TexinfoMarkup.pm | 22 ++++++++++++++--------
tp/Texinfo/Convert/Utils.pm | 24 +++++++++++++-----------
tp/Texinfo/Translations.pm | 10 +++++-----
tp/Texinfo/XS/main/convert_utils.c | 24 ++++++++++--------------
tp/Texinfo/XS/parsetexi/indices.c | 11 +++++------
7 files changed, 65 insertions(+), 51 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d65ba31c6b..c445afb77a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-05-10 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/DocBook.pm (%def_argument_types_docbook)
+ (_convert), tp/Texinfo/Convert/TexinfoMarkup.pm (_convert),
+ tp/Texinfo/Convert/Utils.pm (definition_arguments_content)
+ (definition_category_tree), tp/Texinfo/Translations.pm
+ (complete_indices), tp/Texinfo/XS/main/convert_utils.c
+ (definition_arguments_content, definition_category_tree),
+ tp/Texinfo/XS/parsetexi/indices.c (complete_indices): use directly the
+ type of definition line argument containers instead of def_role.
+
2024-05-10 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/parsetexi/def.c (parse_def): use definition line
diff --git a/tp/Texinfo/Convert/DocBook.pm b/tp/Texinfo/Convert/DocBook.pm
index 5085c338a7..4465734ec4 100644
--- a/tp/Texinfo/Convert/DocBook.pm
+++ b/tp/Texinfo/Convert/DocBook.pm
@@ -210,13 +210,13 @@ my %defcommand_name_type = (
);
my %def_argument_types_docbook = (
- 'type' => ['returnvalue'],
- 'class' => ['ooclass', 'classname'],
+ 'def_type' => ['returnvalue'],
+ 'def_class' => ['ooclass', 'classname'],
# TODO or a simple emphasis?
# replaceable is not used here, such that replaceable is only
# used if there is an explicit @var{}
- 'arg' => ['emphasis role="arg"'],
- 'typearg' => ['type'],
+ 'def_arg' => ['emphasis role="arg"'],
+ 'def_typearg' => ['type'],
);
my %ignored_block_commands;
@@ -1703,15 +1703,15 @@ sub _convert($$;$)
$main_command = $element->{'extra'}->{'def_command'};
}
foreach my $arg (@{$element->{'args'}->[0]->{'contents'}}) {
- my $type = $arg->{'extra'}->{'def_role'};
+ my $type = $arg->{'type'};
next if !$type and $arg->{'type'} eq 'spaces';
my $content = $self->_convert($arg);
if ($type eq 'spaces' or $type eq 'delimiter') {
$result .= $content;
- } elsif ($type eq 'category') {
+ } elsif ($type eq 'def_category') {
$result .= "<phrase role=\"category\"><emphasis
role=\"bold\">$content</emphasis>:</phrase>";
- } elsif ($type eq 'name') {
+ } elsif ($type eq 'def_name') {
$result .=
"<$defcommand_name_type{$main_command}>$content</$defcommand_name_type{$main_command}>";
} else {
if (!defined($def_argument_types_docbook{$type})) {
diff --git a/tp/Texinfo/Convert/TexinfoMarkup.pm
b/tp/Texinfo/Convert/TexinfoMarkup.pm
index a266787a18..36c6ed7b9a 100644
--- a/tp/Texinfo/Convert/TexinfoMarkup.pm
+++ b/tp/Texinfo/Convert/TexinfoMarkup.pm
@@ -1516,28 +1516,29 @@ sub _convert($$;$)
$alias = 0;
}
foreach my $arg (@{$element->{'args'}->[0]->{'contents'}}) {
+ my $type = $arg->{'type'};
# should only happen for dubious trees in which the def line
# was not split in def roles
- next if (not $arg->{'extra'} or not $arg->{'extra'}->{'def_role'});
- my $type = $arg->{'extra'}->{'def_role'};
+ next if (!defined($type));
my $content = $self->_convert($arg);
if ($type eq 'spaces') {
$content =~ s/\n$//;
$result .= $content;
} else {
my $attribute = [];
- if ($type eq 'category' and $alias) {
+ if ($type eq 'def_category' and $alias) {
push @$attribute, ['automatic', 'on'];
}
my $format_element;
- if ($type eq 'name') {
+ if ($type eq 'def_name') {
$format_element = $defcommand_name_type{$main_command};
- } elsif ($type eq 'arg') {
+ } elsif ($type eq 'def_arg') {
$format_element = 'param';
- } elsif ($type eq 'typearg') {
+ } elsif ($type eq 'def_typearg') {
$format_element = 'paramtype';
} else {
$format_element = $type;
+ $format_element =~ s/^def_//;
}
if ($arg->{'contents'} and scalar($arg->{'contents'})
and $arg->{'contents'}->[0]->{'type'}
@@ -1571,8 +1572,13 @@ sub _convert($$;$)
and not ($element->{'parent'}->{'parent'}->{'cmdname'}
and $element->{'parent'}->{'parent'}->{'cmdname'}
eq 'multitable')
- and (!$element->{'parent'}->{'extra'}
- or !defined($element->{'parent'}->{'extra'}->{'def_role'})))
{
+ and (!$element->{'parent'}->{'type'}
+ or ($element->{'parent'}->{'type'} ne 'def_category'
+ and $element->{'parent'}->{'type'} ne 'def_type'
+ and $element->{'parent'}->{'type'} ne 'def_name'
+ and $element->{'parent'}->{'type'} ne 'def_typearg'
+ and $element->{'parent'}->{'type'} ne 'def_arg'
+ and $element->{'parent'}->{'type'} ne 'def_class'))) {
my $attribute = [];
push @$attribute, ['bracketed', 'on'];
push @$attribute, _leading_trailing_spaces_arg($element);
diff --git a/tp/Texinfo/Convert/Utils.pm b/tp/Texinfo/Convert/Utils.pm
index e2bcb2a056..add8859f14 100644
--- a/tp/Texinfo/Convert/Utils.pm
+++ b/tp/Texinfo/Convert/Utils.pm
@@ -106,16 +106,17 @@ sub definition_arguments_content($)
my @args = @{$element->{'args'}->[0]->{'contents'}};
while (@args) {
- my $role = $args[0]->{'extra'}->{'def_role'};
- if ($role eq 'category') {
+ my $arg_type = $args[0]->{'type'};
+ if ($arg_type eq 'def_category') {
$category = shift @args;
- } elsif ($role eq 'class') {
+ } elsif ($arg_type eq 'def_class') {
$class = shift @args;
- } elsif ($role eq 'type') {
+ } elsif ($arg_type eq 'def_type') {
$type = shift @args;
- } elsif ($role eq 'name') {
+ } elsif ($arg_type eq 'def_name') {
$name = shift @args;
- } elsif ($role eq 'arg' or $role eq 'typearg' or $role eq 'delimiter') {
+ } elsif ($arg_type eq 'def_arg' or $arg_type eq 'def_typearg'
+ or $arg_type eq 'delimiter') {
last;
}
shift @args;
@@ -140,13 +141,14 @@ sub definition_category_tree($$)
my $arg_category;
my $arg_class;
foreach my $arg (@{$current->{'args'}->[0]->{'contents'}}) {
- my $role = $arg->{'extra'}->{'def_role'};
- if ($role eq 'category') {
+ my $type = $arg->{'type'};
+ if ($type eq 'def_category') {
$arg_category = $arg;
- } elsif ($role eq 'class') {
+ } elsif ($type eq 'def_class') {
$arg_class = $arg;
- } elsif ($role eq 'space') {
- } elsif ($role eq 'arg' or $role eq 'typearg' or $role eq 'delimiter') {
+ } elsif ($type eq 'space') {
+ } elsif ($type eq 'def_arg' or $type eq 'def_typearg'
+ or $type eq 'delimiter') {
last;
}
}
diff --git a/tp/Texinfo/Translations.pm b/tp/Texinfo/Translations.pm
index 9b8ab7c924..7e7f07c4d0 100644
--- a/tp/Texinfo/Translations.pm
+++ b/tp/Texinfo/Translations.pm
@@ -409,13 +409,13 @@ sub complete_indices($;$)
my ($name, $class);
if ($main_entry_element->{'args'}->[0]->{'contents'}) {
foreach my $arg
(@{$main_entry_element->{'args'}->[0]->{'contents'}}) {
- my $role = $arg->{'extra'}->{'def_role'};
- if ($role eq 'name') {
+ my $type = $arg->{'type'};
+ if ($type eq 'def_name') {
$name = $arg;
- } elsif ($role eq 'class') {
+ } elsif ($type eq 'def_class') {
$class = $arg;
- } elsif ($role eq 'arg' or $role eq 'typearg'
- or $role eq 'delimiter') {
+ } elsif ($type eq 'def_arg' or $type eq 'def_typearg'
+ or $type eq 'delimiter') {
last;
}
}
diff --git a/tp/Texinfo/XS/main/convert_utils.c
b/tp/Texinfo/XS/main/convert_utils.c
index d3bb5ab835..b663eea67b 100644
--- a/tp/Texinfo/XS/main/convert_utils.c
+++ b/tp/Texinfo/XS/main/convert_utils.c
@@ -461,19 +461,16 @@ definition_arguments_content (const ELEMENT *element)
for (i = 0; i < def_line->contents.number; i++)
{
ELEMENT *arg = def_line->contents.list[i];
- char *role = lookup_extra_string (arg, "def_role");
- if (!role)
- fprintf (stderr, "BUG: NO ROLE %s\n", print_element_debug
(arg, 0));
- if (!strcmp (role, "class"))
+ if (arg->type == ET_def_class)
result->class = arg;
- else if (!strcmp (role, "category"))
+ else if (arg->type == ET_def_category)
result->category = arg;
- else if (!strcmp (role, "type"))
+ else if (arg->type == ET_def_type)
result->type = arg;
- else if (!strcmp (role, "name"))
+ else if (arg->type == ET_def_name)
result->name = arg;
- else if (!strcmp (role, "arg") || !strcmp (role, "typearg")
- || !strcmp (role, "delimiter"))
+ else if (arg->type == ET_def_arg || arg->type == ET_def_typearg
+ || arg->type == ET_delimiter)
{
i--;
break;
@@ -518,13 +515,12 @@ definition_category_tree (OPTIONS * options, const
ELEMENT *current)
for (i = 0; i < def_line->contents.number; i++)
{
ELEMENT *arg = def_line->contents.list[i];
- char *role = lookup_extra_string (arg, "def_role");
- if (!strcmp (role, "class"))
+ if (arg->type == ET_def_class)
arg_class = arg;
- else if (!strcmp (role, "category"))
+ else if (arg->type == ET_def_category)
arg_category = arg;
- else if (!strcmp (role, "arg") || !strcmp (role, "typearg")
- || !strcmp (role, "delimiter"))
+ else if (arg->type == ET_def_arg || arg->type == ET_def_typearg
+ || arg->type == ET_delimiter)
break;
}
}
diff --git a/tp/Texinfo/XS/parsetexi/indices.c
b/tp/Texinfo/XS/parsetexi/indices.c
index 82f183c0b2..d26bc311e1 100644
--- a/tp/Texinfo/XS/parsetexi/indices.c
+++ b/tp/Texinfo/XS/parsetexi/indices.c
@@ -418,14 +418,13 @@ complete_indices (int document_descriptor, int
debug_level)
for (ic = 0; ic < def_l_e->contents.number; ic++)
{
ELEMENT *arg = def_l_e->contents.list[ic];
- char *role = lookup_extra_string (arg, "def_role");
- if (!strcmp (role, "name"))
+ if (arg->type == ET_def_name)
name = arg;
- else if (!strcmp (role, "class"))
+ else if (arg->type == ET_def_class)
class = arg;
- else if (!strcmp (role, "arg")
- || !strcmp (role, "typearg")
- || !strcmp (role, "delimiter"))
+ else if (arg->type == ET_def_arg
+ || arg->type == ET_def_typearg
+ || arg->type == ET_delimiter)
break;
}
}