executablebooks / sphinx-panels

A sphinx extension for creating panels in a grid layout
https://sphinx-panels.readthedocs.io
MIT License
83 stars 20 forks source link

Add support for adding/generating ids for sphinx-panels elements, to allow direct linking #56

Open CAM-Gerlach opened 3 years ago

CAM-Gerlach commented 3 years ago

Is your feature request related to a problem? Please describe.

The Sphinx-Panels components, particularly dropdown, are very useful for constructing pages like FAQs, where linking directly to the resulting elements would be very useful. For example, we use Sphinx-Panels several places on the new docs site for the Spyder IDE, including the FAQ, where we want to be able to link users directly to specific questions.

Describe the solution you'd like

If an :id: property was added, that would allow us to either link directly to a question by id, or at least use the id to uniquely identify the element, such that we can more easily use a bit of JS to scroll to and open a specified dropdown by id. In addition, an option to to statically generate a displayed link anchor (see mockup below) to allow easy copy/pasting of the link elsewhere would be useful (though I'm not sure how you would want to style it by default; our current plan is to use a FA link icon).

Describe alternatives you've considered

For now, we're in the process of implementing by adding a unique class to each element as a "pseudo-id" and then using JS add the ids and the link anchors, but that's a crude hack that misuses HTML properties, Ultimately, in our particular application we're still going to need JS to reposition the scroll position to avoid the navbar and automatically open the linked question, but for most use cases adding an id and an anchor will be sufficient, and this will still simplify things for us considerably. Thanks.

Additional context

Example of link anchor (style, or implementation to begin with may be out of scope for sphinx-panels, but wanted to mention it just in case).

image

welcome[bot] commented 3 years ago

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

chrisjsewell commented 3 years ago

Thanks @CAM-Gerlach, yep that sounds like it should be quite possible 👍

junngo commented 3 years ago

Hello @chrisjsewell :) I have a question. I don't think this function is made yet. Is there any alternative method or plan to make this function?

Thank you for making a great library.