minor, move scripts manuals to __doc__

This commit is contained in:
Ebrahim Byagowi 2020-05-28 15:01:15 +04:30
parent 593e58c842
commit 08f1d95a50
11 changed files with 66 additions and 42 deletions

View File

@ -1,15 +1,17 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import io, os.path, sys """usage: ./gen-arabic-table.py ArabicShaping.txt UnicodeData.txt Blocks.txt
if len (sys.argv) != 4:
print ("""usage: ./gen-arabic-table.py ArabicShaping.txt UnicodeData.txt Blocks.txt
Input files: Input files:
* https://unicode.org/Public/UCD/latest/ucd/ArabicShaping.txt * https://unicode.org/Public/UCD/latest/ucd/ArabicShaping.txt
* https://unicode.org/Public/UCD/latest/ucd/UnicodeData.txt * https://unicode.org/Public/UCD/latest/ucd/UnicodeData.txt
* https://unicode.org/Public/UCD/latest/ucd/Blocks.txt * https://unicode.org/Public/UCD/latest/ucd/Blocks.txt
""", file=sys.stderr) """
import io, os.path, sys
if len (sys.argv) != 4:
print (__doc__, file=sys.stderr)
sys.exit (1) sys.exit (1)
files = [io.open (x, encoding='utf-8') for x in sys.argv[1:]] files = [io.open (x, encoding='utf-8') for x in sys.argv[1:]]
@ -126,7 +128,7 @@ def print_joining_table(f):
print ("}; /* Table items: %d; occupancy: %d%% */" % (offset, occupancy)) print ("}; /* Table items: %d; occupancy: %d%% */" % (offset, occupancy))
print () print ()
page_bits = 12; page_bits = 12
print () print ()
print ("static unsigned int") print ("static unsigned int")
print ("joining_type (hb_codepoint_t u)") print ("joining_type (hb_codepoint_t u)")

View File

@ -1,9 +1,11 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"usage: gen-def.py harfbuzz.def hb.h [hb-blob.h hb-buffer.h ...]"
import io, os, re, sys import io, os, re, sys
if len (sys.argv) < 3: if len (sys.argv) < 3:
sys.exit("usage: gen-def.py harfbuzz.def hb.h [hb-blob.h hb-buffer.h ...]") sys.exit(__doc__)
output_file = sys.argv[1] output_file = sys.argv[1]
header_paths = sys.argv[2:] header_paths = sys.argv[2:]

View File

