10 |
10 |
11 WARNING: the generation transfers quite much data over your |
11 WARNING: the generation transfers quite much data over your |
12 internet connection. don't run that at home, use |
12 internet connection. don't run that at home, use |
13 a server ;-) |
13 a server ;-) |
14 |
14 |
15 :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS. |
15 :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. |
16 :license: BSD, see LICENSE for details. |
16 :license: BSD, see LICENSE for details. |
17 """ |
17 """ |
18 |
|
19 from __future__ import print_function |
|
20 |
18 |
21 MODULES = {'.NET': ('dotnet_load',), |
19 MODULES = {'.NET': ('dotnet_load',), |
22 'APC': ('apc_add', |
20 'APC': ('apc_add', |
23 'apc_bin_dump', |
21 'apc_bin_dump', |
24 'apc_bin_dumpfile', |
22 'apc_bin_dumpfile', |
4696 module_re = re.compile(PHP_MODULE_RE) |
4694 module_re = re.compile(PHP_MODULE_RE) |
4697 modules = {} |
4695 modules = {} |
4698 |
4696 |
4699 for file in get_php_references(): |
4697 for file in get_php_references(): |
4700 module = '' |
4698 module = '' |
4701 for line in open(file): |
4699 with open(file) as f: |
4702 if not module: |
4700 for line in f: |
4703 search = module_re.search(line) |
4701 if not module: |
4704 if search: |
4702 search = module_re.search(line) |
4705 module = search.group(1) |
4703 if search: |
4706 modules[module] = [] |
4704 module = search.group(1) |
|
4705 modules[module] = [] |
4707 |
4706 |
4708 elif 'href="function.' in line: |
4707 elif 'href="function.' in line: |
4709 for match in function_re.finditer(line): |
4708 for match in function_re.finditer(line): |
4710 fn = match.group(1) |
4709 fn = match.group(1) |
4711 if '->' not in fn and '::' not in fn and fn not in modules[module]: |
4710 if '->' not in fn and '::' not in fn and fn not in modules[module]: |
4712 modules[module].append(fn) |
4711 modules[module].append(fn) |
4713 |
4712 |
4714 if module: |
4713 if module: |
4715 # These are dummy manual pages, not actual functions |
4714 # These are dummy manual pages, not actual functions |
4716 if module == 'PHP Options/Info': |
4715 if module == 'PHP Options/Info': |
4717 modules[module].remove('main') |
4716 modules[module].remove('main') |
4724 |
4723 |
4725 return modules |
4724 return modules |
4726 |
4725 |
4727 def get_php_references(): |
4726 def get_php_references(): |
4728 download = urlretrieve(PHP_MANUAL_URL) |
4727 download = urlretrieve(PHP_MANUAL_URL) |
4729 tar = tarfile.open(download[0]) |
4728 with tarfile.open(download[0]) as tar: |
4730 tar.extractall() |
4729 tar.extractall() |
4731 tar.close() |
|
4732 for file in glob.glob("%s%s" % (PHP_MANUAL_DIR, PHP_REFERENCE_GLOB)): |
4730 for file in glob.glob("%s%s" % (PHP_MANUAL_DIR, PHP_REFERENCE_GLOB)): |
4733 yield file |
4731 yield file |
4734 os.remove(download[0]) |
4732 os.remove(download[0]) |
4735 |
4733 |
4736 def regenerate(filename, modules): |
4734 def regenerate(filename, modules): |