Re: [PATCH v2 06/12] scripts: lib: netlink_yml_parser.py: use classes

Mauro Carvalho Chehab <[email protected]>
Newsgroups dev.linux.lists.lkmm,dev.linux.lists.linux-kernel-mentees,org.kernel.vger.linux-doc,org.kernel.vger.linux-kernel,org.kernel.vger.netdev
Message-ID <[email protected]>
Em Fri, 13 Jun 2025 12:20:33 +0100
Donald Hunter <[email protected]> escreveu:

> Mauro Carvalho Chehab <[email protected]> writes:
> 
> > As we'll be importing netlink parser into a Sphinx extension,
> > move all functions and global variables inside two classes:
> >
> > - RstFormatters, containing ReST formatter logic, which are
> >   YAML independent;
> > - NetlinkYamlParser: contains the actual parser classes. That's
> >   the only class that needs to be imported by the script or by
> >   a Sphinx extension.  
> 
> I suggest a third class for the doc generator that is separate from the
> yaml parsing.

Do you mean moving those two (or three? [*]) methods to a new class?

    def parse_yaml(self, obj: Dict[str, Any]) -> str:
    def parse_yaml_file(self, filename: str) -> str:
    def generate_main_index_rst(self, output: str, index_dir: str) -> None:

Also, how should I name it to avoid confusion with NetlinkYamlParser? 
Maybe YnlParser?

[*] generate_main_index_rst is probably deprecated. eventually
    we may drop it or keep it just at the command line stript.

> The yaml parsing should really be refactored to reuse
> tools/net/ynl/pyynl/lib/nlspec.py at some point.

Makes sense, but such change is out of the scope of this series.

> > With that, we won't pollute Sphinx namespace, avoiding any
> > potential clashes.
> >
> > Signed-off-by: Mauro Carvalho Chehab <[email protected]>  

Thanks,
Mauro
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.