linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Changbin Du <changbin.du@gmail.com>
To: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Changbin Du <changbin.du@gmail.com>,
	Jonathan Corbet <corbet@lwn.net>,
	linux-pci@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	linux-crypto@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-wireless@vger.kernel.org, linux-fpga@vger.kernel.org,
	linux-usb@vger.kernel.org, dri-devel@lists.freedesktop.org,
	intel-gfx@lists.freedesktop.org,
	Matthew Wilcox <willy@infradead.org>,
	Thomas Zimmermann <tzimmermann@suse.de>
Subject: Re: [PATCH v2] kernel-doc: rename the kernel-doc directive 'functions' to 'identifiers'
Date: Tue, 29 Oct 2019 08:31:22 +0800	[thread overview]
Message-ID: <20191029003120.llve32crfw63ovpw@mail.google.com> (raw)
In-Reply-To: <87v9s99q9l.fsf@intel.com>

On Mon, Oct 28, 2019 at 11:24:22AM +0200, Jani Nikula wrote:
> On Fri, 25 Oct 2019, Changbin Du <changbin.du@gmail.com> wrote:
> > On Fri, Oct 25, 2019 at 09:57:48AM +0300, Jani Nikula wrote:
> >> On Thu, 24 Oct 2019, Jonathan Corbet <corbet@lwn.net> wrote:
> >> > On Sun, 20 Oct 2019 21:17:17 +0800
> >> > Changbin Du <changbin.du@gmail.com> wrote:
> >> >
> >> >> The 'functions' directive is not only for functions, but also works for
> >> >> structs/unions. So the name is misleading. This patch renames it to
> >> >> 'identifiers', which specific the functions/types to be included in
> >> >> documentation. We keep the old name as an alias of the new one before
> >> >> all documentation are updated.
> >> >> 
> >> >> Signed-off-by: Changbin Du <changbin.du@gmail.com>
> >> >
> >> > So I think this is basically OK, but I have one more request...
> >> >
> >> > [...]
> >> >
> >> >> diff --git a/Documentation/sphinx/kerneldoc.py b/Documentation/sphinx/kerneldoc.py
> >> >> index 1159405cb920..0689f9c37f1e 100644
> >> >> --- a/Documentation/sphinx/kerneldoc.py
> >> >> +++ b/Documentation/sphinx/kerneldoc.py
> >> >> @@ -59,9 +59,10 @@ class KernelDocDirective(Directive):
> >> >>      optional_arguments = 4
> >> >>      option_spec = {
> >> >>          'doc': directives.unchanged_required,
> >> >> -        'functions': directives.unchanged,
> >> >>          'export': directives.unchanged,
> >> >>          'internal': directives.unchanged,
> >> >> +        'identifiers': directives.unchanged,
> >> >> +        'functions': directives.unchanged,  # alias of 'identifiers'
> >> >>      }
> >> >>      has_content = False
> >> >>  
> >> >> @@ -71,6 +72,7 @@ class KernelDocDirective(Directive):
> >> >>  
> >> >>          filename = env.config.kerneldoc_srctree + '/' + self.arguments[0]
> >> >>          export_file_patterns = []
> >> >> +        identifiers = None
> >> >>  
> >> >>          # Tell sphinx of the dependency
> >> >>          env.note_dependency(os.path.abspath(filename))
> >> >> @@ -86,19 +88,22 @@ class KernelDocDirective(Directive):
> >> >>              export_file_patterns = str(self.options.get('internal')).split()
> >> >>          elif 'doc' in self.options:
> >> >>              cmd += ['-function', str(self.options.get('doc'))]
> >> >> +        elif 'identifiers' in self.options:
> >> >> +            identifiers = self.options.get('identifiers').split()
> >> >>          elif 'functions' in self.options:
> >> >> -            functions = self.options.get('functions').split()
> >> >> -            if functions:
> >> >> -                for f in functions:
> >> >> -                    cmd += ['-function', f]
> >> >> -            else:
> >> >> -                cmd += ['-no-doc-sections']
> >> >> +            identifiers = self.options.get('functions').split()
> >> >
> >> > Rather than do this, can you just change the elif line to read:
> >> >
> >> >     elif ('identifiers' in self.options) or ('functions' in self.options):
> >> >
> >> > ...then leave the rest of the code intact?  It keeps the logic together,
> >> > and avoids the confusing distinction between identifiers=='' and
> >> > identifiers==None .
> >> 
> >> I think the problem is you still need to distinguish between the two for
> >> the get('functions') part.
> >> 
> >> One option is to rename 'functions' to 'identifiers' in the above block,
> >> and put something like this above the whole if ladder (untested):
> >> 
> >>         # backward compat
> >>         if 'functions' in self.options:
> >>             if 'identifiers' in self.options:
> >>                 kernellog.warn(env.app, "fail")
> > This will miss the content of 'functions' directive if both exist in
> > same doc.
> 
> Did you not notice your patch does the same, except silently, while this
> would produce a warning? Which one is less surprising?
>
yes, my mistake. Mine does the same thing.

> >
> >>             else:
> >>                 self.options.set('identifiers', self.options.get('functions'))
> >> 
> >> BR,
> >> Jani.
> >>
> > After comparing, I still perfer my original code which is simpler. :)
> 
> But is it, really? I agree with Jon about the distinction between None
> and '' being confusing.
>
Here python is different from C. Both empty string and None are False in python.
Note such condition is common in python.

Again, I am ok with both.

> 
> BR,
> Jani.
> 
> 
> 
> >
> >> 
> >> -- 
> >> Jani Nikula, Intel Open Source Graphics Center
> 
> -- 
> Jani Nikula, Intel Open Source Graphics Center

-- 
Cheers,
Changbin Du

  reply	other threads:[~2019-10-29  0:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-20 13:17 [PATCH v2] kernel-doc: rename the kernel-doc directive 'functions' to 'identifiers' Changbin Du
2019-10-24 18:19 ` Jonathan Corbet
2019-10-25  6:57   ` Jani Nikula
2019-10-25 14:48     ` Changbin Du
2019-10-28  9:24       ` Jani Nikula
2019-10-29  0:31         ` Changbin Du [this message]
2019-10-29  5:42           ` Markus Heiser
2019-10-29  8:00           ` Jonathan Corbet
2019-10-31 13:50             ` Changbin Du

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=20191029003120.llve32crfw63ovpw@mail.google.com \
    --to=changbin.du@gmail.com \
    --cc=corbet@lwn.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fpga@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=tzimmermann@suse.de \
    --cc=willy@infradead.org \
    /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).