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