Skip to content

fix(docs): generate method sub-pages for every class in API reference#1678

Open
czechian wants to merge 1 commit into
gooddata:masterfrom
czechian:fix/api-ref-shared-method-links
Open

fix(docs): generate method sub-pages for every class in API reference#1678
czechian wants to merge 1 commit into
gooddata:masterfrom
czechian:fix/api-ref-shared-method-links

Conversation

@czechian

@czechian czechian commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Inherited methods shared across many catalog classes (e.g. client_class, from_api, to_dict) share a name. The API reference builder deduped by the global links dict and skipped page creation for all but the first class, yet every class still rendered a relative link to its own method sub-page (), producing 404s on all other classes.

Dedup now applies only to the global links dict used for docstring linkification; each class always gets its own method sub-pages.

Summary by CodeRabbit

  • Bug Fixes
    • Improved documentation page generation so shared or inherited functions appear under each relevant class instead of being omitted after the first occurrence.
    • Fixed duplicate handling to keep global links consistent while still generating all expected function pages.
  • Tests
    • Added coverage for classes that share a method name, ensuring each class gets its own reference page.

Inherited methods shared across many catalog classes (e.g. client_class,
from_api, to_dict) share a name. The API reference builder deduped by the
global links dict and skipped page creation for all but the first class,
yet every class still rendered a relative link to its own method sub-page
(<a href=client_class/>), producing 404s on all other classes.

Dedup now applies only to the global links dict used for docstring
linkification; each class always gets its own method sub-pages.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@czechian czechian requested review from hkad98, lupko and pcerny as code owners July 1, 2026 13:44
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Modified _pass1 in the Python doc reference builder so it deduplicates only the global links dictionary entry for functions, while still emitting a page spec for every function encountered, including inherited/shared methods across classes. Added a unit test validating this behavior.

Changes

Shared Method Page Generation Fix

Layer / File(s) Summary
Deduplicate links dict only, always emit page specs
scripts/docs/python_ref_builder.py
_pass1 now skips items only for private function names; it still deduplicates the global links entry but always appends a page spec, so shared method names across classes each get their own page.
Test for per-class method pages
scripts/docs/tests/test_python_ref_builder.py
Adds test_shared_method_gets_page_under_every_class, verifying two classes with a same-named method (client_class) each get their own generated markdown page.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Poem

A hop, a skip, a shared method's page,
No longer lost in dedup's cage!
ClassA and ClassB, each gets its due,
A markdown file, fresh and new,
This bunny thumps with pure delight 🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: generating method sub-pages for every class in the API reference.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
scripts/docs/python_ref_builder.py (1)

378-382: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Global links entry for shared method names always points to the first class encountered.

Since links[func_name] is only set once (first class wins), any docstring link resolution for that function name (e.g. from ClassB's docstring referencing client_class) will still resolve to ClassA's page — no longer 404 but potentially the wrong class's page. This is an inherent limitation of a single global links map for shared names, not a regression from this diff, but worth flagging as a known caveat.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/docs/python_ref_builder.py` around lines 378 - 382, The shared-name
entry in the global links map is a known limitation in python_ref_builder.py:
once links[func_name] is set by the first class, later same-named methods
resolve to the wrong class page. Update the link-resolution logic around the
links[func_name] assignment in the docstring/reference builder to disambiguate
by class context instead of relying on a single global function name key, or
explicitly document this first-class-wins caveat if you are not changing
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@scripts/docs/python_ref_builder.py`:
- Around line 378-382: The shared-name entry in the global links map is a known
limitation in python_ref_builder.py: once links[func_name] is set by the first
class, later same-named methods resolve to the wrong class page. Update the
link-resolution logic around the links[func_name] assignment in the
docstring/reference builder to disambiguate by class context instead of relying
on a single global function name key, or explicitly document this
first-class-wins caveat if you are not changing behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ee9becea-e5a8-4ddd-85cc-14c385bb534a

📥 Commits

Reviewing files that changed from the base of the PR and between bb355b3 and 2299bb7.

📒 Files selected for processing (2)
  • scripts/docs/python_ref_builder.py
  • scripts/docs/tests/test_python_ref_builder.py

@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.21%. Comparing base (bb355b3) to head (2299bb7).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1678   +/-   ##
=======================================
  Coverage   79.21%   79.21%           
=======================================
  Files         232      232           
  Lines       15809    15809           
=======================================
  Hits        12523    12523           
  Misses       3286     3286           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant