1#!/usr/bin/env python3 2# Copyright © 2020 Arm Ltd. All rights reserved. 3# SPDX-License-Identifier: MIT 4"""Generate PyArmNN documentation.""" 5 6import 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(): 32 __copy_file_to_dir(file_paths=['../../docs/pyarmnn.png'], 33 target_dir_path='docs') 34 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__) 53