本文整理汇总了Python中sphinx.ext.autodoc.cut_lines函数的典型用法代码示例。如果您正苦于以下问题:Python cut_lines函数的具体用法?Python cut_lines怎么用?Python cut_lines使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cut_lines函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup
def setup(app):
app.connect("autodoc-process-docstring", cut_lines(
pre=1,
post=11,
what=["module"]
))
app.connect("autodoc-process-docstring", cut_lines(
pre=1,
what=["module","class","method","function","attribute","data","exception"]
))
示例2: setup
def setup(app):
from sphinx.ext.autodoc import cut_lines
app.connect('autodoc-process-docstring', cut_lines(4, what=['module']))
app.add_description_unit('directive', 'dir', 'pair: %s; directive', parse_directive)
app.add_description_unit('role', 'role', 'pair: %s; role', parse_role)
app.add_description_unit('confval', 'confval', 'pair: %s; configuration value')
app.add_description_unit('event', 'event', 'pair: %s; event', parse_event)
示例3: setup
def setup(app):
# Avoid print the copyright intro in each module documentation
from sphinx.ext.autodoc import cut_lines
app.connect('autodoc-process-docstring', cut_lines(15, what=['module']))
# Generate the meos documentation files
app.connect('builder-inited', Autogenerate_MEoS)
示例4: setup
def setup(app):
from sphinx.ext.autodoc import cut_lines
app.connect('autodoc-process-docstring', cut_lines(4, what=['module']))
app.add_description_unit('confval', 'confval',
objname='configuration value',
indextemplate='pair: %s; configuration value')
app.add_description_unit('event', 'event', 'pair: %s; event', parse_event)
示例5: setup
def setup(app):
from sphinx.ext.autodoc import cut_lines
app.connect(b'autodoc-process-docstring', cut_lines(4, what=['module']))
app.add_object_type(
b'confval', 'confval',
objname='configuration value',
indextemplate='pair: %s; configuration value')
示例6: setup
def setup(app):
from sphinx.ext.autodoc import between, cut_lines
global autodoc_lang
if "autodoc_lang" in app.config.overrides:
autodoc_lang = app.config.overrides["autodoc_lang"]
app.connect("autodoc-process-docstring", between("\.\.\s\[(/|)" + autodoc_lang + "\].*", ["function"]))
app.connect("autodoc-process-docstring", cut_lines(1, what=["function"]))
示例7: setup
def setup(app):
from sphinx.ext.autodoc import cut_lines
from sphinx.util.docfields import GroupedField
app.connect("autodoc-process-docstring", cut_lines(4, what=["module"]))
app.add_object_type(
"confval", "confval", objname="configuration value", indextemplate="pair: %s; configuration value"
)
fdesc = GroupedField("parameter", label="Parameters", names=["param"], can_collapse=True)
app.add_object_type("event", "event", "pair: %s; event", parse_event, doc_field_types=[fdesc])
示例8: setup
def setup(app):
from sphinx.ext.autodoc import cut_lines
from sphinx.util.docfields import GroupedField
app.connect('autodoc-process-docstring', cut_lines(4, what=['module']))
app.add_object_type('confval', 'confval',
objname='configuration value',
indextemplate='pair: %s; configuration value')
fdesc = GroupedField('parameter', label='Parameters',
names=['param'], can_collapse=True)
app.add_object_type('event', 'event', 'pair: %s; event', parse_event,
doc_field_types=[fdesc])
示例9: test_docstring_processing
def test_docstring_processing():
def process(objtype, name, obj):
inst = AutoDirective._registry[objtype](directive, name)
inst.object = obj
inst.fullname = name
return list(inst.process_doc(inst.get_doc()))
class E:
def __init__(self):
"""Init docstring"""
# docstring processing by event handler
assert process("class", "bar", E) == ["Init docstring", "", "42", ""]
lid = app.connect("autodoc-process-docstring", cut_lines(1, 1, ["function"]))
def f():
"""
first line
second line
third line
"""
assert process("function", "f", f) == ["second line", ""]
app.disconnect(lid)
lid = app.connect("autodoc-process-docstring", between("---", ["function"]))
def g():
"""
first line
---
second line
---
third line
"""
assert process("function", "g", g) == ["second line", ""]
app.disconnect(lid)
lid = app.connect("autodoc-process-docstring", between("---", ["function"], exclude=True))
def h():
"""
first line
---
second line
---
third line
"""
assert process("function", "h", h) == ["first line", "third line", ""]
app.disconnect(lid)
示例10: test_docstring_processing
def test_docstring_processing():
def process(objtype, name, obj):
inst = AutoDirective._registry[objtype](directive, name)
inst.object = obj
inst.fullname = name
return list(inst.process_doc(inst.get_doc()))
class E:
def __init__(self):
"""Init docstring"""
# docstring processing by event handler
assert process('class', 'bar', E) == ['Init docstring', '', '42', '']
lid = app.connect('autodoc-process-docstring',
cut_lines(1, 1, ['function']))
def f():
"""
first line
second line
third line
"""
assert process('function', 'f', f) == ['second line', '']
app.disconnect(lid)
lid = app.connect('autodoc-process-docstring', between('---', ['function']))
def g():
"""
first line
---
second line
---
third line
"""
assert process('function', 'g', g) == ['second line', '']
app.disconnect(lid)
lid = app.connect('autodoc-process-docstring',
between('---', ['function'], exclude=True))
def h():
"""
first line
---
second line
---
third line
"""
assert process('function', 'h', h) == ['first line', 'third line', '']
app.disconnect(lid)
示例11: setup
def setup(app):
from sphinx.ext.autodoc import cut_lines
from sphinx.util.docfields import GroupedField
app.connect('autodoc-process-docstring', cut_lines(4, what=['module']))
app.add_object_type('confval', 'confval',
objname='configuration value',
indextemplate='pair: %s; configuration value')
fdesc = GroupedField('parameter', label='Parameters',
names=['param'], can_collapse=True)
app.add_object_type('event', 'event', 'pair: %s; event', parse_event,
doc_field_types=[fdesc])
# workaround for RTD
from sphinx.util import logging
logger = logging.getLogger(__name__)
app.info = lambda *args, **kwargs: logger.info(*args, **kwargs)
app.warn = lambda *args, **kwargs: logger.warning(*args, **kwargs)
app.debug = lambda *args, **kwargs: logger.debug(*args, **kwargs)
示例12: test_docstring_processing_functions
def test_docstring_processing_functions():
lid = app.connect('autodoc-process-docstring', cut_lines(1, 1, ['function']))
def f():
"""
first line
second line
third line
"""
assert list(gen.get_doc('function', 'f', f)) == ['second line', '']
app.disconnect(lid)
lid = app.connect('autodoc-process-docstring', between('---', ['function']))
def f():
"""
first line
---
second line
---
third line
"""
assert list(gen.get_doc('function', 'f', f)) == ['second line', '']
app.disconnect(lid)
示例13: setup
def setup(app):
#remove first line of module docstrings - it's module title
from sphinx.ext.autodoc import cut_lines
app.connect('autodoc-process-docstring', cut_lines(1, what=['module']))
示例14: setup
def setup(app):
from sphinx.ext.autodoc import cut_lines
app.connect("autodoc-process-docstring", cut_lines(4, 2, what=["module"]))
示例15: setup
def setup(app):
from sphinx.ext.autodoc import cut_lines
app.connect('autodoc-process-docstring', cut_lines(2, what=['module']))