如何访问``conf.py''中的“ sphinx -build -t abc”之类的标签?

发布于 2025-02-09 04:51:45 字数 578 浏览 0 评论 0原文

根据sphinx的文档,tags对象在conf.py master )。但是,我得到:attributeError:'nontype'对象没有属性'有'

conf.py

if tags.has('abc'):

pip list

Package      Version
------------ ---------
Sphinx       5.0.2

如何访问标签sphinx -build -t abcconf.py中?

According to Sphinx' documentation there is a tags object available in conf.py (master). However, I get: AttributeError: 'NoneType' object has no attribute 'has'

conf.py:

if tags.has('abc'):

pip list:

Package      Version
------------ ---------
Sphinx       5.0.2

How to access tags like sphinx-build -t abc in conf.py?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

葬花如无物 2025-02-16 04:51:45

in conf.py中检查

if 'abc' in tags.tags.keys():
  # do some magic

'

if tags.tags.get('abc', False):
  # do some magic

您可以在'abc' 由Sphinx注射到构建过程中conf.py中,没有任何导入。

You can check for 'abc' in conf.py like this:

if 'abc' in tags.tags.keys():
  # do some magic

or if you need to check the boolean value of your tag:

if tags.tags.get('abc', False):
  # do some magic

tags get injected by Sphinx into the conf.py during a build and is available without any import.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文