Skip to content

Commit 70f0193

Browse files
behdadclaude
andcommitted
gen-hb-docs.py: require an explicit sections.txt path
build.sh is the only caller and always passes the path; drop the $HB_SRC / ./harfbuzz / ~/harfbuzz autodetection so there's just one code path to reason about. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d4ab23f commit 70f0193

File tree

1 file changed

+5
-23
lines changed

1 file changed

+5
-23
lines changed

scripts/gen-hb-docs.py

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
"""Regenerate js/hb-docs.js from harfbuzz's docs/harfbuzz-sections.txt.
33
44
Usage:
5-
scripts/gen-hb-docs.py [PATH_TO_harfbuzz-sections.txt]
6-
7-
If no path is given, the script auto-detects the HarfBuzz source
8-
tree the same way scripts/build.sh does: $HB_SRC, then
9-
./harfbuzz/ next to this repo, then ~/harfbuzz.
5+
scripts/gen-hb-docs.py PATH_TO_harfbuzz-sections.txt
106
"""
117
import os
128
import re
@@ -15,19 +11,6 @@
1511
HERE = os.path.dirname (os.path.dirname (os.path.abspath (__file__)))
1612

1713

18-
def find_sections_txt ():
19-
env = os.environ.get ("HB_SRC")
20-
candidates = []
21-
if env:
22-
candidates.append (os.path.join (env, "docs", "harfbuzz-sections.txt"))
23-
candidates.append (os.path.join (HERE, "harfbuzz", "docs", "harfbuzz-sections.txt"))
24-
candidates.append (os.path.expanduser ("~/harfbuzz/docs/harfbuzz-sections.txt"))
25-
for c in candidates:
26-
if os.path.isfile (c):
27-
return c
28-
return None
29-
30-
3114
def parse (path):
3215
"""Yield (symbol, section) pairs.
3316
@@ -60,13 +43,12 @@ def parse (path):
6043

6144

6245
def main (argv):
63-
if len (argv) > 2:
46+
if len (argv) != 2:
6447
print (__doc__, file = sys.stderr)
6548
return 2
66-
sections_txt = argv[1] if len (argv) == 2 else find_sections_txt ()
67-
if not sections_txt or not os.path.isfile (sections_txt):
68-
print ("error: cannot find harfbuzz-sections.txt", file = sys.stderr)
69-
print (" set HB_SRC=/path/to/harfbuzz or pass the path", file = sys.stderr)
49+
sections_txt = argv[1]
50+
if not os.path.isfile (sections_txt):
51+
print ("error: %s: no such file" % sections_txt, file = sys.stderr)
7052
return 1
7153

7254
pairs = list (parse (sections_txt))

0 commit comments

Comments
 (0)