|
2 | 2 | """Regenerate js/hb-docs.js from harfbuzz's docs/harfbuzz-sections.txt. |
3 | 3 |
|
4 | 4 | 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 |
10 | 6 | """ |
11 | 7 | import os |
12 | 8 | import re |
|
15 | 11 | HERE = os.path.dirname (os.path.dirname (os.path.abspath (__file__))) |
16 | 12 |
|
17 | 13 |
|
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 | | - |
31 | 14 | def parse (path): |
32 | 15 | """Yield (symbol, section) pairs. |
33 | 16 |
|
@@ -60,13 +43,12 @@ def parse (path): |
60 | 43 |
|
61 | 44 |
|
62 | 45 | def main (argv): |
63 | | - if len (argv) > 2: |
| 46 | + if len (argv) != 2: |
64 | 47 | print (__doc__, file = sys.stderr) |
65 | 48 | 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) |
70 | 52 | return 1 |
71 | 53 |
|
72 | 54 | pairs = list (parse (sections_txt)) |
|
0 commit comments