I have this issue with sphinx rendering shields.io badges. I am using sphinx and the read-the-docs template.

I want to add a series of badges in my index.rst file. The URLs correctly work in my README.md - found here - written in markdown, and do show the correct badge when opening them in the browser.

However, when i use the same links in the rst file, it looks like the output html has some sort of problem fetching information from shields.io. The badges do show, but either do not fetch information at all (like GitHubActions build and CodeCov coverage badges) or fetches correct info but do not render as requested (eg. pypi version being orange instead of blue)

This is how my badges render inside index.html:

This is how my badges render inside index.html

My rst is as following (made copying-pasting entries from the badge editor in shields.io website):

.. image:: https://img.shields.io/pypi/pyversions/mplStrater   :alt: PyPI - Python Version 

.. image:: https://img.shields.io/pypi/v/mplStrater?makecolor=blue :alt: PyPI - Version



.. image:: https://img.shields.io/github/release-date/giocaizzi/mplStrater :alt: GitHub Release Date

.. image:: https://img.shields.io/github/workflow/status/giocaizzi/mplStrater/mplStrater/main :alt: GitHub Workflow Status (branch)

.. image:: https://img.shields.io/codecov/c/github/giocaizzi/mplStrater :alt: Codecov

.. image:: https://requires.io/github/giocaizzi/mplStrater/requirements.svg?branch=main 
    :target: https://requires.io/github/giocaizzi/mplStrater/requirements/?branch=main
    :alt: Requirements Status

.. image:: https://img.shields.io/github/license/giocaizzi/mplStrater :alt: license

.. image:: https://img.shields.io/github/issues/giocaizzi/mplStrater :alt: issues

Edit:

Just to add a bit more context. I have also run the make linkcheck command and all the URLs are passing.

(           index: line   24) ok        https://img.shields.io/github/issues/giocaizzi/mplStrater:alt:issues
(           index: line   11) ok        https://img.shields.io/github/release-date/giocaizzi/mplStrater:alt:GitHubReleaseDate
(           index: line   21) ok        https://img.shields.io/github/license/giocaizzi/mplStrater:alt:license
(           index: line   15) ok        https://img.shields.io/codecov/c/github/giocaizzi/mplStrater:alt:Codecov
(           index: line    2) ok        https://requires.io/github/giocaizzi/mplStrater/requirements.svg?branch=main
(           index: line    9) ok        https://img.shields.io/pypi/v/mplStrater?makecolor=blue:alt:PyPI-Version
(           index: line   46) ok        https://github.com/giocaizzi
(           index: line   13) ok        https://img.shields.io/github/workflow/status/giocaizzi/mplStrater/mplStrater/main:alt:GitHubWorkflowStatus(branch)
(           index: line    5) ok        https://img.shields.io/pypi/pyversions/mplStrater:alt:PyPI-PythonVersion
(           index: line    2) ok        https://requires.io/github/giocaizzi/mplStrater/requirements/?branch=main

The environment i am using for working on the project and buidling the documentation is the following. The only strict requirement on documentations documentation packages is docutils=0.16 due to a bug not being resolved with bulletpoints in the read-the-docs template (as far as i have investigated).

name: geo
channels:
  - defaults
  - conda-forge
dependencies:
  - python=3.7
  - geopandas
  - matplotlib
  - numpy>=1.17
  - pandas
  - rasterio
  - rio-color
  - ipython
  - ipykernel
  - pytest
  - pytest-cov
  - sphinx
  - sphinx_rtd_theme
  - myst-parser
  - nbsphinx
  - docutils=0.16
1

There are 1 best solutions below

0
Pierrick Rambaud On

As suggested by @Steve piercy, the way you wrote the image badges doesn't respect .rst directive format:


.. directive:: main_arg
   :option1: value1
   :option2: value2

In your case the orginal .md badges where as follow:

[![Requirements Status](https://requires.io/github/giocaizzi/mplStrater/requirements.svg?branch=main)](https://requires.io/github/giocaizzi/mplStrater/requirements/?branch=main)

there are 3 information:

which can be easily set in .rst:

.. image:: https://requires.io/github/giocaizzi/mplStrater/requirements.svg?branch=main
   :alt: Requirements Status
   :target: https://requires.io/github/giocaizzi/mplStrater/requirements/?branch=main