本文整理汇总了Python中docutils.transforms.references.TargetNotes方法的典型用法代码示例。如果您正苦于以下问题:Python references.TargetNotes方法的具体用法?Python references.TargetNotes怎么用?Python references.TargetNotes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类docutils.transforms.references
的用法示例。
在下文中一共展示了references.TargetNotes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: apply
# 需要导入模块: from docutils.transforms import references [as 别名]
# 或者: from docutils.transforms.references import TargetNotes [as 别名]
def apply(self):
doc = self.document
i = len(doc) - 1
refsect = copyright = None
while i >= 0 and isinstance(doc[i], nodes.section):
title_words = doc[i][0].astext().lower().split()
if 'references' in title_words:
refsect = doc[i]
break
elif 'copyright' in title_words:
copyright = i
i -= 1
if not refsect:
refsect = nodes.section()
refsect += nodes.title('', 'References')
doc.set_id(refsect)
if copyright:
# Put the new "References" section before "Copyright":
doc.insert(copyright, refsect)
else:
# Put the new "References" section at end of doc:
doc.append(refsect)
pending = nodes.pending(references.TargetNotes)
refsect.append(pending)
self.document.note_pending(pending, 0)
pending = nodes.pending(misc.CallBack,
details={'callback': self.cleanup_callback})
refsect.append(pending)
self.document.note_pending(pending, 1)
示例2: cleanup_callback
# 需要导入模块: from docutils.transforms import references [as 别名]
# 或者: from docutils.transforms.references import TargetNotes [as 别名]
def cleanup_callback(self, pending):
"""
Remove an empty "References" section.
Called after the `references.TargetNotes` transform is complete.
"""
if len(pending.parent) == 2: # <title> and <pending>
pending.parent.parent.remove(pending.parent)
示例3: run
# 需要导入模块: from docutils.transforms import references [as 别名]
# 或者: from docutils.transforms.references import TargetNotes [as 别名]
def run(self):
pending = nodes.pending(references.TargetNotes)
self.add_name(pending)
pending.details.update(self.options)
self.state_machine.document.note_pending(pending)
return [pending]