From 60934f3c87fe3ef9c6fb8981d9f12ba2e253b040 Mon Sep 17 00:00:00 2001 From: "Lori A. Burns" Date: Thu, 9 Jun 2022 01:34:54 -0400 Subject: [PATCH] overzealous autodocs removal (#290) --- docs/source/changelog.rst | 2 +- qcelemental/models/__init__.py | 1 + qcelemental/models/basemodels.py | 11 ++++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index f78a2d12..a2b54722 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -30,7 +30,7 @@ Enhancements ++++++++++++ - (:pr:`285`) Standardized default on ``AtomicResult.native_files`` to ``{}`` from ``None``. -- (:pr:`289`) Transition from some early documentation tools (class +- (:pr:`289`, :pr:`290`) Transition from some early documentation tools (class ``AutodocBaseSettings`` and ``qcarchive_sphinx_theme``) to externally maintained ones (project https://github.com/mansenfranzen/autodoc_pydantic and ``sphinx_rtd_theme``). Expand API docs. diff --git a/qcelemental/models/__init__.py b/qcelemental/models/__init__.py index b0110879..447d5478 100644 --- a/qcelemental/models/__init__.py +++ b/qcelemental/models/__init__.py @@ -8,6 +8,7 @@ from . import types from .align import AlignmentMill +from .basemodels import AutodocBaseSettings # remove when QCFractal merges `next` from .basemodels import ProtoModel from .basis import BasisSet from .common_models import ComputeError, DriverEnum, FailedOperation, Provenance diff --git a/qcelemental/models/basemodels.py b/qcelemental/models/basemodels.py index 01a2786e..d0edfe61 100644 --- a/qcelemental/models/basemodels.py +++ b/qcelemental/models/basemodels.py @@ -3,9 +3,11 @@ from typing import Any, Dict, Optional, Set, Union import numpy as np -from pydantic import BaseModel, BaseSettings +from pydantic import BaseSettings # remove when QCFractal merges `next` +from pydantic import BaseModel from qcelemental.util import deserialize, serialize +from qcelemental.util.autodocs import AutoPydanticDocGenerator # remove when QCFractal merges `next` def _repr(self) -> str: @@ -23,6 +25,7 @@ class Config: def __init_subclass__(cls, **kwargs) -> None: super().__init_subclass__(**kwargs) + cls.__base_doc__ = "" # remove when QCFractal merges `next` if "pydantic" in cls.__repr__.__module__: cls.__repr__ = _repr @@ -188,4 +191,10 @@ def compare(self, other: Union["ProtoModel", BaseModel], **kwargs) -> bool: return compare_recursive(self, other, **kwargs) +# remove when QCFractal merges `next` +class AutodocBaseSettings(BaseSettings): + def __init_subclass__(cls) -> None: + cls.__doc__ = AutoPydanticDocGenerator(cls, always_apply=True) + + qcschema_draft = "http://json-schema.org/draft-04/schema#"