diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index e879bee..d219f84 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -25,6 +25,7 @@ jobs: python ./docs/source/generate_class_list.py - name: Build Docs run: | + cp LICENSE docs/source/ cd docs sphinx-apidoc -o ./source/ ../src/ -M --no-toc rm ./source/*.rst diff --git a/docs/source/generate_class_list.py b/docs/source/generate_class_list.py index 41720ba..4b800a9 100644 --- a/docs/source/generate_class_list.py +++ b/docs/source/generate_class_list.py @@ -11,8 +11,10 @@ def write_classes(f: TextIOWrapper, patterns: list[str], module_name: str, title classes = [ name for name, obj in inspect.getmembers(module, inspect.isclass) if (obj.__module__ == module_name and - any(fnmatch.fnmatch(name, pat) for pat in patterns if pat not in exclude) and - obj.__doc__ and '(Automatic generated stub)' not in obj.__doc__) + any(fnmatch.fnmatch(name, pat) for pat in patterns) and + obj.__doc__ and + # '(Automatic generated stub)' not in obj.__doc__ and + '(no I/O function)' not in obj.__doc__) ] """Write the classes to the file.""" @@ -21,23 +23,27 @@ def write_classes(f: TextIOWrapper, patterns: list[str], module_name: str, title f.write(f'{description}\n\n') for cls in classes: - f.write('```{eval-rst}\n') - f.write(f'.. autoclass:: {module_name}.{cls}\n') - f.write(' :members:\n') - f.write(' :undoc-members:\n') - f.write(' :show-inheritance:\n') - f.write(' :inherited-members:\n') - if title != 'Base classes': - f.write(' :exclude-members: select\n') - f.write('```\n\n') + if cls not in exclude: + f.write('```{eval-rst}\n') + f.write(f'.. autoclass:: {module_name}.{cls}\n') + f.write(' :members:\n') + #f.write(' :undoc-members:\n') + f.write(' :show-inheritance:\n') + f.write(' :inherited-members: object\n') + if title not in ['Base classes', 'Bus coupler']: + f.write(' :exclude-members: select, parameters\n') + else: + print('* ', cls) + f.write('```\n\n') with open('docs/source/modules.md', 'w') as f: - f.write('# Classes\n\n') + f.write('# Classes and Modules\n\n') write_classes(f, ['BK*', 'WAGO_750_352'], 'pyhoff.devices', title='Bus coupler', description='These classes are bus couplers and are used to connect the IO bus terminals to a Ethernet interface.') write_classes(f, ['KL*'], 'pyhoff.devices', title='Beckhoff bus terminals') write_classes(f, ['WAGO*'], 'pyhoff.devices', title='WAGO bus terminals', exclude=['WAGO_750_352']) + write_classes(f, ['*Terminal*'], 'pyhoff.devices', title='Generic bus terminals') write_classes(f, ['*'], 'pyhoff', title='Base classes', description='These classes are base classes for devices and are typically not used directly.') write_classes(f, ['*'], 'pyhoff.modbus', title='Modbus',