Re: [PATCH v7 04/17] tools: ynl_gen_rst.py: Split library from command line tool

Donald Hunter
2025-06-19T12:20:02Z

Mauro Carvalho Chehab <mchehab+huawei@kernel.org> writes:
> +
> + def generate_main_index_rst(self, output: str, index_dir: str) -> None:
> + """Generate the `networking_spec/index` content and write to the file"""
> + lines = []
> +
> + lines.append(self.fmt.rst_header())
> + lines.append(self.fmt.rst_label("specs"))
> + lines.append(self.fmt.rst_title("Netlink Family Specifications"))
> + lines.append(self.fmt.rst_toctree(1))
> +
> + index_fname = os.path.basename(output)
> + base, ext = os.path.splitext(index_fname)
> +
> + if not index_dir:
> + index_dir = os.path.dirname(output)
> +
> + logging.debug(f"Looking for {ext} files in %s", index_dir)
> + for filename in sorted(os.listdir(index_dir)):
> + if not filename.endswith(ext) or filename == index_fname:
> + continue
> + base, ext = os.path.splitext(filename)
> + lines.append(f" {base}\n")
> +
> + logging.debug("Writing an index file at %s", output)
> +
> + return "".join(lines)

Did you miss my comment on v5 to not move this from ynl_gen_rst.py,
since it is not needed and gets removed in a later patch.

> @@ -411,7 +65,6 @@ def write_to_rstfile(content: str, filename: str) -> None:
>
> def generate_main_index_rst(output: str) -> None:
> """Generate the `networking_spec/index` content and write to the file"""
> - lines = []
>
> lines.append(rst_header())
> lines.append(rst_label("specs"))
> @@ -426,7 +79,7 @@ def generate_main_index_rst(output: str) -> None:
> lines.append(f" {filename.replace('.rst', '')}\n")
>
> logging.debug("Writing an index file at %s", output)
> - write_to_rstfile("".join(lines), output)
> + write_to_rstfile(msg, output)

The changes leave this function broken. Bot lines and msg never get
defined.