4
4
import logging
5
5
6
6
from enum import Enum
7
- from pydantic import BaseModel , Field , Extra
7
+ from pydantic import BaseModel , Field , Extra , PrivateAttr
8
8
9
9
from typing_extensions import Annotated
10
10
from typing import Literal , Union , Optional
@@ -201,9 +201,13 @@ class ChoicesChildren(Enum):
201
201
linked = "linked"
202
202
203
203
204
+ SignatureOptions = Literal ["full" , "short" , "relative" ]
205
+
206
+
204
207
class AutoOptions (_Base ):
205
208
"""Options available for Auto content layout element."""
206
209
210
+ signature_path : SignatureOptions = "relative"
207
211
members : Optional [list [str ]] = None
208
212
include_private : bool = False
209
213
include_imports : bool = False
@@ -221,6 +225,15 @@ class AutoOptions(_Base):
221
225
dynamic : Union [None , bool , str ] = None
222
226
children : ChoicesChildren = ChoicesChildren .embedded
223
227
package : Union [str , None , MISSING ] = MISSING ()
228
+ member_options : Optional ["AutoOptions" ] = None
229
+
230
+ # for tracking fields users manually specify
231
+ # so we can tell them apart from defaults
232
+ _fields_specified : list [str ] = PrivateAttr (default = ())
233
+
234
+ def __init__ (self , ** kwargs ):
235
+ super ().__init__ (** kwargs )
236
+ self ._fields_specified = tuple (kwargs )
224
237
225
238
226
239
class Auto (AutoOptions ):
@@ -259,6 +272,8 @@ class Auto(AutoOptions):
259
272
Style for presenting members. Either separate, embedded, or flat.
260
273
package:
261
274
If specified, object lookup will be relative to this path.
275
+ member_options:
276
+ Options to apply to members. These can include any of the options above.
262
277
263
278
264
279
"""
@@ -320,6 +335,7 @@ class Doc(_Docable):
320
335
name : str
321
336
obj : Union [dc .Object , dc .Alias ]
322
337
anchor : str
338
+ signature_path : SignatureOptions = "relative"
323
339
324
340
class Config :
325
341
arbitrary_types_allowed = True
@@ -333,14 +349,20 @@ def from_griffe(
333
349
members = None ,
334
350
anchor : str = None ,
335
351
flat : bool = False ,
352
+ signature_path : str = "relative" ,
336
353
):
337
354
if members is None :
338
355
members = []
339
356
340
357
kind = obj .kind .value
341
358
anchor = obj .path if anchor is None else anchor
342
359
343
- kwargs = {"name" : name , "obj" : obj , "anchor" : anchor }
360
+ kwargs = {
361
+ "name" : name ,
362
+ "obj" : obj ,
363
+ "anchor" : anchor ,
364
+ "signature_path" : signature_path ,
365
+ }
344
366
345
367
if kind == "function" :
346
368
return DocFunction (** kwargs )
@@ -431,6 +453,7 @@ class Config:
431
453
Layout .update_forward_refs ()
432
454
Section .update_forward_refs ()
433
455
Page .update_forward_refs ()
456
+ AutoOptions .update_forward_refs ()
434
457
Auto .update_forward_refs ()
435
458
MemberPage .update_forward_refs ()
436
459
Interlaced .update_forward_refs ()
0 commit comments