blob: 66eff6d52ad5b0f75b5aebd489bf8834d05ce91c [file] [log] [blame]
Richard Burtondc0c6ed2020-04-08 16:39:05 +01001# Copyright © 2020 Arm Ltd. All rights reserved.
2# SPDX-License-Identifier: MIT
3"""Generate PyArmNN documentation."""
4import os
5import tarfile
6
7import pyarmnn as ann
8import shutil
9
10from typing import List, Union
11
12from pdoc.cli import main
13
14
15def __copy_file_to_dir(file_paths: Union[List[str], str], target_dir_path: str):
16 file_paths = [] + file_paths
17
18 if not (os.path.exists(target_dir_path) and os.path.isdir(target_dir_path)):
19 os.makedirs(target_dir_path)
20
21 for file_path in file_paths:
22 if not (os.path.exists(file_path) and os.path.isfile(file_path)):
23 raise RuntimeError('Not a file: {}'.format(file_path))
24
25 file_name = os.path.basename(file_path)
26 shutil.copyfile(file_path, os.path.join(str(target_dir_path), file_name))
27
28
29def copy_doc_images():
30 __copy_file_to_dir(file_paths=['./images/pyarmnn.png'],
31 target_dir_path='docs/pyarmnn/images')
32
33
34def archive_docs(path, version):
35
36 output_filename = f'pyarmnn_docs-{version}.tar'
37
38 with tarfile.open(output_filename, "w") as tar:
39 tar.add(path)
40
41
42if __name__ == "__main__":
43 with open('./README.md', 'r') as readme_file:
44 top_level_pyarmnn_doc = ''.join(readme_file.readlines())
45 ann.__doc__ = top_level_pyarmnn_doc
46
47 main()
48
49 copy_doc_images()
50 archive_docs('./docs', ann.__version__)