|
| 1 | +def clean_up_doxypypy_files(filename): |
| 2 | + lines_to_keep = [] |
| 3 | + lines = [] |
| 4 | + |
| 5 | + in_example = False |
| 6 | + with open(filename, 'r') as fp: |
| 7 | + lines += fp.readlines() |
| 8 | + for line in lines: |
| 9 | + if in_example is True: |
| 10 | + if '#' not in line: |
| 11 | + in_example = False |
| 12 | + else: |
| 13 | + continue |
| 14 | + if 'Examples' in line: |
| 15 | + in_example = True |
| 16 | + continue |
| 17 | + parts = line.split("# @return") |
| 18 | + if len(parts) == 1: |
| 19 | + lines_to_keep.append(line) |
| 20 | + else: |
| 21 | + if len(parts[1].strip()) == 0: |
| 22 | + continue |
| 23 | + else: |
| 24 | + lines_to_keep.append(line.replace('@return', '@retval').replace('POZYX_', '#POZYX_')) |
| 25 | + |
| 26 | + |
| 27 | + with open(filename, 'w') as fp: |
| 28 | + fp.writelines(lines_to_keep) |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | +if __name__ == '__main__': |
| 33 | + import os |
| 34 | + import subprocess |
| 35 | + import shutil |
| 36 | + |
| 37 | + path = os.path.dirname(__file__) |
| 38 | + |
| 39 | + if len(path) > 0: |
| 40 | + path += '/' |
| 41 | + |
| 42 | + original_folder = path + 'pypozyx' |
| 43 | + doxypy_folder = path + 'docs/doxypypozyx' |
| 44 | + |
| 45 | + def run_doxygen(files): |
| 46 | + os.mkdir(doxypy_folder) |
| 47 | + os.mkdir(doxypy_folder + '/definitions') |
| 48 | + os.mkdir(doxypy_folder + '/structures') |
| 49 | + |
| 50 | + for file in files: |
| 51 | + command = ['doxypypy', '-a', '-c', original_folder + '/' + file, '>', doxypy_folder + '/' + file] |
| 52 | + command = ' '.join(command) |
| 53 | + subprocess.run(command, shell=True) |
| 54 | + |
| 55 | + for file in files: |
| 56 | + clean_up_doxypypy_files(doxypy_folder + '/' + file) |
| 57 | + |
| 58 | + subprocess.run('doxygen doxygen_settings', shell=True) |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + # generate groups |
| 63 | + files_first_run = [ |
| 64 | + 'core.py', |
| 65 | + 'lib.py', |
| 66 | + 'pozyx_serial.py' |
| 67 | + # 'definitions/bitmasks.py', |
| 68 | + # 'definitions/constants.py', |
| 69 | + # 'definitions/registers.py', |
| 70 | + # 'structures/device.py', |
| 71 | + # 'structures/generic.py', |
| 72 | + # 'structures/sensor_data.py', |
| 73 | + # 'structures/byte_structure.py' |
| 74 | + ] |
| 75 | + |
| 76 | + # generate relevant classes in index |
| 77 | + files_second_run = [ |
| 78 | + 'structures/device.py', |
| 79 | + 'structures/generic.py', |
| 80 | + 'structures/sensor_data.py' |
| 81 | + ] |
| 82 | + |
| 83 | + run_doxygen(files_first_run) |
| 84 | + shutil.rmtree(doxypy_folder) |
| 85 | + run_doxygen(files_second_run) |
0 commit comments