Re: [PATCH 04/36] mutex, futex: adjust kernel-doc markups to generate ReST

From: Mauro Carvalho Chehab
Date: Mon May 15 2017 - 05:01:10 EST


Em Mon, 15 May 2017 09:03:48 +0200
Peter Zijlstra <peterz@xxxxxxxxxxxxx> escreveu:

> On Fri, May 12, 2017 at 03:19:17PM -0700, Darren Hart wrote:
> > On Sat, May 13, 2017 at 12:11:09AM +0200, Peter Zijlstra wrote:
>
> > > And I really _really_ hate to see that rest crap spread here. Can't we
> > > just delete all that nonsense and go back to 80 column 7bit ASCII ?
> > >
> >
> > Depending on the source this could be a genuine appeal or satire.... :-D
>
> A bit of both of course ;-)
>
> > In this case, I don't think the ReST changes (with -) make the comment block any
> > less readable in the C files.
> >
> > > It is an incentive not to use kerneldoc..
> > >
> >
> > I like the kerneldoc if for no other reason that it helps keeps formatting
> > consistent. I would object if I started seeing XML or some other horrible
> > formatting style showing up in the code, but this honestly seems like a fairly
> > minimal imposition... but that's me.
>
> Well, I don't mind the '-' thing before return values too much, but the
> below chunk is just pure drivel. It makes a perfectly good comment
> worse.
>
> --- a/kernel/locking/mutex.c
> +++ b/kernel/locking/mutex.c
> @@ -227,9 +227,11 @@ static void __sched __mutex_lock_slowpath(struct mutex *lock);
> * (or statically defined) before it can be locked. memset()-ing
> * the mutex to 0 is not allowed.
> *
> - * ( The CONFIG_DEBUG_MUTEXES .config option turns on debugging
> + * .. note::
> + *
> + * The CONFIG_DEBUG_MUTEXES .config option turns on debugging
> * checks that will enforce the restrictions and will also do
> - * deadlock debugging. )
> + * deadlock debugging.
> *
> * This function is similar to (but not equivalent to) down().
> */

What caused problems with the orignal markup is that Sphinx is
highly oriented by indentation: different indentation levels on
it cause troubles. A minimal change for it to be parsed would as
expected would be to remove the extra spaces that caused Sphinx
to misinterpret the paragraph, e. g.:

* ( The CONFIG_DEBUG_MUTEXES .config option turns on debugging
* checks that will enforce the restrictions and will also do
* deadlock debugging. )

But, if the intention of that spaces were to highlight the content
inside the parenthesis (with is what I assumed), then the
.. note markup will do the job.

That's said, I guess it shouldn't be hard to add something at
kernel-doc script to convert some specially-crafted tag (like "Note:")
to avoid having ReST notation for this specific case, e. g.:

* Note:
*
* The CONFIG_DEBUG_MUTEXES .config option turns on debugging
* checks that will enforce the restrictions and will also do
* deadlock debugging.

Yet, IMHO, we should take some care to avoid adding much
translations to it, as, otherwise, we'll end by having two
markup languages instead of just one.

Thanks,
Mauro