File: makeref.py

package info (click to toggle)
pygame 2.6.1-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 43,076 kB
  • sloc: ansic: 66,932; python: 48,797; javascript: 1,153; objc: 224; sh: 121; makefile: 59; cpp: 25
file content (62 lines) | stat: -rwxr-xr-x 1,943 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python

import sys
import os
import subprocess

# rst_dir = 'docs'
# rst_source_dir = os.path.join(rst_dir, 'reST')
# rst_build_dir = os.path.join('docs', 'generated')

# rst_source_dir = os.path.join(rst_dir, 'es')
# rst_build_dir = os.path.join('docs', 'generated', 'es')

# rst_doctree_dir = os.path.join(rst_build_dir, 'doctrees')
# c_header_dir = os.path.join('src_c', 'doc')


def run():
    global rst_dir, rst_source_dir, rst_build_dir, rst_doctree_dir, c_header_dir
    rst_dir = 'docs'
    rst_source_dir = os.path.join(rst_dir, 'reST')
    rst_build_dir = os.path.join('docs', 'generated')

    rst_doctree_dir = os.path.join(rst_build_dir, 'doctrees')
    c_header_dir = os.path.join('src_c', 'doc')
    print("Generating:", rst_source_dir, rst_build_dir)
    runit()


    rst_source_dir = os.path.join(rst_dir, 'es')
    rst_build_dir = os.path.join('docs', 'generated', 'es')
    rst_doctree_dir = os.path.join(rst_build_dir, 'doctrees')
    print("Generating:", rst_source_dir, rst_build_dir)
    runit()


def runit():
    full_generation_flag = False
    for argument in sys.argv[1:]:
        if argument == 'full_generation':
            full_generation_flag = True
    try:
        subprocess_args = [sys.executable, '-m', 'sphinx',
                           '-b', 'html',
                           '-d', rst_doctree_dir,
                           '-D', f'headers_dest={c_header_dir}',
                           '-D', 'headers_mkdirs=0',
                           rst_source_dir,
                           rst_build_dir, ]
        if full_generation_flag:
            subprocess_args.append('-E')
        print("Executing sphinx in subprocess with args:", subprocess_args)
        return subprocess.run(subprocess_args).returncode
    except Exception:
        print('---')
        print('Have you installed sphinx?')
        print('---')
        raise


if __name__ == '__main__':
    sys.exit(run())