linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] kernel-doc: rename the kernel-doc directive 'functions' to 'identifiers'
@ 2019-10-20 13:17 Changbin Du
  2019-10-24 18:19 ` Jonathan Corbet
  0 siblings, 1 reply; 9+ messages in thread
From: Changbin Du @ 2019-10-20 13:17 UTC (permalink / raw)
  To: Jonathan Corbet
  Cc: linux-pci, linux-doc, linux-kernel, linux-mm, linux-crypto,
	linux-kselftest, linux-wireless, linux-fpga, linux-usb,
	dri-devel, intel-gfx, Matthew Wilcox, jani.nikula,
	Thomas Zimmermann, Changbin Du

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>

---
v2:
  o use 'identifiers' as the new directive name.
---
 Documentation/doc-guide/kernel-doc.rst | 29 ++++++++++++++------------
 Documentation/sphinx/kerneldoc.py      | 19 ++++++++++-------
 2 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/Documentation/doc-guide/kernel-doc.rst b/Documentation/doc-guide/kernel-doc.rst
index 192c36af39e2..fff6604631ea 100644
--- a/Documentation/doc-guide/kernel-doc.rst
+++ b/Documentation/doc-guide/kernel-doc.rst
@@ -476,6 +476,22 @@ internal: *[source-pattern ...]*
     .. kernel-doc:: drivers/gpu/drm/i915/intel_audio.c
        :internal:
 
+identifiers: *[ function/type ...]*
+  Include documentation for each *function* and *type* in *source*.
+  If no *function* is specified, the documentation for all functions
+  and types in the *source* will be included.
+
+  Examples::
+
+    .. kernel-doc:: lib/bitmap.c
+       :identifiers: bitmap_parselist bitmap_parselist_user
+
+    .. kernel-doc:: lib/idr.c
+       :identifiers:
+
+functions: *[ function/type ...]*
+  This is an alias of the 'identifiers' directive and deprecated.
+
 doc: *title*
   Include documentation for the ``DOC:`` paragraph identified by *title* in
   *source*. Spaces are allowed in *title*; do not quote the *title*. The *title*
@@ -488,19 +504,6 @@ doc: *title*
     .. kernel-doc:: drivers/gpu/drm/i915/intel_audio.c
        :doc: High Definition Audio over HDMI and Display Port
 
-functions: *[ function ...]*
-  Include documentation for each *function* in *source*.
-  If no *function* is specified, the documentation for all functions
-  and types in the *source* will be included.
-
-  Examples::
-
-    .. kernel-doc:: lib/bitmap.c
-       :functions: bitmap_parselist bitmap_parselist_user
-
-    .. kernel-doc:: lib/idr.c
-       :functions:
-
 Without options, the kernel-doc directive includes all documentation comments
 from the source file.
 
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()
 
         for pattern in export_file_patterns:
             for f in glob.glob(env.config.kerneldoc_srctree + '/' + pattern):
                 env.note_dependency(os.path.abspath(f))
                 cmd += ['-export-file', f]
 
+        if identifiers:
+            for i in identifiers:
+                cmd += ['-function', i]
+        elif identifiers is not None:
+            cmd += ['-no-doc-sections']
+
         cmd += [filename]
 
         try:
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] kernel-doc: rename the kernel-doc directive 'functions' to 'identifiers'
  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
  0 siblings, 1 reply; 9+ messages in thread
From: Jonathan Corbet @ 2019-10-24 18:19 UTC (permalink / raw)
  To: Changbin Du
  Cc: linux-pci, linux-doc, linux-kernel, linux-mm, linux-crypto,
	linux-kselftest, linux-wireless, linux-fpga, linux-usb,
	dri-devel, intel-gfx, Matthew Wilcox, jani.nikula,
	Thomas Zimmermann

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 .

Thanks,

jon

>          for pattern in export_file_patterns:
>              for f in glob.glob(env.config.kerneldoc_srctree + '/' + pattern):
>                  env.note_dependency(os.path.abspath(f))
>                  cmd += ['-export-file', f]
>  
> +        if identifiers:
> +            for i in identifiers:
> +                cmd += ['-function', i]
> +        elif identifiers is not None:
> +            cmd += ['-no-doc-sections']
> +
>          cmd += [filename]
>  
>          try:

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] kernel-doc: rename the kernel-doc directive 'functions' to 'identifiers'
  2019-10-24 18:19 ` Jonathan Corbet
