All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Heiser <markus.heiser@darmarit.de>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Jonathan Corbet <corbet@lwn.net>
Cc: Jani Nikula <jani.nikula@intel.com>,
	ksummit-discuss@lists.linuxfoundation.org,
	ksummit@lists.linux.dev
Subject: Re: [Ksummit-discuss] [TECH TOPIC] What kernel documentation could be
Date: Fri, 24 Jun 2022 18:37:56 +0200	[thread overview]
Message-ID: <963dd061-47ba-6f96-72e2-4f34cc952b8c@darmarit.de> (raw)
In-Reply-To: <20220624083307.159824bd@sal.lan>

Hi Jon, Mauro,

   with great interest I have read this thread !

If I can help, I'm happy to participate again.  TBH: The kernel-doc
implementation from mine could only be a piece of the puzzle to
improve the process (not without raising other questions).

But similar to Jani, I see the priority problems on a different level
level.

We have too many demands that reach into the smallest niches.  I
believe that some parts must be generalized and some request must
be abandoned.

In my opinion, many problems are homemade, to take just one example:

IMO It is unnecessary that the build-chain must run on all
platforms and with all distributions.

Who observes the Sphinx-doc & docutils development since (>15)
years is aware that with various (old) Sphinx-doc & docutils
versions no stable results can be produced, not without
complicating the build-chain.  And this is exactly the situation
we are facing today.

The build chain of documentation has nothing to do with kernel
development (at least in my opinion) and should be decoupled from it:
maintaining one defined build environment is enough work ... this
becomes especially clear if you (as Jani recommends) rely more on
sphinx-modules and widely used tools.

Another point on which I now have a clear view are the regular
expressions: no one likes them (me too), but I can't think of a
general solution (parser) given the number of requirements for
parsing source code we have.

I would like to support the kernel community again, but at the
moment I have difficulties to follow the many exceptions. I would
be happy if you keep me in CC .. may be I find my place again
back in the kernel-doc development :-)

Thanks and with best regards

   -- Markus --


