Skip to content

Sphinx roles and directives not working in generated examples #1195

@tsbinns

Description

@tsbinns

I have a set of .py example files containing rst text blocks which I am trying to generate into a gallery of examples using sphinx-gallery. However, links for sphinx roles and directives are not being generated.

For example, I would expect ":class:my_project.my_class" in a text block to be converted to a link to this class in my documentation's API, however it remains as the raw text ":class:my_project.my_class" in the generated example files. Similarly, citations to bibiliography entries using ":footcite:" also do not render correctly. I have no issues using these roles and directives elswehere in the documentation, and there are no warnings from sphinx that the objects referenced within the example files cannot be found.

I have compared my config settings with other projects where I know these roles to be working in the generated examples, however I do not notice anything which I am obviously doing wrong. For building the documentation, I am using the following settings:

extensions = [
    "sphinx.ext.mathjax",
    "sphinx.ext.autosectionlabel",
    "sphinx.ext.autodoc",
    "sphinx.ext.autosummary",
    "sphinx.ext.linkcode",
    "sphinx.ext.intersphinx",
    "numpydoc",
    "nbsphinx",
    "nbsphinx_link",
    "sphinxcontrib.bibtex",
    "sphinx_gallery.gen_gallery",
]

source_suffix = [".rst", ".md"]

sphinx_gallery_conf = {
    "examples_dirs": "../../examples",
    "gallery_dirs": "auto_examples",
}

The only thing I have noticed is that the sources of the auto_example html files have the suffix .ipynb.txt, whereas in other projects I have seen this as .rst.txt, e.g. build/html/auto_examples/plot_compute_my_example.html has source build/html/_sources/auto_examples/plot_compute_my_example.ipynb.txt. I have no idea how to specify the source files to be .rst.txt files, so I cannot test if this is what is causing the problem.

I'm really stumped with this one, so any help is greatly appreciated. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions