@@ -279,8 +279,15 @@ def get_grouped_documenters(self, all_members=False):
279279 self .options .update (options_save )
280280 return documenters
281281
282- def add_autosummary (self ):
283- """Add the autosammary table of this documenter."""
282+ def add_autosummary (self , relative_ref_paths = False ):
283+ """Add the autosammary table of this documenter.
284+
285+ Parameters
286+ ==========
287+ relative_ref_paths: bool
288+ Use paths relative to the current module instead of
289+ absolute import paths for each object
290+ """
284291 if (
285292 self .options .get ("autosummary" )
286293 and not self .options .get ("no-autosummary" )
@@ -303,8 +310,14 @@ def add_autosummary(self):
303310 indent = ' '
304311
305312 for (documenter , _ ) in documenters :
306- self .add_line (
307- indent + '~' + documenter .fullname , sourcename )
313+ if relative_ref_paths :
314+ obj_ref_path = documenter .fullname .lstrip (
315+ self .modname + '.' )
316+ else :
317+ obj_ref_path = documenter .fullname
318+
319+ self .add_line (indent + '~' + obj_ref_path , sourcename )
320+
308321 self .add_line ('' , sourcename )
309322
310323
@@ -351,7 +364,7 @@ class AutoSummModuleDocumenter(ModuleDocumenter, AutosummaryDocumenter):
351364 def add_content (self , * args , ** kwargs ):
352365 super ().add_content (* args , ** kwargs )
353366
354- self .add_autosummary ()
367+ self .add_autosummary (relative_ref_paths = True )
355368
356369 if self .options .get ("autosummary-no-nesting" ):
357370 self .options ["no-autosummary" ] = "True"
@@ -400,7 +413,7 @@ class AutoSummClassDocumenter(ClassDocumenter, AutosummaryDocumenter):
400413 def add_content (self , * args , ** kwargs ):
401414 super ().add_content (* args , ** kwargs )
402415
403- self .add_autosummary ()
416+ self .add_autosummary (relative_ref_paths = True )
404417
405418
406419class CallableDataDocumenter (DataDocumenter ):
0 commit comments