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+ }
47+
4348# Add any paths that contain templates here, relative to this directory.
4449templates_path = [ "_templates" ]
4550
6166
6267# -- Autodoc Configuration ---------------------------------------------------------------
6368
64- # The following two options seem to be ignored...
69+ nitpicky = True
70+
6571autodoc_typehints = "description"
66- autodoc_type_aliases = { type_alias : f"{ type_alias } " for type_alias in {
67- "Priv" ,
68- "Seed" ,
72+ autodoc_type_aliases = { k : k for k in {
73+ "JSONType" ,
6974 "Ed25519Pub" ,
70- "JSONType"
75+ "Priv" ,
76+ "Seed"
7177} }
7278
79+ # https://github.com/sphinx-doc/sphinx/issues/10785
80+ def resolve_type_aliases (app , env , node , contnode ):
81+ """Resolve :class: references to our type aliases as :attr: instead."""
82+ if (
83+ node ["refdomain" ] == "py"
84+ and node ["reftype" ] == "class"
85+ and node ["reftarget" ] in autodoc_type_aliases
86+ ):
87+ return app .env .get_domain ("py" ).resolve_xref (
88+ env , node ["refdoc" ], app .builder , "attr" , node ["reftarget" ], node , contnode
89+ )
90+
7391def autodoc_skip_member_handler (app , what , name , obj , skip , options ):
7492 # Skip private members, i.e. those that start with double underscores but do not end in underscores
7593 if name .startswith ("__" ) and not name .endswith ("_" ):
7694 return True
7795
78- # Could be achieved using exclude-members, but this is more comfy
79- if name in {
80- "__abstractmethods__" ,
81- "__dict__" ,
82- "__module__" ,
83- "__new__" ,
84- "__weakref__" ,
85- "_abc_impl"
86- }: return True
96+ # Other fixed names to always skip
97+ if name in { "_abc_impl" }:
98+ return True
8799
88100 # Skip __init__s without documentation. Those are just used for type hints.
89101 if name == "__init__" and obj .__doc__ is None :
@@ -93,3 +105,4 @@ def autodoc_skip_member_handler(app, what, name, obj, skip, options):
93105
94106def setup (app ):
95107 app .connect ("autodoc-skip-member" , autodoc_skip_member_handler )
108+ app .connect ("missing-reference" , resolve_type_aliases )
0 commit comments