3737 "sphinx.ext.autodoc" ,
3838 "sphinx.ext.viewcode" ,
3939 "sphinx.ext.napoleon" ,
40+ "sphinx.ext.intersphinx" ,
4041 "sphinx_autodoc_typehints"
4142]
4243
44+ intersphinx_mapping = {
45+ "python" : ("https://docs.python.org/3" , None ),
46+ "pydantic" : ("https://docs.pydantic.dev/latest" , None )
47+ }
48+
4349# Add any paths that contain templates here, relative to this directory.
4450templates_path = [ "_templates" ]
4551
6167
6268# -- Autodoc Configuration ---------------------------------------------------------------
6369
64- # The following two options seem to be ignored...
70+ nitpicky = True
71+
6572autodoc_typehints = "description"
66- autodoc_type_aliases = { type_alias : f"{ type_alias } " for type_alias in {
67- "JSONObject"
73+ autodoc_type_aliases = { k : k for k in {
74+ "JSONObject" ,
75+ "SkippedMessageKeys"
6876} }
6977
78+ # https://github.com/sphinx-doc/sphinx/issues/10785
79+ def resolve_type_aliases (app , env , node , contnode ):
80+ """Resolve :class: references to our type aliases as :attr: instead."""
81+ if (
82+ node ["refdomain" ] == "py"
83+ and node ["reftype" ] == "class"
84+ and node ["reftarget" ] in autodoc_type_aliases
85+ ):
86+ return app .env .get_domain ("py" ).resolve_xref (
87+ env , node ["refdoc" ], app .builder , "attr" , node ["reftarget" ], node , contnode
88+ )
89+
7090def autodoc_skip_member_handler (app , what , name , obj , skip , options ):
7191 # Skip private members, i.e. those that start with double underscores but do not end in underscores
7292 if name .startswith ("__" ) and not name .endswith ("_" ):
7393 return True
7494
75- # Could be achieved using exclude-members, but this is more comfy
76- if name in {
77- "__abstractmethods__" ,
78- "__dict__" ,
79- "__module__" ,
80- "__new__" ,
81- "__weakref__" ,
82- "_abc_impl"
83- }: return True
95+ # Other fixed names to always skip
96+ if name in { "_abc_impl" , "model_config" }:
97+ return True
8498
8599 # Skip __init__s without documentation. Those are just used for type hints.
86100 if name == "__init__" and obj .__doc__ is None :
@@ -90,3 +104,4 @@ def autodoc_skip_member_handler(app, what, name, obj, skip, options):
90104
91105def setup (app ):
92106 app .connect ("autodoc-skip-member" , autodoc_skip_member_handler )
107+ app .connect ("missing-reference" , resolve_type_aliases )
0 commit comments