本文整理匯總了Python中sphinx.util.compat.Directive方法的典型用法代碼示例。如果您正苦於以下問題:Python compat.Directive方法的具體用法?Python compat.Directive怎麽用?Python compat.Directive使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sphinx.util.compat
的用法示例。
在下文中一共展示了compat.Directive方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: setup
# 需要導入模塊: from sphinx.util import compat [as 別名]
# 或者: from sphinx.util.compat import Directive [as 別名]
def setup(app):
setup.app = app
setup.config = app.config
setup.confdir = app.confdir
# app.add_stylesheet('css/md.css')
app.add_config_value('pandoc_from', ['markdown', 'mediawiki'], 'env')
# Directive pandoc:: [file.ext]
app.add_directive('pandoc', MakePandocDirective(''))
# Directive [type]:: [file.xyz] where type can be a pandoc type
# like 'markdown', 'mediawiki'
for from_type in setup.config.pandoc_from:
app.add_directive(from_type, MakePandocDirective(from_type))
return {
'parallel_read_safe' : True,
'parallel_write_safe' : True
}
示例2: create_template_factory
# 需要導入模塊: from sphinx.util import compat [as 別名]
# 或者: from sphinx.util.compat import Directive [as 別名]
def create_template_factory(app):
class TemplateDefinition(Directive):
has_content = True
required_arguments = 1
optional_arguments = 1
final_argument_whitespace = True
option_spec = {'yaml': directives.flag}
def run(self):
name = self.arguments[0]
defined_in = self.state.document.current_source
source_path = self.state.document.get('source')
# Register this directive as existing in the current document.
if not source_path in REGISTERED:
REGISTERED[source_path] = set()
if not name in REGISTERED[source_path]:
template = '\n'.join(self.content)
is_yaml = 'yaml' in self.options
directive = create_directive(name, template, defined_in, is_yaml)
app.add_directive(name, directive)
REGISTERED[source_path].add(name)
return []
return TemplateDefinition