Skip to content

Commit e80795f

Browse files
Merge pull request #1682 from gooddata/snapshot-master-4b2c4f30-to-rel/dev
[bot] Merge master/4b2c4f30 into rel/dev
2 parents f0c2161 + 4b2c4f3 commit e80795f

2 files changed

Lines changed: 31 additions & 5 deletions

File tree

scripts/docs/python_ref_builder.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,12 +368,18 @@ def _pass1(data_root: dict, dir_root: Path, api_ref_root: str, module_import_pat
368368

369369
elif name == "functions":
370370
for func_name in obj:
371-
if func_name.startswith("_") or func_name in links:
371+
if func_name.startswith("_"):
372372
continue
373-
links[func_name] = {
374-
"path": f"{api_ref_root}/{func_name}".lower(),
375-
"kind": "function",
376-
}
373+
# Dedup only the global links dict (used for docstring
374+
# linkification). Page creation must still happen for every
375+
# class, otherwise inherited methods shared across classes
376+
# (e.g. client_class) get a page under only the first class
377+
# while every other class emits a relative link that 404s.
378+
if func_name not in links:
379+
links[func_name] = {
380+
"path": f"{api_ref_root}/{func_name}".lower(),
381+
"kind": "function",
382+
}
377383
pages.append(
378384
_PageSpec(
379385
kind="function",

scripts/docs/tests/test_python_ref_builder.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,3 +398,23 @@ def test_duplicate_names_skipped(self, _mod, tmp_path):
398398
# Should not raise — second "Shared" is skipped
399399
_mod.create_file_structure(data, tmp_path, "/latest/api-reference")
400400
assert (tmp_path / "mod1" / "Shared" / "_index.md").exists()
401+
402+
def test_shared_method_gets_page_under_every_class(self, _mod, tmp_path):
403+
# Methods inherited across many classes (e.g. client_class) share a name.
404+
# Each class lists the method with a relative link, so each class must get
405+
# its own method page — deduping only affects the global links dict.
406+
method = {"kind": "function", "docstring_parsed": None, "signature": {}}
407+
data = {
408+
"mod1": {
409+
"kind": "module",
410+
"ClassA": {"kind": "class", "functions": {"client_class": dict(method)}},
411+
},
412+
"mod2": {
413+
"kind": "module",
414+
"ClassB": {"kind": "class", "functions": {"client_class": dict(method)}},
415+
},
416+
}
417+
_mod.create_file_structure(data, tmp_path, "/latest/api-reference")
418+
# Both classes must have their own client_class page (neither should 404).
419+
assert (tmp_path / "mod1" / "ClassA" / "client_class.md").exists()
420+
assert (tmp_path / "mod2" / "ClassB" / "client_class.md").exists()

0 commit comments

Comments
 (0)