#187
gdtest_ref_reorder
OK
CONFIG
Reference config reordering: Functions before Classes.
Reference config that reorders the default sections. Functions appear before Classes, reversing the normal order.
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
P4
P4Reordered sectionsreference
Source Files
gdtest_ref_reorder/
__init__.py
"""Test package for reference config reordering.""" from .functions import compute, transform from .models import DataModel, Schema __all__ = ["DataModel", "Schema", "compute", "transform"]
functions.py
"""Utility functions for computing and transforming."""
def compute(x: float) -> float:
"""Compute the square of a value.
Parameters
----------
x : float
The input value.
Returns
-------
float
The squared value.
Examples
--------
>>> compute(3.0)
9.0
"""
return x ** 2
def transform(data: list) -> list:
"""Transform a list by doubling each element.
Parameters
----------
data : list
The input data list.
Returns
-------
list
The transformed data with doubled values.
Examples
--------
>>> transform([1, 2, 3])
[2, 4, 6]
"""
return [x * 2 for x in data]models.py
"""Data model and schema classes."""
class DataModel:
"""A data model for holding and validating data.
Parameters
----------
data : dict
The data to model.
Examples
--------
>>> m = DataModel({"key": "value"})
>>> m.validate()
True
"""
def __init__(self, data: dict):
"""Initialize the data model.
Parameters
----------
data : dict
The data to model.
"""
self.data = data
def validate(self) -> bool:
"""Validate the data model.
Returns
-------
bool
True if the data is valid.
"""
return bool(self.data)
class Schema:
"""A schema for parsing and validating structured data.
Parameters
----------
definition : dict
The schema definition.
Examples
--------
>>> s = Schema({"type": "object"})
>>> s.parse({"key": "value"})
{'key': 'value'}
"""
def __init__(self, definition: dict):
"""Initialize the schema.
Parameters
----------
definition : dict
The schema definition.
"""
self.definition = definition
def parse(self, data: dict) -> dict:
"""Parse data according to the schema.
Parameters
----------
data : dict
The data to parse.
Returns
-------
dict
The parsed data.
"""
return dataREADME.md
# gdtest-ref-reorder Test reference config reordering.
great-docs.yml
reference:
- title: Functions
desc: Utility functions
contents:
- name: compute
- name: transform
- title: Classes
desc: Data classes
contents:
- name: DataModel
- name: Schema