Skip to content

Commit e93462a

Browse files
committed
fix lints
Signed-off-by: Jack Luar <39641663+luarss@users.noreply.github.com>
1 parent 0fe6274 commit e93462a

4 files changed

Lines changed: 48 additions & 41 deletions

File tree

bazel/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ config_setting(
4949
filegroup(
5050
name = "pandoc",
5151
srcs = select({
52-
":_linux_x86_64": ["@pandoc_linux_amd64//:pandoc"],
5352
":_linux_aarch64": ["@pandoc_linux_arm64//:pandoc"],
54-
":_macos_x86_64": ["@pandoc_macos_x86_64//:pandoc"],
53+
":_linux_x86_64": ["@pandoc_linux_amd64//:pandoc"],
5554
":_macos_aarch64": ["@pandoc_macos_arm64//:pandoc"],
55+
":_macos_x86_64": ["@pandoc_macos_x86_64//:pandoc"],
5656
}),
5757
visibility = ["//visibility:public"],
5858
)

bazel/man_pages.bzl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,15 @@ man_pages = rule(
8787
doc = "Python scripts for man page generation.",
8888
allow_files = True,
8989
),
90-
"_pandoc": attr.label(
91-
default = "//bazel:pandoc",
92-
allow_single_file = True,
93-
cfg = "exec",
94-
),
9590
"_manpages_impl": attr.label(
9691
default = "//bazel:manpages_impl",
9792
executable = True,
9893
cfg = "exec",
9994
),
95+
"_pandoc": attr.label(
96+
default = "//bazel:pandoc",
97+
allow_single_file = True,
98+
cfg = "exec",
99+
),
100100
},
101101
)

bazel/manpages_impl.py

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -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

6970
def 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"),

pyproject.toml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
[tool.black]
2-
extend-exclude = '''
3-
^/third-party/
4-
'''
5-
force-exclude = '''
6-
^/third-party/
7-
'''
2+
extend-exclude = '^/third-party/'
3+
force-exclude = '^/third-party/'

0 commit comments

Comments
 (0)