Search code examples
python-sphinxrestructuredtext

How to override seealso:: directive in Sphinx?


I'm using Sphinx in a project and I wanna change 'See also' title in top of the seealso::'s box in the template. I also searched a little in the codes and saw the SeeAlso class in the Sphinx library but I have no idea how to override it and change the title.


Solution

  • Well, I finally found a way that I think is the simple one!

    My question was to be able to change the title of sphinx specific admonitions like seealso::

    In the locale folder (sphinx/locale/__init__.py) , there is a dictionary named admonitionlabels, that the titles are defined here.

    To change it in the project, we just add this code in the project's config.py:

    from sphinx import locale
    locale.admonitionlabels['seealso'] = 'new title'
    

    and when we use make html sphinx will apply our new title to the project