Modifying content width of the Sphinx theme 'Read the Docs'

前端 未结 9 864
小鲜肉
小鲜肉 2020-12-13 18:04

I am using \'Read the Docs\' Sphinx theme for my documentation. In the original theme, given below

http://read-the-docs.readthedocs.org/en/latest/theme.html

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 18:34

    To make the ReadTheDocs theme use the entire width of your screen you can modify the theme.css file, removing the max-width: 800px; property from the wy-nav-content class definition, like so:

    .wy-nav-content {
        padding: 1.618em 3.236em;
        height: 100%;
        /* max-width: 800px; */
        margin: auto;
    }
    

    Some Notes

    • Source of theme.css is here:

      https://github.com/rtfd/readthedocs.org/blob/master/media/css/sphinx_rtd_theme.css

    • On your filesystem it will be in (assuming you've run:pip install sphinx_rtd_theme):

      lib/python2.7/site-packages/sphinx_rtd_theme/static/css/theme.css

    • To find the absolute path of theme.css on Linux/Mac you can run this on the command line (assuming you have set your $PYTHONPATH environment variable):

      for p in `echo $PYTHONPATH | tr ":" "\n"`; do 
          find $p -type f -name 'theme.css' | grep sphinx_rtd_theme
      done
      
    • The theme.css file will be minified so you can use a tool like http://unminify.com to make it easier to read.


    The results:

    Before:

    Unmodified readthedocs theme

    After:

    Modified readthedocs theme

提交回复
热议问题