Am 24.06.22 um 09:33 schrieb Mauro Carvalho Chehab:
> Em Thu, 23 Jun 2022 07:40:45 -0600
> Jonathan Corbet <corbet@lwn.net> escreveu:
> 
>> Mauro Carvalho Chehab <mchehab@kernel.org> writes:
>>
>>>> The solution would be to finally convert the
>>>> script to a proper python Sphinx extension that can do caching. (This is
>>>> how it works in Hawkmoth, FWIW.)
>>
>> I've been pondering on this for a bit, and would like to do it, but I
>> don't know when I might find the time for it.
> 
> There is already a version of kernel-doc written in Python, made by
> Markus Heiser:
> 
> 	https://github.com/return42/linuxdoc/blob/master/linuxdoc/kernel_doc.py
> 
> It could be a starting point.
> 
>>> That's one solution, but see: there is already a python extension
>>> that currently calls kernel-doc everytime. It could, instead,
>>> cache the rst returned by its first run (or a parsed version of it)
>>> and use the cached results the other 3 times.
>>>
>>> Porting kernel-doc to python could be doable, but not trivial, due to several
>>> reasons:
>>>
>>> - it should keep running standalone, as otherwise debugging parsing issues
>>>    on kernel-doc would be a lot harder. In particular, kernel-doc --none is
>>>    really helpful to report kernel-doc tag errors;
>>
>> Yes, of course.  As Jani noted, that's just how you would do it, not a
>> problem.
>>
>>> - regressions will likely be introduced on a change like that;
>>
>> The nice thing is ... we already have a really nice regression test in
>> the form of the current docs build and diff.
> 
> True. We can test the results with both versions and even check how
> performance is affected.
> 
>>> - regular contributors to kernel-doc will need to ramp up with the newer
>>>    version;
>>
>> We have those?  That script is a nightmare and nobody goes near it if
>> they can possibly avoid it.  I would expect to have more contributors
>> with a decent Python version that doesn't include 25 years of regex
>> accretion.
> 
> Well, the kernel-doc version from Markus in python is ~23% bigger
> than our current kernel-doc. Granted, it could be due to comments and
> blank lines, but basically, the same regexes that are in perl would
> also be need to be replicated in python, as parsing a C code with
> regexes is not a trivial task.
> 
> So, in terms of complexity, I doubt much would change by porting it
> to python.
> 
> Now, one of the things that the kernel-doc does is that it has the
> parse code and the output logic, which actually has an an abstraction
> to let it to produce results on different formats (currently, none, man
> and rst - we dropped some other formats from it). This abstraction
> increases its complexity. This is something that doesn't need to be
> replicated on any ports.
> 
>>> - a port like that could increase the script run time, as the
>>>    optimizations and regular expressions there could behave different on
>>>    python.
>>
>> It could also decrease it by improving caching opportunities, getting
>> rid of a lot of fork()/exec() pairs and Perl interpreter startups, etc.
>>
>> I've actually, in a spare moment or two, been doing some profiling of
>> the kernel docs build and trying to track down the sources of the
>> slowness.  I am thinking that nearly 700 *million* calls to the iterator
>> for the C-domain symbol list might have something to do with it...
> 
> Wow, that's a lot!
> 
>>> True, but independently if the script would be rewritten in python or not,
>>> one way would be to enrich the 'DOCS:' kernel-doc tag in order to mention
>>> there the symbols that belong to each part of the document, e. g. something
>>> like:
>>>
>>> 	/**
>>> 	 * DOC: foo
>>> 	 *
>>> 	 * Some comments...
>>> 	 *
>>> 	 * symbols:
>>> 	 *     foo
>>> 	 *     bar
>>> 	 */
>>>
>>> One advantage is that all documentation will be on a single place,
>>> so hopefully it would be easier to maintain.
>>
>> I'm not quite sure I get this...you want to put the TOC tree in the
>> source comments?  This looks like the kind of thing that nobody ever
>> remembers to update, but maybe I'm missing something.
> 
> No, it won't generate a TOC tree. It would instead reorder how
> kernel-doc would output the symbols.
> 
> That's no different than what we have already at the .kernel-doc
> directives, e. g. it would be a replacement for:
> 
> 
> 	.. kernel-doc:: include/some_header.h
> 	   :doc: foo
> 
> 	.. kernel-doc:: include/some_header.h
> 	   :functions:
> 		foo
> 		bar
> 
> The problem we currently have is that the above pattern means that
> one or more .rst files would contain a list of symbols that are
> actually documented at some_header.h. People updating such file
> will very likely forget to update .rst files, leading to missing
> documentation. Also, the same symbol could be included on different
> .rst files.
> 
> I remember I had to fix myself duplicated symbols inclusion while
> trying to reduce the docs build time on a few *.h files that
> were included hundreds of times. I bet if someone checks again,
> duplicated inclusions of the same symbol and missed symbols that
> are documented on their sources, but aren't included at any .rst file.
> 
> Currently, detecting it is very hard, because the symbol lists
> are on different files and the same header are sometimes included
> on different rst files. By placing the symbol list inside the source
> file, it makes very simple for kernel-doc to check if all documented
> symbols are inside the "DOC:" markups, producing errors otherwise.
> 
> Regards,
> Mauro

  reply	other threads:[~2022-06-24 16:46 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-17 20:57 [TECH TOPIC] What kernel documentation could be Jonathan Corbet
2022-06-17 20:57 ` [Ksummit-discuss] " Jonathan Corbet
2022-06-17 21:48 ` Laurent Pinchart
2022-06-17 21:48   ` Laurent Pinchart
2022-06-27 15:18   ` Jonathan Corbet
2022-06-18  8:24 ` Mauro Carvalho Chehab
2022-06-18  8:24   ` Mauro Carvalho Chehab
2022-06-18 11:03   ` Miguel Ojeda
2022-06-18 11:16     ` Mauro Carvalho Chehab
2022-06-18 11:16       ` Mauro Carvalho Chehab
2022-06-18 14:37       ` Miguel Ojeda
2022-06-23  9:18   ` Jani Nikula
2022-06-23  9:57     ` Mauro Carvalho Chehab
2022-06-23 10:30       ` Jani Nikula
2022-06-23 13:40       ` Jonathan Corbet
2022-06-24  7:33         ` Mauro Carvalho Chehab
2022-06-24 16:37           ` Markus Heiser [this message]
2022-06-27 15:27             ` Jonathan Corbet
2022-06-27 15:31               ` Christoph Hellwig
2022-06-28  7:43               ` Mauro Carvalho Chehab
2022-06-28  7:57                 ` Geert Uytterhoeven
2022-06-28 11:01                   ` Mauro Carvalho Chehab
2022-07-02 12:43                     ` Stephen Rothwell
2022-06-24 22:57           ` Jonathan Corbet
2022-06-25  9:10             ` Mauro Carvalho Chehab
2022-06-25 14:00               ` Jonathan Corbet
2022-06-25 18:11                 ` Linus Torvalds
2022-06-26  7:55                   ` Mauro Carvalho Chehab
2022-06-26  9:26                     ` Mauro Carvalho Chehab
2022-06-26  9:53                     ` Mauro Carvalho Chehab
2022-06-27 15:28                       ` Liam Howlett
2022-06-27 15:54                         ` Christian Brauner
2022-06-27 16:27                         ` Mark Brown
2022-06-28 10:53                           ` Mauro Carvalho Chehab
2022-06-28 16:13                         ` Luck, Tony
2022-06-27 15:34                   ` Jonathan Corbet
2022-06-27 17:07                     ` Linus Torvalds
2022-07-01  8:48                       ` [PATCH 0/4] Address some issues with sphinx detection Mauro Carvalho Chehab
2022-07-01  8:48                         ` [PATCH 1/4] scripts: sphinx-pre-install: fix venv version check logic Mauro Carvalho Chehab
2022-07-01  8:48                         ` [PATCH 2/4] scripts: sphinx-pre-install: report broken venv Mauro Carvalho Chehab
2022-07-01  8:48                         ` [PATCH 3/4] scripts: sphinx-pre-install: check for PDF min version later on Mauro Carvalho Chehab
2022-07-01  8:48                         ` [PATCH 4/4] scripts: sphinx-pre-install: provide both venv and package installs Mauro Carvalho Chehab
2022-07-02 10:11                       ` [PATCH v2 0/5] Address some issues with sphinx detection Mauro Carvalho Chehab
2022-07-02 10:11                         ` [PATCH v2 1/5] scripts: sphinx-pre-install: fix venv version check logic Mauro Carvalho Chehab
2022-07-02 10:11                         ` [PATCH v2 2/5] scripts: sphinx-pre-install: report broken venv Mauro Carvalho Chehab
2022-07-02 10:11                         ` [PATCH v2 3/5] scripts: sphinx-pre-install: check for PDF min version later on Mauro Carvalho Chehab
2022-07-02 10:11                         ` [PATCH v2 4/5] scripts: sphinx-pre-install: provide both venv and package installs Mauro Carvalho Chehab
2022-07-02 10:11                         ` [PATCH v2 5/5] scripts: sphinx-pre-install: place a warning for Sphinx >= 3.0 Mauro Carvalho Chehab
2022-07-05  4:15                         ` [PATCH v2 0/5] Address some issues with sphinx detection Akira Yokosawa
2022-07-06 14:31                           ` Akira Yokosawa
2022-07-07 20:33                             ` Mauro Carvalho Chehab
2022-07-07 18:45                           ` Jonathan Corbet
2022-07-07 20:25                             ` Mauro Carvalho Chehab
2022-07-07 20:15                           ` Mauro Carvalho Chehab
2022-07-08 11:34                             ` Expectation to --no-pdf option (was Re: [PATCH v2 0/5] Address some issues with sphinx detection) Akira Yokosawa
2022-07-08 14:02                               ` Jonathan Corbet
2022-07-08 14:59                                 ` Mauro Carvalho Chehab
2022-07-08 15:27                                   ` Akira Yokosawa
2022-07-08 23:01                                     ` Akira Yokosawa
2022-07-09  7:59                                       ` Mauro Carvalho Chehab
2022-07-11 11:23                                         ` Akira Yokosawa
2022-08-01 23:30                         ` [PATCH v2 0/5] Address some issues with sphinx detection Tomasz Warniełło
2022-07-02 10:52                   ` [Ksummit-discuss] [TECH TOPIC] What kernel documentation could be Mauro Carvalho Chehab
2022-06-25 17:43 ` Steven Rostedt
2022-06-25 17:48   ` Laurent Pinchart

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=963dd061-47ba-6f96-72e2-4f34cc952b8c@darmarit.de \
    --to=markus.heiser@darmarit.de \
    --cc=corbet@lwn.net \
    --cc=jani.nikula@intel.com \
    --cc=ksummit-discuss@lists.linuxfoundation.org \
    --cc=ksummit@lists.linux.dev \
    --cc=mchehab@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.