Matthew Bentham | 245d64c | 2019-12-02 12:59:43 +0000 | [diff] [blame^] | 1 | import os |
| 2 | import tarfile |
| 3 | |
| 4 | import pyarmnn as ann |
| 5 | import shutil |
| 6 | |
| 7 | from typing import List, Union |
| 8 | |
| 9 | from pdoc.cli import main |
| 10 | |
| 11 | |
| 12 | def __copy_file_to_dir(file_paths: Union[List[str], str], target_dir_path: str): |
| 13 | file_paths = [] + file_paths |
| 14 | |
| 15 | if not (os.path.exists(target_dir_path) and os.path.isdir(target_dir_path)): |
| 16 | os.makedirs(target_dir_path) |
| 17 | |
| 18 | for file_path in file_paths: |
| 19 | if not (os.path.exists(file_path) and os.path.isfile(file_path)): |
| 20 | raise RuntimeError('Not a file: {}'.format(file_path)) |
| 21 | |
| 22 | file_name = os.path.basename(file_path) |
| 23 | shutil.copyfile(file_path, os.path.join(str(target_dir_path), file_name)) |
| 24 | |
| 25 | |
| 26 | def copy_doc_images(): |
| 27 | __copy_file_to_dir(file_paths=['./images/pyarmnn.png' ], |
| 28 | target_dir_path='docs/pyarmnn/images') |
| 29 | |
| 30 | |
| 31 | def archive_docs(path, version): |
| 32 | |
| 33 | output_filename = f'pyarmnn_docs-{version}.tar' |
| 34 | |
| 35 | with tarfile.open(output_filename, "w") as tar: |
| 36 | tar.add(path) |
| 37 | |
| 38 | |
| 39 | if __name__ == "__main__": |
| 40 | with open('./readme.md', 'r') as readme_file: |
| 41 | top_level_pyarmnn_doc = ''.join(readme_file.readlines()) |
| 42 | ann.__doc__ = top_level_pyarmnn_doc |
| 43 | |
| 44 | main() |
| 45 | |
| 46 | copy_doc_images() |
| 47 | archive_docs('./docs', ann.__version__) |