Skip to content

Commit 2926b95

Browse files
committed
fix: use method level as split point for paths
1 parent 4849631 commit 2926b95

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

autoapi/mappers/base.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,20 +359,18 @@ def output_child_rst(self, obj, obj_parent, detail_dir, source_suffix):
359359
# should be created for a class and its children:
360360
# detail_dir / obj_parent_name / index.rst (example/Foo/index.rst)
361361
# detail_dir / obj_parent_name / obj_name.rst (example/Foo/foo.rst)
362-
is_last_level = obj_child_page_level == desired_page_level
362+
own_page_level = self.app.config.autoapi_own_page_level
363363
if obj.type in ["exception", "class"]:
364-
if is_last_level:
364+
if own_page_level == "function":
365365
outfile = f"{obj.short_name}{source_suffix}"
366366
path = os.path.join(detail_dir, outfile)
367367
else:
368368
outdir = os.path.join(detail_dir, obj.short_name)
369369
ensuredir(outdir)
370370
path = os.path.join(outdir, f"index{source_suffix}")
371371
else:
372-
if detail_dir.endswith(obj_parent.short_name):
373-
outdir = detail_dir
374-
else:
375-
outdir = os.path.join(detail_dir, obj_parent.short_name)
372+
is_parent_in_detail_dir = detail_dir.endswith(obj_parent.short_name)
373+
outdir = detail_dir if is_parent_in_detail_dir else os.path.join(detail_dir, obj_parent.short_name)
376374
ensuredir(outdir)
377375
path = os.path.join(outdir, f"{obj.short_name}{source_suffix}")
378376

autoapi/templates/python/module.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Classes
134134
Do -> if 'function' not in own_page_types
135135
Instead of -> if "class" == (own_page_types | list | last)
136136
#}
137-
{% if "function" not in own_page_types %}
137+
{% if "method" not in own_page_types %}
138138
{{ klass.short_name }}.rst
139139
{% else %}
140140
{{ klass.short_name }}/index.rst

0 commit comments

Comments
 (0)