Re: [PATCH v5 10/15] docs: sphinx: add a parser for yaml files for Netlink specs

Mauro Carvalho Chehab
2025-06-18T08:21:12Z

Em Tue, 17 Jun 2025 18:23:22 +0100
Donald Hunter <donald.hunter@gmail.com> escreveu:

> On Tue, 17 Jun 2025 at 17:00, Mauro Carvalho Chehab
> <mchehab+huawei@kernel.org> wrote:
> > >
> > > (2) is cleaner and faster, but (1) is easier to implement on an
> > > already-existing code.
> >
> > The logic below implements (1). This seems to be the easiest way for
> > pyyaml. I will submit as 2 separate patches at the end of the next
> > version.
> >
> > Please notice that I didn't check yet for the "quality" of the
> > line numbers. Some tweaks could be needed later on.
>
> Thanks for working on this. I suppose we might be able to work on an
> evolution from (1) to (2) in a followup piece of work?

Yes, it shouldn't be hard for you to migrate to (2) in the future.

Currently, the parser is stateless, but, as there's now a class,
IMO the best would be to store the lines as an array of tuples
inside the YnlDocGenerator class, like this:

self.lines = [
(line_number1, message_string1),
(line_number2, message_string2),
(line_number3, message_string3),
(line_number4, message_string4),
...
]

This way, the parse_yaml_file() method would just return self.lines.

Thanks,
Mauro