Skip to content

Instantly share code, notes, and snippets.

@rybarix
Created December 12, 2021 21:04
Show Gist options
  • Save rybarix/10f595c3a58070b4da8daa1d41ce4cd3 to your computer and use it in GitHub Desktop.
Save rybarix/10f595c3a58070b4da8daa1d41ce4cd3 to your computer and use it in GitHub Desktop.
Generate simplest documentation possible
# HERE import all functions/classes to generate documentation for
from covidseg.dataset_reduction import reduce_dataset
from covidseg.inference import inference
# Generate docstrings
def __docs(m):
"""
Generates simple docstring for python module.
"""
file = f"\nFILE: {m.__file__}" if hasattr(m, '__file__') else ""
d = f"{m.__module__}.{m.__name__}\n{m.__doc__}{file}\n"
return d
# HERE insert all modules to generate documentation for
mods = [
reduce_dataset,
inference,
]
for mod in mods:
d = __docs(mod)
print(f"{d}\n")
# EXAMPLE OUTPUT
"""
covidseg.dataset_reduction.reduce_dataset
Reduce dataset within data_folder with help of lungseg_model.
:param lungseg_model: lung segmentation model Pytorch nn.Module
:param data_folder: path to inference images
:param output_folder: path where to store output volumes
covidseg.inference.inference
Performs inference on input volume with reducing the volume in the process.
:param volume_path: path to volume to perform inference on
:param lungseg_model: instance of lung segmentation model
:param covidseg_model: instance of covid segmentation model
:output_filename: output file name path
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment