ya2 · news · projects · code · about

83f435164ced3babe3c98faf7c234df62c87abb5
[pmachines.git] / lib / build / docs.py
1 '''This module creates the documentation using pydoc.'''
2 from os import system, mkdir, remove, rename
3 from os.path import exists
4 from shutil import rmtree, make_archive
5 from lib.build.build import InsideDir
6 from pathlib import Path
7 from glob import glob
8
9
10 #TODO refactor: make class DocsBuilder
11
12
13 def bld_docs():
14 '''Builds the docs (inside a zip file).'''
15 system('python -m pydoc -w ./')
16 rmtree('docs', ignore_errors=True)
17 Path('docs').mkdir(exist_ok=True)
18 [rename(fname, 'docs/' + fname) for fname in glob('*.html')]
19 Path('build').mkdir(exist_ok=True)
20 rmtree('build/docs', ignore_errors=True)
21 rename('docs', 'build/docs')
22 with InsideDir('build'):
23 exists('docs.zip') and remove('docs.zip')
24 make_archive('docs', 'zip', '.', 'docs')
25 rmtree('docs')