Skip to content

Fix Lunr search links for inherited members - #482

Open
2836048681 wants to merge 1 commit into
pdoc3:masterfrom
2836048681:fix/416-inherited-search-links
Open

2836048681 wants to merge 1 commit into
pdoc3:masterfrom
2836048681:fix/416-inherited-search-links

Conversation

@2836048681

Copy link
Copy Markdown

PR body

Lunr search results for inherited members can point to the base class page with a subclass anchor. For example, clicking Class2.get_a() opens the Class1 page but cannot jump to the method section.

Use the same documented member to choose both the page and the anchor. By default, inherited results jump to the ancestor's section. With show_inherited_members=True, they jump to the member rendered on the subclass page. Results still display the name that matched the search.

Fixes #416.

Test evidence

  • python -m unittest -v pdoc.test.CliTest.test_lunr_search_inherited_links passed. Before the fix, the regression failed for five inherited entries. The test covers a method, a property, two levels of inheritance, and an override, and checks that each target anchor exists in the generated HTML.
  • python -m unittest -v pdoc.test passed on Python 3.12. It ran 84 tests with two skips and one expected failure. Output is in w08/tmp/pdoc-fixed.log.
  • Ran the generated search page's JavaScript against both the prebuilt and browser-built Lunr indexes with both settings for show_inherited_members. All four combinations returned links to real anchors. Output is in w08/tmp/pdoc-rendered-search.log.
  • flake8 pdoc setup.py and git diff --check passed.

This branch has not been deployed

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Wrong search hyperlinks to page sections for inherited classes

1 participant