@ 2019-10-25  6:57   ` Jani Nikula
  2019-10-25 14:48     ` Changbin Du
  0 siblings, 1 reply; 9+ messages in thread
From: Jani Nikula @ 2019-10-25  6:57 UTC (permalink / raw)
  To: Jonathan Corbet, Changbin Du
  Cc: linux-pci, linux-doc, linux-kernel, linux-mm, linux-crypto,
	linux-kselftest, linux-wireless, linux-fpga, linux-usb,
	dri-devel, intel-gfx, Matthew Wilcox, Thomas Zimmermann

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")
            else:
                self.options.set('identifiers', self.options.get('functions'))

BR,
Jani.


-- 
Jani Nikula, Intel Open Source Graphics Center

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] kernel-doc: rename the kernel-doc directive 'functions' to 'identifiers'
  2019-10-25  6:57   ` Jani Nikula
@ 2019-10-25 14:48     ` Changbin Du
  2019-10-28  9:24       ` Jani Nikula
  0 siblings, 1 reply; 9+ messages in thread
From: Changbin Du @ 2019-10-25 14:48 UTC (permalink / raw)
  To: Jani Nikula
  Cc: Jonathan Corbet, Changbin Du, linux-pci, linux-doc, linux-kernel,
	linux-mm, linux-crypto, linux-kselftest, linux-wireless,
	linux-fpga, linux-usb, dri-devel, intel-gfx, Matthew Wilcox,
	Thomas Zimmermann

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.

>             else:
>                 self.options.set('identifiers', self.options.get('functions'))
> 
> BR,
> Jani.
>
After comparing, I still perfer my original code which is simpler. :)

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

-- 
Cheers,
Changbin Du

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] kernel-doc: rename the kernel-doc directive 'functions' to 'identifiers'
  2019-10-25 14:48     ` Changbin Du
@ 2019-10-28  9:24       ` Jani Nikula
  2019-10-29  0:31         ` Changbin Du
  0 siblings, 1 reply; 9+ messages in thread
From: Jani Nikula @ 2019-10-28  9:24 UTC (permalink / raw)
  To: Changbin Du
  Cc: Jonathan Corbet, Changbin Du, linux-pci, linux-doc, linux-kernel,
	linux-mm, linux-crypto, linux-kselftest, linux-wireless,
	linux-fpga, linux-usb, dri-devel, intel-gfx, Matthew Wilcox,
	Thomas Zimmermann

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?

>
>>             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.


BR,
Jani.



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

-- 
Jani Nikula, Intel Open Source Graphics Center

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] kernel-doc: rename the kernel-doc directive 'functions' to 'identifiers'
  2019-10-28  9:24       ` Jani Nikula
@ 2019-10-29  0:31         ` Changbin Du
  2019-10-29  5:42           ` Markus Heiser
  2019-10-29  8:00           ` Jonathan Corbet
  0 siblings, 2 replies; 9+ messages in thread
