Compare commits

..

No commits in common. "6febc47de010bdc989f4bb71dad513fa67d87068" and "2acffb90b5a71611d2792427b0b1643d87c98954" have entirely different histories.

3 changed files with 17 additions and 23 deletions

View File

@ -25,7 +25,6 @@ jobs:
python ./docs/source/generate_class_list.py python ./docs/source/generate_class_list.py
- name: Build Docs - name: Build Docs
run: | run: |
cp LICENSE docs/source/
cd docs cd docs
sphinx-apidoc -o ./source/ ../src/ -M --no-toc sphinx-apidoc -o ./source/ ../src/ -M --no-toc
rm ./source/*.rst rm ./source/*.rst

View File

@ -11,10 +11,8 @@ def write_classes(f: TextIOWrapper, patterns: list[str], module_name: str, title
classes = [ classes = [
name for name, obj in inspect.getmembers(module, inspect.isclass) name for name, obj in inspect.getmembers(module, inspect.isclass)
if (obj.__module__ == module_name and if (obj.__module__ == module_name and
any(fnmatch.fnmatch(name, pat) for pat in patterns) and any(fnmatch.fnmatch(name, pat) for pat in patterns if pat not in exclude) and
obj.__doc__ and obj.__doc__ and '(Automatic generated stub)' not in obj.__doc__)
# '(Automatic generated stub)' not in obj.__doc__ and
'(no I/O function)' not in obj.__doc__)
] ]
"""Write the classes to the file.""" """Write the classes to the file."""
@ -23,26 +21,23 @@ def write_classes(f: TextIOWrapper, patterns: list[str], module_name: str, title
f.write(f'{description}\n\n') f.write(f'{description}\n\n')
for cls in classes: for cls in classes:
if cls not in exclude: f.write('```{eval-rst}\n')
f.write('```{eval-rst}\n') f.write(f'.. autoclass:: {module_name}.{cls}\n')
f.write(f'.. autoclass:: {module_name}.{cls}\n') f.write(' :members:\n')
f.write(' :members:\n') f.write(' :undoc-members:\n')
f.write(' :show-inheritance:\n') f.write(' :show-inheritance:\n')
f.write(' :inherited-members: object\n') f.write(' :inherited-members:\n')
if title not in ['Base classes', 'Bus coupler']: if title != 'Base classes':
f.write(' :exclude-members: select, parameters\n') f.write(' :exclude-members: select\n')
else: f.write('```\n\n')
print('* ', cls)
f.write('```\n\n')
with open('docs/source/modules.md', 'w') as f: with open('docs/source/modules.md', 'w') as f:
f.write('# Classes and Modules\n\n') f.write('# Classes\n\n')
write_classes(f, ['BK*', 'WAGO_750_352'], 'pyhoff.devices', title='Bus coupler', 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.') 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, ['KL*'], 'pyhoff.devices', title='Beckhoff bus terminals')
write_classes(f, ['WAGO*'], 'pyhoff.devices', title='WAGO bus terminals', exclude=['WAGO_750_352']) 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', write_classes(f, ['*'], 'pyhoff', title='Base classes',
description='These classes are base classes for devices and are typically not used directly.') description='These classes are base classes for devices and are typically not used directly.')
write_classes(f, ['*'], 'pyhoff.modbus', title='Modbus', write_classes(f, ['*'], 'pyhoff.modbus', title='Modbus',

View File

@ -224,7 +224,7 @@ class KL3054(AnalogInputTerminal):
channel: The channel number to read from. channel: The channel number to read from.
Returns: Returns:
The current value in mA. The current value.
""" """
return self.read_normalized(channel) * 16.0 + 4.0 return self.read_normalized(channel) * 16.0 + 4.0
@ -244,7 +244,7 @@ class KL3042(AnalogInputTerminal):
channel: The channel number to read from. channel: The channel number to read from.
Returns: Returns:
The current value in mA. The current value.
""" """
return self.read_normalized(channel) * 20.0 return self.read_normalized(channel) * 20.0
@ -311,7 +311,7 @@ class KL4002(AnalogOutputTerminal):
Args: Args:
channel: The channel number to set. channel: The channel number to set.
value: The voltage value to set in V. value: The voltage value to set.
Returns: Returns:
True if the write operation succeeded. True if the write operation succeeded.
@ -348,7 +348,7 @@ class KL4132(AnalogOutputTerminal):
Args: Args:
channel: The channel number to set. channel: The channel number to set.
value: The voltage value to set in V. value: The voltage value to set.
Returns: Returns:
True if the write operation succeeded. True if the write operation succeeded.
@ -369,7 +369,7 @@ class KL4004(AnalogOutputTerminal):
Args: Args:
channel: The channel number to set. channel: The channel number to set.
value: The voltage value to set in V. value: The voltage value to set.
Returns: Returns:
True if the write operation succeeded. True if the write operation succeeded.