← GDG /

#115 gdtest_config_reference

#115 gdtest_config_reference OK CONFIG
Tests reference config with explicit titled sections grouping functions.
Tests reference config with explicit sections. Config defines two reference sections: 'Core API' and 'Utilities'. On the reference page these should appear as named section headings.
View Site → Build Log ๐Ÿงช Test Coverage

Build Mode

● Has great-docs.yml

This package ships a pre-supplied config. The great-docs init step is skipped and great-docs build uses the spec-defined configuration directly. Tests specific config options and their rendered output.

Dimensions

K22
K22reference configconfig

Source Files

๐Ÿ“ gdtest_config_reference/
๐Ÿ“„ __init__.py
"""Test package for reference config with sections."""

from gdtest_config_reference.core import compute, analyze
from gdtest_config_reference.utils import format_result, clean_data
๐Ÿ“„ core.py
"""Core computation and analysis functions."""


def compute(x: float, y: float) -> float:
    """Compute the combined value of two numbers.

    Parameters
    ----------
    x : float
        The first input value.
    y : float
        The second input value.

    Returns
    -------
    float
        The computed result.

    Examples
    --------
    >>> compute(3.0, 4.0)
    7.0
    """
    return x + y


def analyze(data: list) -> dict:
    """Analyze a list of values and return summary statistics.

    Parameters
    ----------
    data : list
        A list of numeric values to analyze.

    Returns
    -------
    dict
        A dictionary containing summary statistics such as mean
        and count.

    Examples
    --------
    >>> analyze([1, 2, 3])
    {'mean': 2.0, 'count': 3}
    """
    if not data:
        return {"mean": 0.0, "count": 0}
    return {"mean": sum(data) / len(data), "count": len(data)}
๐Ÿ“„ utils.py
"""Utility functions for formatting and cleaning."""


def format_result(value: float, precision: int = 2) -> str:
    """Format a numeric result as a string.

    Parameters
    ----------
    value : float
        The value to format.
    precision : int, optional
        The number of decimal places, by default 2.

    Returns
    -------
    str
        The formatted string representation.

    Examples
    --------
    >>> format_result(3.14159, precision=3)
    '3.142'
    """
    return f"{value:.{precision}f}"


def clean_data(raw: list) -> list:
    """Clean a list of raw data by removing None values.

    Parameters
    ----------
    raw : list
        The raw data list, possibly containing None values.

    Returns
    -------
    list
        A cleaned list with None values removed.

    Examples
    --------
    >>> clean_data([1, None, 3, None, 5])
    [1, 3, 5]
    """
    return [x for x in raw if x is not None]
๐Ÿ“„ great-docs.yml
reference:
  - title: Core API
    desc: Core functions
    contents:
      - name: compute
      - name: analyze
  - title: Utilities
    desc: Helper utilities
    contents:
      - name: format_result
      - name: clean_data