@ -1,15 +1,18 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""usage: ./gen-emoji-table.py emoji-data.txt
Input file:
* https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt
"""
import sys import sys
import os.path import os.path
from collections import OrderedDict from collections import OrderedDict
import packTab import packTab
if len (sys.argv) != 2: if len (sys.argv) != 2:
print("""usage: ./gen-emoji-table.py emoji-data.txt print(__doc__, file=sys.stderr)
Input file:
* https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt""", file=sys.stderr)
sys.exit (1) sys.exit (1)
f = open(sys.argv[1]) f = open(sys.argv[1])

View File

@ -1,9 +1,11 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"usage: gen-harfbuzzcc.py harfbuzz.cc hb-blob.cc hb-buffer.cc ..."
import io, os, re, sys import io, os, re, sys
if len (sys.argv) < 3: if len (sys.argv) < 3:
sys.exit("usage: gen-harfbuzzcc.py harfbuzz.def hb-blob.cc hb-buffer.cc ...") sys.exit(__doc__)
output_file = sys.argv[1] output_file = sys.argv[1]
source_paths = sys.argv[2:] source_paths = sys.argv[2:]

View File

@ -1,9 +1,11 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"usage: gen-hb-version.py 1.0.0 hb-version.h.in hb-version.h"
import io, os, re, sys import io, os, re, sys
if len (sys.argv) < 4: if len (sys.argv) < 4:
sys.exit("usage: gen-hb-version.py 1.0.0 hb-version.h.in hb-version.h") sys.exit(__doc__)
version = sys.argv[1] version = sys.argv[1]
major, minor, micro = version.split (".") major, minor, micro = version.split (".")

View File

@ -1,14 +1,17 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import io, sys """usage: ./gen-indic-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt Blocks.txt
if len (sys.argv) != 4:
print ("""usage: ./gen-indic-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt Blocks.txt
Input files: Input files:
* https://unicode.org/Public/UCD/latest/ucd/IndicSyllabicCategory.txt * https://unicode.org/Public/UCD/latest/ucd/IndicSyllabicCategory.txt
* https://unicode.org/Public/UCD/latest/ucd/IndicPositionalCategory.txt * https://unicode.org/Public/UCD/latest/ucd/IndicPositionalCategory.txt
* https://unicode.org/Public/UCD/latest/ucd/Blocks.txt""", file=sys.stderr) * https://unicode.org/Public/UCD/latest/ucd/Blocks.txt
"""
import io, sys
if len (sys.argv) != 4:
print (__doc__, file=sys.stderr)
sys.exit (1) sys.exit (1)
ALLOWED_SINGLES = [0x00A0, 0x25CC] ALLOWED_SINGLES = [0x00A0, 0x25CC]

View File

@ -1,8 +1,9 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# Generates the code for a sorted unicode range array as used in hb-ot-os2-unicode-ranges.hh """Generates the code for a sorted unicode range array as used in hb-ot-os2-unicode-ranges.hh
# Input is a tab seperated list of unicode ranges from the otspec Input is a tab seperated list of unicode ranges from the otspec
# (https://docs.microsoft.com/en-us/typography/opentype/spec/os2#ur). (https://docs.microsoft.com/en-us/typography/opentype/spec/os2#ur).
"""
import io import io
import re import re
@ -17,7 +18,7 @@ input_file = args[0]
with io.open(input_file, mode="r", encoding="utf-8") as f: with io.open(input_file, mode="r", encoding="utf-8") as f:
all_ranges = []; all_ranges = []
current_bit = 0 current_bit = 0
while True: while True:
line = f.readline().strip() line = f.readline().strip()

View File

@ -16,6 +16,12 @@ back to BCP 47 tags. Ambiguous OpenType tags (those that correspond to
multiple BCP 47 tags) are listed here, except when the alphabetically multiple BCP 47 tags) are listed here, except when the alphabetically
first BCP 47 tag happens to be the chosen disambiguated tag. In that first BCP 47 tag happens to be the chosen disambiguated tag. In that
case, the fallback behavior will choose the right tag anyway. case, the fallback behavior will choose the right tag anyway.
usage: ./gen-tag-table.py languagetags language-subtag-registry
Input files:
* https://docs.microsoft.com/en-us/typography/opentype/spec/languagetags
* https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
""" """
import collections import collections
@ -30,11 +36,7 @@ import sys
import unicodedata import unicodedata
if len (sys.argv) != 3: if len (sys.argv) != 3:
print ('''usage: ./gen-tag-table.py languagetags language-subtag-registry print (__doc__, file=sys.stderr)
Input files:
* https://docs.microsoft.com/en-us/typography/opentype/spec/languagetags
* https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry''', file=sys.stderr)
sys.exit (1) sys.exit (1)
from html import unescape from html import unescape

View File

@ -1,14 +1,17 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""usage: ./gen-ucd-table ucd.nounihan.grouped.xml [/path/to/hb-common.h]
Input file:
* https://unicode.org/Public/UCD/latest/ucdxml/ucd.nounihan.grouped.zip
"""
import io, os.path, sys, re import io, os.path, sys, re
import logging import logging
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
if len (sys.argv) not in (2, 3): if len (sys.argv) not in (2, 3):
print("""usage: ./gen-ucd-table ucd.nounihan.grouped.xml [/path/to/hb-common.h] print(__doc__, file=sys.stderr)
Input file:
* https://unicode.org/Public/UCD/latest/ucdxml/ucd.nounihan.grouped.zip""", file=sys.stderr)
sys.exit(1) sys.exit(1)
# https://github.com/harfbuzz/packtab # https://github.com/harfbuzz/packtab

View File

@ -1,17 +1,20 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# flake8: noqa # flake8: noqa: F821
import io """usage: ./gen-use-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt UnicodeData.txt Blocks.txt
import sys
if len (sys.argv) != 5:
print ("""usage: ./gen-use-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt UnicodeData.txt Blocks.txt
Input file: Input file:
* https://unicode.org/Public/UCD/latest/ucd/IndicSyllabicCategory.txt * https://unicode.org/Public/UCD/latest/ucd/IndicSyllabicCategory.txt
* https://unicode.org/Public/UCD/latest/ucd/IndicPositionalCategory.txt * https://unicode.org/Public/UCD/latest/ucd/IndicPositionalCategory.txt
* https://unicode.org/Public/UCD/latest/ucd/UnicodeData.txt * https://unicode.org/Public/UCD/latest/ucd/UnicodeData.txt
* https://unicode.org/Public/UCD/latest/ucd/Blocks.txt""", file=sys.stderr) * https://unicode.org/Public/UCD/latest/ucd/Blocks.txt
"""
import io
import sys
if len (sys.argv) != 5:
print (__doc__, file=sys.stderr)
sys.exit (1) sys.exit (1)
BLACKLISTED_BLOCKS = ["Thai", "Lao"] BLACKLISTED_BLOCKS = ["Thai", "Lao"]

View File

@ -7,6 +7,10 @@ circles into sequences prohibited by the USE script development spec.
This function should be used as the ``preprocess_text`` of an This function should be used as the ``preprocess_text`` of an
``hb_ot_complex_shaper_t``. ``hb_ot_complex_shaper_t``.
usage: ./gen-vowel-constraints.py ms-use/IndicShapingInvalidCluster.txt Scripts.txt
Input file:
* https://unicode.org/Public/UCD/latest/ucd/Scripts.txt
""" """
import collections import collections
@ -19,10 +23,7 @@ import io
import sys import sys
if len (sys.argv) != 3: if len (sys.argv) != 3:
print ("""usage: ./gen-vowel-constraints.py ms-use/IndicShapingInvalidCluster.txt Scripts.txt print (__doc__, file=sys.stderr)
Input file:
* https://unicode.org/Public/UCD/latest/ucd/Scripts.txt""", file=sys.stderr)
sys.exit (1) sys.exit (1)
with io.open (sys.argv[2], encoding='utf-8') as f: with io.open (sys.argv[2], encoding='utf-8') as f: