3434
3535
3636def _run_pandoc (pandoc , src , dst , to_format ):
37+ """Run pandoc to convert *src* to *dst* using *to_format* writer."""
3738 subprocess .run (
3839 [pandoc , "-s" , "-t" , to_format , src , "-o" , dst , "--quiet" ],
3940 check = True ,
@@ -42,7 +43,12 @@ def _run_pandoc(pandoc, src, dst, to_format):
4243
4344def _process_section (pandoc , md_dir , roff_scratch , html_dir , cat_dir ,
4445 section_num , skip_stems = None ):
45- """Convert every .md in md_dir → roff → HTML + cat pages."""
46+ """Convert every .md in *md_dir* to roff, HTML, and cat pages.
47+
48+ Files whose stem (filename without .md) is in *skip_stems* are
49+ left alone — used to avoid re-converting module READMEs as if
50+ they were per-function man pages.
51+ """
4652 skip_stems = skip_stems or set ()
4753 for fname in sorted (os .listdir (md_dir )):
4854 if not fname .endswith (".md" ):
@@ -61,6 +67,12 @@ def _process_section(pandoc, md_dir, roff_scratch, html_dir, cat_dir,
6167
6268
6369def main ():
70+ """Orchestrate man page generation from the Bazel sandbox.
71+
72+ Mirrors the source tree layout that md_roff_compat.py expects,
73+ runs generation scripts, then converts all resulting markdown
74+ to roff / HTML / cat pages via pandoc.
75+ """
6476 p = argparse .ArgumentParser ()
6577 p .add_argument ("--pandoc" , required = True ,
6678 help = "Path to pandoc binary" )
@@ -111,7 +123,8 @@ def main():
111123 module , path = spec .split (":" , 1 )
112124 shutil .copy (path , os .path .join (man2_md , f"{ module } .md" ))
113125
114- # Copy messages.txt files next to each other as ../src/{module}/.
126+ # Copy each module's messages.txt to ../src/{module}/messages.txt
127+ # so md_roff_compat.py finds them relative to the docs/ directory.
115128 for spec in args .messages :
116129 module , path = spec .split (":" , 1 )
117130 mod_dir = os .path .join (workdir , "src" , module )
0 commit comments