mgeraeds / hires-processing

Code for processing large files from geospatial and hydrodynamic models.
MIT License
0 stars 0 forks source link

Generate test function to be automatically documented by sphinx #14

Closed rortizmerino closed 4 months ago

rortizmerino commented 5 months ago

Requires:

check more details in: https://www.sphinx-doc.org/en/master/tutorial/automatic-doc-generation.html

rortizmerino commented 4 months ago

Below a few steps to get a function documented using the validate function. They assume the folders and files are already correctly configured and sphinx is already installed locally.

  1. Make sure the function file contains docstrings in the correct format. For example:
"""
Module for validation functions.

This module provides functions for validating various data structures.
"""

def validate_data(data):
    """
    Validate the given data.

    Parameters:
    data (dict): The data to validate.

    Returns:
    bool: True if the data is valid, False otherwise.
    """
    # Implementation here
    pass
  1. Create a documentation file within docs. For validate.py would be validate.rst.
validate module
===============

.. automodule:: reduce.validate
    :members:
    :undoc-members:
    :show-inheritance:

It's defined as reduce.validate since it is within the src/reduce/ folder.

  1. Include validate.rst in the Table of Contents. Edit index.rst to include a reference to validate.rst. Ensure it's part of the toctree:
.. toctree::
   :maxdepth: 2
   :caption: Contents:

   reduce.validate
  1. Clean up previous documentation files and build the new ones:
make clean
make html

Note: Some modifications might be required for building directly in github, might be added at a later time. Closing the issue for now.