feature: stabilized the new instance method and adds docs #64

Merged
HideyoshiNakazone merged 2 commits from feature/alters-library-api into main 2025-11-26 03:05:15 +00:00
HideyoshiNakazone commented 2025-11-26 03:04:11 +00:00 (Migrated from github.com)

This pull request introduces significant improvements to the documentation and refactors the API for building Pydantic models from JSON Schema, focusing on better cache management and clearer usage patterns. The main changes include renaming the instance method for building models with a cache, updating all references and tests to use the new method, and expanding the documentation to explain the reference cache and its usage in detail.

Documentation improvements

  • Added a comprehensive new documentation page, docs/source/usage.ref_cache.rst, detailing the reference cache mechanism, its configuration, usage patterns, and API for inspecting and managing cached types.
  • Updated docs/source/usage.rst to clarify the difference between static and instance methods, provide examples for both, and reference the new cache documentation. [1] [2] [3]

API refactoring

  • Renamed the instance method build_with_instance to build_with_cache in SchemaConverter, making its purpose and behavior clearer and more consistent with the documentation.
  • Updated the docstring for the static build method to clarify that it does not use a persistent reference cache unless one is provided.

Test suite updates

This pull request introduces significant improvements to the documentation and refactors the API for building Pydantic models from JSON Schema, focusing on better cache management and clearer usage patterns. The main changes include renaming the instance method for building models with a cache, updating all references and tests to use the new method, and expanding the documentation to explain the reference cache and its usage in detail. ### Documentation improvements * Added a comprehensive new documentation page, `docs/source/usage.ref_cache.rst`, detailing the reference cache mechanism, its configuration, usage patterns, and API for inspecting and managing cached types. * Updated `docs/source/usage.rst` to clarify the difference between static and instance methods, provide examples for both, and reference the new cache documentation. [[1]](diffhunk://#diff-66e28562c85a1bb96f431f2dd52bbabab914359e4b06f58eb1e18eadc01f5c06R1-R12) [[2]](diffhunk://#diff-66e28562c85a1bb96f431f2dd52bbabab914359e4b06f58eb1e18eadc01f5c06R24-R33) [[3]](diffhunk://#diff-66e28562c85a1bb96f431f2dd52bbabab914359e4b06f58eb1e18eadc01f5c06L29-L38) ### API refactoring * Renamed the instance method `build_with_instance` to `build_with_cache` in `SchemaConverter`, making its purpose and behavior clearer and more consistent with the documentation. * Updated the docstring for the static `build` method to clarify that it does not use a persistent reference cache unless one is provided. ### Test suite updates * Refactored all test cases in `tests/test_schema_converter.py` to use the new `build_with_cache` method name, ensuring consistency and correctness with the updated API. [[1]](diffhunk://#diff-04f19b964ef1fadc9b51ecb3b8ddff05392ba340be55cccf56c5a8ca49c11d5aL36-R36) [[2]](diffhunk://#diff-04f19b964ef1fadc9b51ecb3b8ddff05392ba340be55cccf56c5a8ca49c11d5aL50-R50) [[3]](diffhunk://#diff-04f19b964ef1fadc9b51ecb3b8ddff05392ba340be55cccf56c5a8ca49c11d5aL63-R63) [[4]](diffhunk://#diff-04f19b964ef1fadc9b51ecb3b8ddff05392ba340be55cccf56c5a8ca49c11d5aL73-R73) [[5]](diffhunk://#diff-04f19b964ef1fadc9b51ecb3b8ddff05392ba340be55cccf56c5a8ca49c11d5aL89-R89) [[6]](diffhunk://#diff-04f19b964ef1fadc9b51ecb3b8ddff05392ba340be55cccf56c5a8ca49c11d5aL104-R104) [[7]](diffhunk://#diff-04f19b964ef1fadc9b51ecb3b8ddff05392ba340be55cccf56c5a8ca49c11d5aL125-R125) [[8]](diffhunk://#diff-04f19b964ef1fadc9b51ecb3b8ddff05392ba340be55cccf56c5a8ca49c11d5aL156-R156) [[9]](diffhunk://#diff-04f19b964ef1fadc9b51ecb3b8ddff05392ba340be55cccf56c5a8ca49c11d5aL181-R181) [[10]](diffhunk://#diff-04f19b964ef1fadc9b51ecb3b8ddff05392ba340be55cccf56c5a8ca49c11d5aL202-R202) [[11]](diffhunk://#diff-04f19b964ef1fadc9b51ecb3b8ddff05392ba340be55cccf56c5a8ca49c11d5aL225-R225) [[12]](diffhunk://#diff-04f19b964ef1fadc9b51ecb3b8ddff05392ba340be55cccf56c5a8ca49c11d5aL238-R238) [[13]](diffhunk://#diff-04f19b964ef1fadc9b51ecb3b8ddff05392ba340be55cccf56c5a8ca49c11d5aL276-R276) [[14]](diffhunk://#diff-04f19b964ef1fadc9b51ecb3b8ddff05392ba340be55cccf56c5a8ca49c11d5aL300-R300) [[15]](diffhunk://#diff-04f19b964ef1fadc9b51ecb3b8ddff05392ba340be55cccf56c5a8ca49c11d5aL323-R323) [[16]](diffhunk://#diff-04f19b964ef1fadc9b51ecb3b8ddff05392ba340be55cccf56c5a8ca49c11d5aL340-R340)
HideyoshiNakazone commented 2025-11-26 03:05:11 +00:00 (Migrated from github.com)

Doesn't break backwards compatibility

Doesn't break backwards compatibility
Sign in to join this conversation.