File: build_docs.py

package info (click to toggle)
sympy 1.14.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 36,784 kB
  • sloc: python: 460,598; xml: 359; makefile: 162; sh: 59; lisp: 4
file content (53 lines) | stat: -rwxr-xr-x 1,297 bytes parent folder | download
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
#!/usr/bin/env python3


import os
from os.path import dirname, join
from os import chdir
import shutil

from helpers import run


ROOTDIR = dirname(dirname(__file__))
DOCSDIR = join(ROOTDIR, 'doc')


def main(version, outputdir):
    os.makedirs(outputdir, exist_ok=True)
    run('bin/test_sphinx.sh')
    build_html(DOCSDIR, outputdir, version)
    build_latex(DOCSDIR, outputdir, version)


def build_html(docsdir, outputdir, version):
    #run('make', 'clean', cwd=docsdir)
    #run('make', 'html', cwd=docsdir)

    builddir = join(docsdir, '_build')
    docsname = 'sympy-docs-html-%s' % (version,)
    zipname = docsname + '.zip'
    cwd = os.getcwd()
    try:
        chdir(builddir)
        shutil.move('html', docsname)
        run('zip', '-9lr', zipname, docsname)
    finally:
        chdir(cwd)
    shutil.move(join(builddir, zipname), join(outputdir, zipname))


def build_latex(docsdir, outputdir, version):
    #run('make', 'clean', cwd=docsdir)
    #run('make', 'latexpdf', cwd=docsdir)

    srcfilename = 'sympy-%s.pdf' % (version,)
    dstfilename = 'sympy-docs-pdf-%s.pdf' % (version,)
    src = join('doc', '_build', 'latex', srcfilename)
    dst = join(outputdir, dstfilename)
    shutil.copyfile(src, dst)


if __name__ == "__main__":
    import sys
    main(*sys.argv[1:])