@@ -41,8 +41,9 @@ def _run_pandoc(pandoc, src, dst, to_format):
4141 )
4242
4343
44- def _process_section (pandoc , md_dir , roff_scratch , html_dir , cat_dir ,
45- section_num , skip_stems = None ):
44+ def _process_section (
45+ pandoc , md_dir , roff_scratch , html_dir , cat_dir , section_num , skip_stems = None
46+ ):
4647 """Convert every .md in *md_dir* to roff, HTML, and cat pages.
4748
4849 Files whose stem (filename without .md) is in *skip_stems* are
@@ -59,11 +60,11 @@ def _process_section(pandoc, md_dir, roff_scratch, html_dir, cat_dir,
5960 src = os .path .join (md_dir , fname )
6061 roff = os .path .join (roff_scratch , f"{ stem } .{ section_num } " )
6162 _run_pandoc (pandoc , src , roff , "man" )
62- _run_pandoc (pandoc , roff ,
63- os .path .join (html_dir , f"{ stem } .html" ), "html" )
63+ _run_pandoc (pandoc , roff , os .path .join (html_dir , f"{ stem } .html" ), "html" )
6464 # pandoc plain replaces nroff -man | col -b
65- _run_pandoc (pandoc , roff ,
66- os .path .join (cat_dir , f"{ stem } .{ section_num } " ), "plain" )
65+ _run_pandoc (
66+ pandoc , roff , os .path .join (cat_dir , f"{ stem } .{ section_num } " ), "plain"
67+ )
6768
6869
6970def main ():
@@ -74,20 +75,30 @@ def main():
7475 to roff / HTML / cat pages via pandoc.
7576 """
7677 p = argparse .ArgumentParser ()
77- p .add_argument ("--pandoc" , required = True ,
78- help = "Path to pandoc binary" )
79- p .add_argument ("--script" , action = "append" , default = [],
80- help = "Python script path (may be repeated)" )
81- p .add_argument ("--readme" , action = "append" , default = [],
82- help = "module:path pairs for README.md files" )
83- p .add_argument ("--messages" , action = "append" , default = [],
84- help = "module:path pairs for messages.txt files" )
85- p .add_argument ("--man1-src" , action = "append" , default = [],
86- help = "man1 source .md files" )
87- p .add_argument ("--cat-out" , required = True ,
88- help = "Output directory for cat pages" )
89- p .add_argument ("--html-out" , required = True ,
90- help = "Output directory for html pages" )
78+ p .add_argument ("--pandoc" , required = True , help = "Path to pandoc binary" )
79+ p .add_argument (
80+ "--script" ,
81+ action = "append" ,
82+ default = [],
83+ help = "Python script path (may be repeated)" ,
84+ )
85+ p .add_argument (
86+ "--readme" ,
87+ action = "append" ,
88+ default = [],
89+ help = "module:path pairs for README.md files" ,
90+ )
91+ p .add_argument (
92+ "--messages" ,
93+ action = "append" ,
94+ default = [],
95+ help = "module:path pairs for messages.txt files" ,
96+ )
97+ p .add_argument (
98+ "--man1-src" , action = "append" , default = [], help = "man1 source .md files"
99+ )
100+ p .add_argument ("--cat-out" , required = True , help = "Output directory for cat pages" )
101+ p .add_argument ("--html-out" , required = True , help = "Output directory for html pages" )
91102 args = p .parse_args ()
92103
93104 with tempfile .TemporaryDirectory () as workdir :
@@ -135,16 +146,13 @@ def main():
135146 # we can skip them when running pandoc (they're module-level READMEs,
136147 # not individual function man pages).
137148 readme_stems = {
138- os .path .splitext (f )[0 ]
139- for f in os .listdir (man2_md )
140- if f .endswith (".md" )
149+ os .path .splitext (f )[0 ] for f in os .listdir (man2_md ) if f .endswith (".md" )
141150 }
142151
143152 # Run md_roff_compat.py from docs_dir so its relative paths
144153 # (./md/man2, ../src) resolve correctly.
145154 subprocess .run (
146- [sys .executable ,
147- os .path .join (scripts_dir , "md_roff_compat.py" )],
155+ [sys .executable , os .path .join (scripts_dir , "md_roff_compat.py" )],
148156 cwd = docs_dir ,
149157 env = {** os .environ , "PYTHONPATH" : scripts_dir },
150158 check = True ,
@@ -161,7 +169,8 @@ def main():
161169
162170 # man1: straight from source .md files
163171 _process_section (
164- pandoc , man1_md ,
172+ pandoc ,
173+ man1_md ,
165174 os .path .join (roff_scratch , "man1" ),
166175 os .path .join (html_out , "html1" ),
167176 os .path .join (cat_out , "cat1" ),
@@ -170,7 +179,8 @@ def main():
170179
171180 # man2: only the per-function files generated by md_roff_compat.py
172181 _process_section (
173- pandoc , man2_md ,
182+ pandoc ,
183+ man2_md ,
174184 os .path .join (roff_scratch , "man2" ),
175185 os .path .join (html_out , "html2" ),
176186 os .path .join (cat_out , "cat2" ),
@@ -180,7 +190,8 @@ def main():
180190
181191 # man3: all files written to man3 (messages-derived pages)
182192 _process_section (
183- pandoc , man3_md ,
193+ pandoc ,
194+ man3_md ,
184195 os .path .join (roff_scratch , "man3" ),
185196 os .path .join (html_out , "html3" ),
186197 os .path .join (cat_out , "cat3" ),
0 commit comments