linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: Jonathan Corbet <corbet@lwn.net>
Cc: Linux Doc Mailing List <linux-doc@vger.kernel.org>,
	Changbin Du <changbin.du@intel.com>,
	linux-kernel@vger.kernel.org,
	Markus Heiser <markus.heiser@darmarit.de>
Subject: Re: [PATCH] scripts: kernel-doc: allow passing desired Sphinx C domain dialect
Date: Mon, 12 Oct 2020 14:27:50 +0200	[thread overview]
Message-ID: <20201012142750.5073109a@coco.lan> (raw)
In-Reply-To: <20201006080134.07d94d26@lwn.net>

Em Tue, 6 Oct 2020 08:01:34 -0600
Jonathan Corbet <corbet@lwn.net> escreveu:

> On Tue, 6 Oct 2020 08:42:07 +0200
> Mauro Carvalho Chehab <mchehab+huawei@kernel.org> wrote:
> 
> > As right now we don't support Sphinx version 3.0[1], we're actually using just
> > $sphinx_major. So, I'm wonder if it would make sense to also make <minor>
> > optional.  
> 
> Maybe...someday we may need it, knowing how the Sphinx folks approach
> compatibility, but I guess we can always add it then if so.
> 
> > The change would be trivial, although the regex will become even more
> > harder to read ;-)  
> 
> 	^(\d+)(\.(\d+)){,2}
> 
> ?  (untested, of course)

Didn't work (perl complains about its syntax), and neither:

	^(\d+)(\.(\d+)){0,2}

I also tried this:

	^(\d+)(?:\.(\d+)){0,2}

But both ends misplacing the second group information when
x.y.z is used.

On the tests I did, this is the one that worked fine:

	if ($ver_string =~ m/^(\d+)(?:\.(\d+))?(?:\.(\d+))?/) {
	    $sphinx_major = $1;
	    if (defined($2)) {
		$sphinx_minor = $2;
	    } else {
		$sphinx_minor = 0;
	    }
	    if (defined($3)) {
		$sphinx_patch = $3
	    } else {
		$sphinx_patch = 0;
	    }

Or the alternative one, using substrings:

	if ($ver_string =~ m/^(\d+)(\.\d+)?(\.\d+)?/) {
	    $sphinx_major = $1;
	    if (defined($2)) {
		$sphinx_minor = substr($2,1);
	    } else {
		$sphinx_minor = 0;
	    }
	    if (defined($3)) {
		$sphinx_patch = substr($3,1)
	    } else {
		$sphinx_patch = 0;
	    }
	}

I'll keep the last one, as it is likely simpler to understand.

> 
> > [1] not sure how valuable would be adding support for Sphinx 3.0. While
> > I didn't make any tests, I'm strongly suspecting that, with the approach
> > we took for backward/forward compatibility, adding support for it
> > would mean to just do a trivial change at cdomain.py by applying a
> > patch that Markus did replacing a regex function that doesn't exist
> > anymore at Sphinx API and emulating C namespace with the logic I
> > already implemented.   
> 
> 3.0 might just be skippable at this point, methinks.  

Yeah, agreed. 

I'll fold the latest version of this patch with the following diff.

Thanks,
Mauro

index 297312824d26..c8f6b11d5da1 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -466,11 +466,15 @@ while ($ARGV[0] =~ m/^--?(.*)/) {
 	$show_not_found = 1;  # A no-op but don't fail
     } elsif ($cmd eq "sphinx-version") {
 	my $ver_string = shift @ARGV;
-	if ($ver_string =~ m/^(\d+)\.(\d+)(\.\d+)?/) {
+	if ($ver_string =~ m/^(\d+)(\.\d+)?(\.\d+)?/) {
 	    $sphinx_major = $1;
-	    $sphinx_minor = $2;
+	    if (defined($2)) {
+		$sphinx_minor = substr($2,1);
+	    } else {
+		$sphinx_minor = 0;
+	    }
 	    if (defined($3)) {
-		$sphinx_patch = substr($3,1);
+		$sphinx_patch = substr($3,1)
 	    } else {
 		$sphinx_patch = 0;
 	    }
@@ -2368,7 +2372,10 @@ sub process_file($) {
 }
 
 
-get_sphinx_version() if (!$sphinx_major);
+if ($output_mode eq "rst") {
+	get_sphinx_version() if (!$sphinx_major);
+}
+
 $kernelversion = get_kernel_version();
 
 # generate a sequence of code that will splice in highlighting information



      parent reply	other threads:[~2020-10-12 12:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-04  8:02 [PATCH] scripts: kernel-doc: allow passing desired Sphinx C domain dialect Mauro Carvalho Chehab
2020-10-05 16:17 ` Jonathan Corbet
2020-10-06  6:42   ` Mauro Carvalho Chehab
2020-10-06  7:34     ` Joe Perches
2020-10-06 14:01     ` Jonathan Corbet
2020-10-06 16:53       ` Joe Perches
2020-10-12 12:27       ` Mauro Carvalho Chehab [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201012142750.5073109a@coco.lan \
    --to=mchehab+huawei@kernel.org \
    --cc=changbin.du@intel.com \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markus.heiser@darmarit.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).