99from typing import Literal , Optional , TypedDict , Union
1010
1111import quartodoc .ast as qast
12- from griffe import dataclasses as dc
13- from griffe import expressions as exp
14- from griffe .docstrings import dataclasses as ds
12+ from griffe import (
13+ Alias ,
14+ DocstringAttribute ,
15+ DocstringParameter ,
16+ DocstringSectionParameters ,
17+ DocstringSectionText ,
18+ Expr ,
19+ ExprName ,
20+ Function ,
21+ Object ,
22+ )
1523from plum import dispatch
1624from quartodoc import MdRenderer
1725from quartodoc .pandoc .blocks import DefinitionList
@@ -42,7 +50,7 @@ def render(self, el: qast.DocstringSectionSeeAlso):
4250 return prefix_bare_functions_with_func (el .value )
4351
4452 @dispatch
45- def render (self , el : Union [dc . Object , dc . Alias ]):
53+ def render (self , el : Union [Object , Alias ]):
4654 # If `el` is a protocol class that only has a `__call__` method,
4755 # then we want to display information about the method, not the class.
4856 if len (el .members ) == 1 and "__call__" in el .members .keys ():
@@ -78,7 +86,7 @@ def render(self, el: Union[dc.Object, dc.Alias]):
7886 return converted
7987
8088 @dispatch
81- def render (self , el : ds . DocstringSectionText ):
89+ def render (self , el : DocstringSectionText ):
8290 # functions like shiny.ui.tags.b have html in their docstrings, so
8391 # we escape them. Note that we are only escaping text sections, but
8492 # since these cover the top text of the docstring, it should solve
@@ -93,7 +101,7 @@ def render_annotation(self, el: str):
93101 # TODO-future; Can be removed once we use quartodoc 0.3.5
94102 # Related: https://github.com/machow/quartodoc/pull/205
95103 @dispatch
96- def render (self , el : ds . DocstringAttribute ):
104+ def render (self , el : DocstringAttribute ):
97105 row = [
98106 sanitize (el .name ),
99107 self .render_annotation (el .annotation ),
@@ -106,23 +114,23 @@ def render_annotation(self, el: None):
106114 return ""
107115
108116 @dispatch
109- def render_annotation (self , el : exp . Expr ):
110- # an expression is essentially a list[exp. ExprName | str]
117+ def render_annotation (self , el : Expr ):
118+ # an expression is essentially a list[ExprName | str]
111119 # e.g. Optional[TagList]
112120 # -> [Name(source="Optional", ...), "[", Name(...), "]"]
113121
114122 return "" .join (map (self .render_annotation , el ))
115123
116124 @dispatch
117- def render_annotation (self , el : exp . ExprName ):
125+ def render_annotation (self , el : ExprName ):
118126 # e.g. Name(source="Optional", full="typing.Optional")
119127 return f"[{ el .name } ](`{ el .canonical_path } `)"
120128
121129 @dispatch
122130 # Overload of `quartodoc.renderers.md_renderer` to fix bug where the descriptions
123131 # are cut off and never display other places. Fixing by always displaying the
124132 # documentation.
125- def summarize (self , obj : Union [dc . Object , dc . Alias ]) -> str :
133+ def summarize (self , obj : Union [Object , Alias ]) -> str :
126134 # get high-level description
127135 doc = obj .docstring
128136 if doc is None :
@@ -131,7 +139,7 @@ def summarize(self, obj: Union[dc.Object, dc.Alias]) -> str:
131139 docstring_parts = doc .parsed
132140
133141 if len (docstring_parts ) and isinstance (
134- docstring_parts [0 ], ds . DocstringSectionText
142+ docstring_parts [0 ], DocstringSectionText
135143 ):
136144 description = docstring_parts [0 ].value
137145
@@ -164,7 +172,7 @@ def summarize(self, obj: Union[dc.Object, dc.Alias]) -> str:
164172
165173 # Consolidate the parameter type info into a single column
166174 @dispatch
167- def render (self , el : ds . DocstringParameter ):
175+ def render (self , el : DocstringParameter ):
168176 param = f'<span class="parameter-name">{ el .name } </span>'
169177 annotation = self .render_annotation (el .annotation )
170178 if annotation :
@@ -178,14 +186,14 @@ def render(self, el: ds.DocstringParameter):
178186 return (param , el .description )
179187
180188 @dispatch
181- def render (self , el : ds . DocstringSectionParameters ):
189+ def render (self , el : DocstringSectionParameters ):
182190 rows = list (map (self .render , el .value ))
183191 # rows is a list of tuples of (<parameter>, <description>)
184192
185193 return str (DefinitionList (rows ))
186194
187195 @dispatch
188- def signature (self , el : dc . Function , source : Optional [dc . Alias ] = None ):
196+ def signature (self , el : Function , source : Optional [Alias ] = None ):
189197 if el .name == "__call__" :
190198 # Ex: experimental.ui._card.ImgContainer.__call__(self, *args: Tag) -> Tagifiable
191199 sig = super ().signature (el , source )
@@ -302,7 +310,7 @@ def is_no_ex_decorator(x):
302310 # Don't throw for things that can't be decorated
303311 return
304312
305- if not el .is_explicitely_exported :
313+ if not el .is_exported :
306314 # Don't require examples on "implicitly exported" functions
307315 # In practice, this covers methods of exported classes (class still needs ex)
308316 return
0 commit comments