本文整理汇总了Python中sphinx.application.Sphinx.connect方法的典型用法代码示例。如果您正苦于以下问题:Python Sphinx.connect方法的具体用法?Python Sphinx.connect怎么用?Python Sphinx.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sphinx.application.Sphinx
的用法示例。
在下文中一共展示了Sphinx.connect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pytest_funcarg__app
# 需要导入模块: from sphinx.application import Sphinx [as 别名]
# 或者: from sphinx.application.Sphinx import connect [as 别名]
def pytest_funcarg__app(request):
"""
A Sphinx application for testing.
The app uses the source directory from the ``srcdir`` funcarg, and writes
to the directories given by the ``outdir`` and ``doctreedir`` funcargs.
Additional configuration values can be inserted into this application
through the ``confoverrides`` funcarg.
If the marker ``mock_lookup`` is attached to the current test, the lookup
callback returned by the ``mock_lookup`` funcarg is automatically connected
to the ``issuetracker-lookup-issue`` event in the the created application.
If the marker ``build_app`` is attached to the current test, the app is
build before returning it. Otherwise you need to build explicitly in order
to get the output.
"""
srcdir = request.getfuncargvalue('srcdir')
outdir = request.getfuncargvalue('outdir')
doctreedir = request.getfuncargvalue('doctreedir')
confoverrides = request.getfuncargvalue('confoverrides')
app = Sphinx(str(srcdir), str(srcdir), str(outdir), str(doctreedir),
'html', confoverrides=confoverrides, status=None,
warning=None, freshenv=True)
request.addfinalizer(reset_global_state)
if 'mock_lookup' in request.keywords:
lookup_mock_issue = request.getfuncargvalue('mock_lookup')
app.connect(str('issuetracker-lookup-issue'), lookup_mock_issue)
if 'build_app' in request.keywords:
app.build()
return app
示例2: setup
# 需要导入模块: from sphinx.application import Sphinx [as 别名]
# 或者: from sphinx.application.Sphinx import connect [as 别名]
def setup(app: Sphinx):
def cut_module_meta(app, what, name, obj, options, lines):
"""Remove metadata from autodoc output."""
if what != 'module':
return
lines[:] = [
line for line in lines
if not line.startswith((':copyright:', ':license:'))
]
app.connect('autodoc-process-docstring', cut_module_meta)
示例3: open
# 需要导入模块: from sphinx.application import Sphinx [as 别名]
# 或者: from sphinx.application.Sphinx import connect [as 别名]
if fieldType == 'type':
fieldArg = field['fieldArg']
if fieldArg in params:
params[fieldArg] = field['fieldText']
shortName = name.split('.')[-1]
string = 'def {0}({1}) -> {2}: ...\n\n'.format(
shortName,
', '.join(
['%s: %s' % (param, params[param]) for param in params]),
returnType if returnType else 'Any')
if filename:
with open(filename, 'a') as f:
f.write(string)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--output', '-o', action='store', help='location of stubs file')
args = parser.parse_args()
if args.output:
global filename
filename = args.output
if not os.path.exists(os.path.dirname(filename)):
os.makedirs(os.path.dirname(filename))
with open(filename, 'w') as f:
f.write('from typing import Any\n\n')
app = Sphinx(srcdir, confdir, outdir, doctreedir, buildername, freshenv=True)
app.connect('autodoc-process-docstring', process_docstring)
app.build()