From: Changbin Du @ 2019-10-29  0:31 UTC (permalink / raw)
  To: Jani Nikula
  Cc: Changbin Du, Jonathan Corbet, linux-pci, linux-doc, linux-kernel,
	linux-mm, linux-crypto, linux-kselftest, linux-wireless,
	linux-fpga, linux-usb, dri-devel, intel-gfx, Matthew Wilcox,
	Thomas Zimmermann

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] kernel-doc: rename the kernel-doc directive 'functions' to 'identifiers'
  2019-10-29  0:31         ` Changbin Du
@ 2019-10-29  5:42           ` Markus Heiser
  2019-10-29  8:00           ` Jonathan Corbet
  1 sibling, 0 replies; 9+ messages in thread
From: Markus Heiser @ 2019-10-29  5:42 UTC (permalink / raw)
  To: Changbin Du, Jani Nikula
  Cc: Jonathan Corbet, linux-pci, linux-doc, linux-kernel, linux-mm,
	linux-crypto, linux-kselftest, linux-wireless, linux-fpga,
	linux-usb, dri-devel, intel-gfx, Matthew Wilcox,
	Thomas Zimmermann

Am 29.10.19 um 01:31 schrieb Changbin Du:
>> 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.

The one is a empty string str(''), its bool('') value is False.

| >>> type(''), bool('')
| (<class 'str'>, False)

The other is a NoneType, its bool(None) value is False.

| >>> type(None), bool(None)
| (<class 'NoneType'>, False)

None often used like NULL (pointer). E.g if a function does not give an explicit 
return value, the returned value is None.

| >>> def foo():
| ...     pass
| ...
| >>> print(foo())
| None


-- Markus --


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] kernel-doc: rename the kernel-doc directive 'functions' to 'identifiers'
  2019-10-29  0:31         ` Changbin Du
  2019-10-29  5:42           ` Markus Heiser
@ 2019-10-29  8:00           ` Jonathan Corbet
  2019-10-31 13:50             ` Changbin Du
  1 sibling, 1 reply; 9+ messages in thread
From: Jonathan Corbet @ 2019-10-29  8:00 UTC (permalink / raw)
  To: Changbin Du
  Cc: Jani Nikula, linux-pci, linux-doc, linux-kernel, linux-mm,
	linux-crypto, linux-kselftest, linux-wireless, linux-fpga,
	linux-usb, dri-devel, intel-gfx, Matthew Wilcox,
	Thomas Zimmermann

On Tue, 29 Oct 2019 08:31:22 +0800
Changbin Du <changbin.du@gmail.com> wrote:

> Here python is different from C. Both empty string and None are False in python.
> Note such condition is common in python.

Treating both as a False value is reasonably common.  Treating them
elsewhere in the same code block as separate values is less
so; that's the part I would prefer to avoid.

Thanks,

jon

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] kernel-doc: rename the kernel-doc directive 'functions' to 'identifiers'
  2019-10-29  8:00           ` Jonathan Corbet
@ 2019-10-31 13:50             ` Changbin Du
  0 siblings, 0 replies; 9+ messages in thread
From: Changbin Du @ 2019-10-31 13:50 UTC (permalink / raw)
  To: Jonathan Corbet
  Cc: Changbin Du, Jani Nikula, linux-pci, linux-doc, linux-kernel,
	linux-mm, linux-crypto, linux-kselftest, linux-wireless,
	linux-fpga, linux-usb, dri-devel, intel-gfx, Matthew Wilcox,
	Thomas Zimmermann

On Tue, Oct 29, 2019 at 02:00:27AM -0600, Jonathan Corbet wrote:
> On Tue, 29 Oct 2019 08:31:22 +0800
> Changbin Du <changbin.du@gmail.com> wrote:
> 
> > Here python is different from C. Both empty string and None are False in python.
> > Note such condition is common in python.
> 
> Treating both as a False value is reasonably common.  Treating them
> elsewhere in the same code block as separate values is less
> so; that's the part I would prefer to avoid.
>
ok, please check update in v3.

> Thanks,
> 
> jon

-- 
Cheers,
Changbin Du

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-10-31 13:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2019-10-29  5:42           ` Markus Heiser
2019-10-29  8:00           ` Jonathan Corbet
2019-10-31 13:50             ` Changbin Du

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).