| 1 |
#! /usr/bin/env python3 |
| 2 |
# Copyright (C) 2025 fontconfig Authors |
| 3 |
# SPDX-License-Identifier: HPND |
| 4 |
|
| 5 |
import argparse |
| 6 |
import glob |
| 7 |
import re |
| 8 |
import sys |
| 9 |
from pathlib import Path |
| 10 |
|
| 11 |
parser = argparse.ArgumentParser() |
| 12 |
parser.add_argument('srcdir') |
| 13 |
parser.add_argument('builddir') |
| 14 |
|
| 15 |
args = parser.parse_args() |
| 16 |
h_apis = [] |
| 17 |
d_apis = [] |
| 18 |
|
| 19 |
header_files = glob.glob(str(Path(args.builddir) / 'fontconfig' / '*.h')) + glob.glob(str(Path(args.srcdir) / 'fontconfig' / '*.h')) |
| 20 |
|
| 21 |
for fn in header_files: |
| 22 |
with open(fn) as f: |
| 23 |
for s in f: |
| 24 |
if re.search(r'^Fc', s) and not re.search('FcPublic', s): |
| 25 |
res = re.sub(r'[^a-zA-Z0-9].*', '', s) |
| 26 |
h_apis += [res] |
| 27 |
m = re.search(r'#\s*define\s+(Fc[a-zA-Z]+)\s*\(.*$', s) |
| 28 |
if m: |
| 29 |
h_apis += [m.group(1)] |
| 30 |
|
| 31 |
h_apis.sort() |
| 32 |
|
| 33 |
doc_files = glob.glob(str(Path(args.srcdir) / 'doc' / '*.fncs')) |
| 34 |
for fn in doc_files: |
| 35 |
with open(fn) as f: |
| 36 |
for s in f: |
| 37 |
if re.search(r'@FUNC[+]*@', s): |
| 38 |
d_apis += [s.split()[1]] |
| 39 |
|
| 40 |
d_apis.sort() |
| 41 |
|
| 42 |
missing_in_doc = list(set(h_apis) - set(d_apis)) |
| 43 |
missing_in_header = list(set(d_apis) - set(h_apis)) |
| 44 |
if len(missing_in_doc) == 0 and len(missing_in_header) == 0: |
| 45 |
sys.exit(0) |
| 46 |
|
| 47 |
if len(missing_in_doc) > 0: |
| 48 |
print('Missing API documentation:') |
| 49 |
for s in missing_in_doc: |
| 50 |
print(f'\t{s}') |
| 51 |
print('') |
| 52 |
if len(missing_in_header) > 0: |
| 53 |
print('API available in documentation only:') |
| 54 |
for s in missing_in_header: |
| 55 |
print(f'\t{s}') |
| 56 |
print('') |
| 57 |
|
| 58 |
sys.exit(1) |