diff mbox

[4/5] texi2pod: learn quotation, deftp and deftypefn

Message ID 1435917064-17827-5-git-send-email-marcandre.lureau@redhat.com
State New
Headers show

Commit Message

Marc-André Lureau July 3, 2015, 9:51 a.m. UTC
From: Marc-André Lureau <marcandre.lureau@gmail.com>

Learn a few more markups used for API documentation.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 scripts/texi2pod.pl | 44 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)

Comments

Markus Armbruster Sept. 8, 2015, 11:45 a.m. UTC | #1
Marc-André Lureau <marcandre.lureau@redhat.com> writes:

> From: Marc-André Lureau <marcandre.lureau@gmail.com>
>
> Learn a few more markups used for API documentation.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

I believe texi2pod.pl was originally stolen, most likely from GCC.  Have
you checked its current status there?

https://gcc.gnu.org/git/?p=gcc.git;a=history;f=contrib/texi2pod.pl;h=91bdbb5cea933d0381f2924ab94490fca31d5800;hb=HEAD

Should we steal the current version, then apply our own hacks (if any)
on top?
Peter Maydell Sept. 8, 2015, 12:08 p.m. UTC | #2
On 8 September 2015 at 12:45, Markus Armbruster <armbru@redhat.com> wrote:
> I believe texi2pod.pl was originally stolen, most likely from GCC.  Have
> you checked its current status there?
>
> https://gcc.gnu.org/git/?p=gcc.git;a=history;f=contrib/texi2pod.pl;h=91bdbb5cea933d0381f2924ab94490fca31d5800;hb=HEAD
>
> Should we steal the current version, then apply our own hacks (if any)
> on top?

The current version is GPLv3, so I don't think we should.

-- PMM
Markus Armbruster Sept. 8, 2015, 12:51 p.m. UTC | #3
Peter Maydell <peter.maydell@linaro.org> writes:

> On 8 September 2015 at 12:45, Markus Armbruster <armbru@redhat.com> wrote:
>> I believe texi2pod.pl was originally stolen, most likely from GCC.  Have
>> you checked its current status there?
>>
>> https://gcc.gnu.org/git/?p=gcc.git;a=history;f=contrib/texi2pod.pl;h=91bdbb5cea933d0381f2924ab94490fca31d5800;hb=HEAD
>>
>> Should we steal the current version, then apply our own hacks (if any)
>> on top?
>
> The current version is GPLv3, so I don't think we should.

You're right.

What about the latest version still under GPLv2+:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=e3d2159eb818033b6e7590ce894cc8f964f3bcd0
diff mbox

Patch

diff --git a/scripts/texi2pod.pl b/scripts/texi2pod.pl
index 94097fb..3590a2d 100755
--- a/scripts/texi2pod.pl
+++ b/scripts/texi2pod.pl
@@ -37,6 +37,7 @@  $inf = "";
 $ibase = "";
 @ipath = ();
 $encoding = undef;
+@args = ();
 
 while ($_ = shift) {
     if (/^-D(.*)$/) {
@@ -162,7 +163,8 @@  while(<$inf>) {
 	if ($ended =~ /^(?:ifset|ifclear|ignore|menu|iftex)$/) {
 	    $skipping = pop @skstack;
 	    next;
-	} elsif ($ended =~ /^(?:example|smallexample|display)$/) {
+	} elsif ($ended =~ /^(?:example|smallexample|display
+                            |quotation|deftp|deftypefn)$/x) {
 	    $shift = "";
 	    $_ = "";	# need a paragraph break
 	} elsif ($ended =~ /^(?:itemize|enumerate|[fv]?table)$/) {
@@ -323,6 +325,46 @@  while(<$inf>) {
 	$_ = "\n=item ".join (" : ", @columns)."\n";
     };
 
+    /^\@(quotation)\s*(.+)?$/ and do {
+        push @endwstack, $endw;
+        $endw = $1;
+        $_ = "\n$2:"
+    };
+
+    /^{(.*)}$|^(.*)$/ and $#args > 0 and do {
+        $kind = $args[0];
+        $arguments = $1 // "";
+        if ($endw eq "deftypefn") {
+            $ret = $args[1];
+            $fname = "B<$args[2]>";
+            $_ = $ret ? "$ret " : "";
+            $_ .= "$fname $arguments ($kind)";
+        } else {
+            $_ = "B<$args[1]> ($kind)\n\n$arguments";
+        }
+        @args = ();
+    };
+
+    /^\@(deftp)\s*(.+)?$/ and do {
+        push @endwstack, $endw;
+        $endw = $1;
+        $arg = $2;
+        $arg =~ s/{([^}]*)}/$1/g;
+        $arg =~ s/\@$//;
+        @args = split (/ /, $arg);
+        $_ = "";
+    };
+
+    /^\@(deftypefn)\s*(.+)?$/ and do {
+        push @endwstack, $endw;
+        $endw = $1;
+        $arg = $2;
+        $arg =~ s/{([^}]*)}/$1/g;
+        $arg =~ s/\@$//;
+        @args = split (/ /, $arg);
+        $_ = "";
+    };
+
     /^\@itemx?\s*(.+)?$/ and do {
 	if (defined $1) {
 	    # Entity escapes prevent munging by the <> processing below.