Skip to content

Use bootstrap ScrollSpy with anchor using dots? #39248

@12rambau

Description

@12rambau

Prerequisites

Context

In the development of the pydata-sphinx-theme we use extensively twitter bootstrap to build the UI of a Sphinx generated documentation. When documenting Python API, the Autodoc plugin (that reads the Python docstring and transform it into a documentation page) creates anchors for functions that correspond to the exact path f the method: "pandas.DataFrame.from_csv". These points seems to be incompatible with the twitter bootstrap ScrollSpy tool as they are not interpreted as correct anchors.

For interested reader, see this thread for more context: pydata/pydata-sphinx-theme#1435

reproducible example

I created this small fiddle by adapting one of bootstrap example: https://codepen.io/12rambau/pen/rNovoyw

<div id="container" class="row">
  <div id="list-example" class="list-group col-4">
    <a class="list-group-item list-group-item-action" href="#item.1">Item 1</a>
    <a class="list-group-item list-group-item-action" href="#item.2">Item2</a>
    <a class="list-group-item list-group-item-action" href="#item.3">Item 3</a>
    <a class="list-group-item list-group-item-action" href="#item.4">Item 4</a>
  </div>
  <div class=col-8>
    <div data-spy="scroll" data-target="#list-example" data-offset="0" class="scrollspy-example">
      <h4 id="item.1">Item 1</h4>
      <p> ... </p>
      <h4 id="item.2">Item 2</h4>
      <p> ...</p>
      <h4 id="item.3">Item 3</h4>
      <p> ... </p>
      <h4 id="item.4">Item 4</h4>
      <p> ... </p>
    </div>
  </div>
</div>

As you see it's simply not working as I replaced the target names by "item.1" instead of "item 1".

Going down this issue, it seems related to how uri are parsed in bootstrap. Is there any will to support my use case ? if yes how can I help, if not do you see a workaround that would not imply using custom scrollspy ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions