如何为 Sphinx 添加来自 google 的字体

问题描述 投票:0回答:1

我尝试将谷歌的字体添加到Sphinx,这个字体在这里。到目前为止,我已经尝试遵循这篇文章的说明(在评论中),并做到了这一点:

  1. 创建一个名为

    styles.css
    的文件,并将此代码放入其中,从谷歌导入我的字体:

    @import url('https://fonts.google.com/specimen/Sorts+Mill+Goudy?query=goudy+old+style');
    
  2. 将此行代码放在里面

    conf.py
    :

    def setup(app):
        app.add_stylesheet('styles.css')
    
  3. 使用

    make html
    构建 Sphinx 文件。当我尝试这样做时,我遇到了一个错误,说:

    Running Sphinx v7.4.7
    loading translations [en]... done
    /Users/jonathanfong/DocStrings/venv/lib/python3.9/site-packages/urllib3/__init__.py:35: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
      warnings.warn(
    
    Exception occurred:
      File "/Users/jonathanfong/DocStrings/docs/source/conf.py", line 33, in setup
        app.add_stylesheet('styles.css')
    AttributeError: 'Sphinx' object has no attribute 'add_stylesheet'
    The full traceback has been saved in /var/folders/qz/dxx7vhbd37535w1c245jwdm80000gp/T/sphinx-err-79u1zqel.log, if you want to report the issue to the developers.
    Please also report this if it was a user error, so that a better error message can be provided next time.
    A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
    make: *** [html] Error 2
    

    我导入字体时做错了什么吗?而且原帖的说明有点不清楚,所以我很困惑。

任何和所有的帮助将不胜感激。

documentation python-sphinx
1个回答
0
投票

Sphinx 6.0 中删除了

add_stylesheet()
方法。请使用
add_css_file()
来代替。

另请参阅 https://www.sphinx-doc.org/en/master/extdev/deprecated.html

© www.soinside.com 2019 - 2024. All rights reserved.