readthedocs / sphinx_rtd_theme

Sphinx theme from Read the Docs
https://sphinx-rtd-theme.readthedocs.io/
MIT License
4.7k stars 1.72k forks source link

Highlight linked anchor #869

Open stsewd opened 4 years ago

stsewd commented 4 years ago

I like this from the pip docs https://pip.pypa.io/en/stable/reference/pip_wheel/#cmdoption-i

Screenshot_2020-01-16 pip wheel — pip 19 3 1 documentation

The linked anchor gets highlighted, so is easy to see the exact section that was linked. When several anchors are at the bottom of a page is hard to realize the exact section that was linked, for example https://docs.readthedocs.io/en/stable/guides/specifying-dependencies.html#using-the-project-admin-dashboard

One user proposed a solution in https://github.com/readthedocs/sphinx_rtd_theme/issues/877

agjohnson commented 3 years ago

@nienn To expand on this issue a bit more:

We can't yet target definition list terms, because those elements don't always have id attributes. They have id attributes in the pip docs link above because Pip uses a special Sphinx extension to output these blocks. This would be a next step later.

agjohnson commented 3 years ago

We might also consider a general approach eventually, using :target pseudo class. This would maybe (?) allow for generic targeting. We do for instance have id attr on API docs, ie: https://sphinx-rtd-theme.readthedocs.io/en/stable/demo/api.html#test_py_module.test.Foo.add