sphinx-doc/sphinx
View on GitHubDRY: refactor common functionality in generating index nodes
Open
#2914 opened on Aug 26, 2016
good first issuehelp wantedtype:enhancement
Description
I am trying to write a simple extension to automatically add some index nodes. Unfortunately there doesn't seem to be any base function to do that. I found three places where the same essential stuff is being used to add index nodes to the toctree:
- https://github.com/sphinx-doc/sphinx/blob/3639231cec9e3e8e0ec80e38430566527f312fd6/sphinx/domains/std.py#L95
- https://github.com/sphinx-doc/sphinx/blob/84baf05c4f9c3ff3f17779fe522cec7aa444b2f8/sphinx/roles.py#L170
- https://github.com/sphinx-doc/sphinx/blob/84baf05c4f9c3ff3f17779fe522cec7aa444b2f8/sphinx/directives/other.py#L163
So it looks like I have to copy the appropriate implementation pieces of this (add a target node, add an index node, configure each of them).
It would be really useful to refactor the common functionality into a single, simple function that extensions could use.