Skip to content

Commit 0fe6274

Browse files
committed
docs: add missing docstrings and fix comments in manpage bazel files
- Add docstrings to _run_pandoc, _process_section, and main() - Document skip_stems parameter in _process_section - Clarify messages.txt copy comment - Fix capitalization in man_pages.bzl module docstring (html → HTML) Signed-off-by: Jack Luar <39641663+luarss@users.noreply.github.com>
1 parent 92a6752 commit 0fe6274

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

bazel/man_pages.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright (c) 2026, The OpenROAD Authors
33

4-
"""Hermetic Bazel rule that generates cat/ and html/ man pages.
4+
"""Hermetic Bazel rule that generates cat/ and HTML/ man pages.
55
66
All tools (pandoc, Python interpreter) and all inputs (README files,
77
messages.txt files, man1 source markdown, Python scripts) are declared

bazel/manpages_impl.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535

3636
def _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

4344
def _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

6369
def 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

Comments
 (0)