def add_generic_role(self, name: str, nodeclass: Any, override: bool = False) -> None: """Register a generic Docutils role. Register a Docutils role that does nothing but wrap its contents in the node given by *nodeclass*. .. versionadded:: 0.6 .. versionchanged:: 1.8 Add *override* keyword. """ # Don't use ``roles.register_generic_role`` because it uses # ``register_canonical_role``. logger.debug('[app] adding generic role: %r', (name, nodeclass)) if not override and docutils.is_role_registered(name): logger.warning( __('role %r is already registered, it will be overridden'), name, type='app', subtype='add_generic_role') role = roles.GenericRole(name, nodeclass) docutils.register_role(name, role)
def add_generic_role(self, name, nodeclass): # don't use roles.register_generic_role because it uses # register_canonical_role self.debug('[app] adding generic role: %r', (name, nodeclass)) role = roles.GenericRole(name, nodeclass) roles.register_local_role(name, role)
optional_arguments = 0 final_argument_whitespace = True option_spec = { 'width': directives.nonnegative_int, 'height': directives.nonnegative_int } def run(self): set_classes(self.options) node = role_video(source=self.arguments[0], **self.options) return [node] generic_docroles = {'doc': role_doc} for rolename, nodeclass in generic_docroles.items(): generic = roles.GenericRole(rolename, nodeclass) role = roles.CustomRole(rolename, generic, {'classes': [rolename]}) roles.register_local_role(rolename, role) directives.register_directive('video', VideoDirective) Builder.load_string(''' #:import parse_color kivy.parser.parse_color <RstDocument>: content: content scatter: scatter do_scroll_x: False canvas.before:
def add_generic_role(self, name, nodeclass): # don't use roles.register_generic_role because it uses # register_canonical_role role = roles.GenericRole(name, nodeclass) roles.register_local_role(name, role)
import tempfile from mappyfile.tokens import COMPOSITE_NAMES, ATTRIBUTE_NAMES, SINGLETON_COMPOSITE_NAMES import logging import re import pprint from docutils.parsers.rst import directives, roles, nodes, Directive #from sphinx.directives.other import VersionChange #tmpdir = tempfile.mkdtemp() #from sphinx.application import Sphinx #app = Sphinx(srcdir=tmpdir, confdir=None, outdir=tmpdir, doctreedir=tmpdir, buildername='dummy', status=None) roles.register_local_role("ref", roles.GenericRole("ref", nodes.reference)) """ from sphinx.application import Sphinx class VersionChangeMock(VersionChange): def run(self): self.state.document.settings.env = app.env return super(VersionChangeMock, self).run() directives.register_directive("deprecated", VersionChangeMock) """ # http://www.mapserver.org/mapfile/expressions.html spatial_functions = [
import sys from docutils.parsers.rst import roles from docutils import nodes role = roles.GenericRole('gk', nodes.emphasis) #roles.register_local_role('gk', role)