Pavel Macenauer | 59e057f | 2020-04-15 14:17:26 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 2 | # Copyright © 2020 Arm Ltd. All rights reserved. |
| 3 | # SPDX-License-Identifier: MIT |
| 4 | """Generate PyArmNN documentation.""" |
Pavel Macenauer | 59e057f | 2020-04-15 14:17:26 +0000 | [diff] [blame] | 5 | |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 6 | import os |
| 7 | import tarfile |
| 8 | |
| 9 | import pyarmnn as ann |
| 10 | import shutil |
| 11 | |
| 12 | from typing import List, Union |
| 13 | |
| 14 | from pdoc.cli import main |
| 15 | |
| 16 | |
| 17 | def __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 | |
| 31 | def copy_doc_images(): |
| 32 | __copy_file_to_dir(file_paths=['./images/pyarmnn.png'], |
| 33 | target_dir_path='docs/pyarmnn/images') |
| 34 | |
| 35 | |
| 36 | def 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 | |
| 44 | if __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__) |