How to use the sphinx.locale.l_ function in Sphinx

To help you get started, we’ve selected a few Sphinx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github russell / sphinxcontrib-cldomain / sphinxcontrib / cldomain.py View on Github external
class CLMethod(CLGeneric):

    option_spec = {
        'nodoc': bool_option,
        'noindex': bool_option,
        'noinherit': bool_option,
        'nospecializers': bool_option,
        'linkgeneric': bool_option,
    }

    doc_field_types = [
        Field('specializer', label=l_('Specializer'), has_arg=False,
              names=('specializer')),
        GroupedField('parameter', label=l_('Parameters'),
                     names=('param', 'parameter', 'arg', 'argument',
                            'keyword', 'kwparam')),
        Field('returnvalue', label=l_('Returns'), has_arg=False,
              names=('returns', 'return')),
    ]

    def get_index_name(self, name, type):
        package = self.env.temp_data.get('cl:package')
        specializer = self.arguments
        spec_args = qualify_sexp(package, specializer[0].split(" ")[1:])
        specializer = " ".join(spec_args)
        return type + ":" + name + "(" + specializer.lower() + ")"

    def get_index_text(self, name, type):
        specializer = self.arguments
        spec_args = specializer[0].split(" ")[1:]
github RedpointGames / Protogame / Protogame.Docs / _ext / netxml.py View on Github external
except ValueError:
      dot_start = -1
    refnode['refdomain']='std'
    refnode['reftype']='ref'
    refnode['refexplicit']=True
    return (target[dot_start+1:], ws_re.sub(' ', target.lower()))

class DotNetDomain(Domain):
  name = 'dotnet'
  label = 'dotnet'

  object_types = {
    #'package':     ObjType(l_('package'), 'package', 'ref'),
    'class':        ObjType(l_('class'), 'class', 'ref'),
    'enum':        ObjType(l_('enum'), 'enum', 'ref'),
    'interface':        ObjType(l_('interface'), 'interface', 'ref'),
    'struct':        ObjType(l_('struct'), 'struct', 'ref'),
    #'field':       ObjType(l_('field'), 'field', 'ref'),
    #'constructor': ObjType(l_('constructor'), 'construct', 'ref'),
    'method':      ObjType(l_('method'), 'method', 'ref'),
    'nproperty':      ObjType(l_('property'), 'property', 'ref'),
    'nfield':      ObjType(l_('field'), 'field', 'ref'),
  }

  directives = {
    #'package':        JavaPackage,
    'class':          DotNetClass,
    'struct':          DotNetStruct,
    'interface':      DotNetInterface,
    'enum':          DotNetEnum,
    #'field':          JavaField,
    #'constructor':    JavaConstructor,
github aldebaran / libqi / doc / mycpp.py View on Github external
signode += nodes.Text(' ')
        self.attach_name(signode, obj.name)
        self.attach_type_suffixes(signode, obj.type_suffixes)
        if obj.value is not None:
            signode += nodes.Text(u' = ' + obj.value)


class CPPFunctionObject(CPPObject):

    doc_field_types = [
        TypedField('parameter', label=l_('Parameters'),
                   names=('param', 'parameter', 'arg', 'argument'),
                   typerolename='type', typenames=('type',)),
        Field('returnvalue', label=l_('Returns'), has_arg=False,
              names=('returns', 'return')),
        Field('returntype', label=l_('Return type'), has_arg=False,
              names=('rtype',)),
        ]

    def attach_function(self, node, func):
        owner, name = func.name.split_owner()
        if owner is not None:
            owner = unicode(owner) + '::'
            node += addnodes.desc_addname(owner, owner)

        # cast operator is special.  in this case the return value
        # is reversed.
        if isinstance(name, CastOpDefExpr):
            node += addnodes.desc_name('operator', 'operator')
            node += nodes.Text(u' ')
            self.attach_type(node, name.typename)
        else:
github zeek / zeek / doc / source / ext / bro.py View on Github external
def get_index_text(self, objectname, name):
        return name

class BroAttribute(BroGeneric):
    def get_index_text(self, objectname, name):
        return _('%s (attribute)') % (name)

class BroDomain(Domain):
    """Bro domain."""
    name = 'bro'
    label = 'Bro'

    object_types = {
        'type':             ObjType(l_('type'),             'type'),
        'namespace':        ObjType(l_('namespace'),        'namespace'),
        'id':               ObjType(l_('id'),               'id'),
        'enum':             ObjType(l_('enum'),             'enum'),
        'attr':             ObjType(l_('attr'),             'attr'),
    }

    directives = {
        'type':             BroGeneric,
        'namespace':        BroNamespace,
        'id':               BroIdentifier,
        'enum':             BroEnum,
        'attr':             BroAttribute,
    }

    roles = {
        'type':             XRefRole(),
        'namespace':        XRefRole(),
        'id':               XRefRole(),
github RedpointGames / Protogame / Protogame.Docs / _ext / netxml.py View on Github external
]

class DotNetEnum(DotNetObject):
  display_prefix = 'enum '

class DotNetMethod(DotNetObject):
  
  option_spec = {
    'name': directives.unchanged,
    'prefix': directives.unchanged,
    'parameters': directives.unchanged,
    'return': directives.unchanged,
  }
  
  doc_field_types = [
    TypedField('parameter', label=l_('Parameters'),
                names=('param', 'parameter', 'arg', 'argument'),
                typerolename='type', typenames=('type',)),
    GroupedField('typeparameters', label=l_('Type Parameters'),
                 rolename='typeparam', names=('typeparam', 'typeparameter')),
  ]

  def handle_signature(self, sig, signode):
    name = self.options['name']
    parameters = json.loads(self.options['parameters']) if 'parameters' in self.options else []
    return_v = json.loads(self.options['return']) if 'return' in self.options else ("","")
    prefix = self.options['prefix'] if 'prefix' in self.options else ""
  
    if not ('parameters' in self.options) or not ('return' in self.options):
      print("WARNING: No parameters or return set for '" + name + "'")
    
    signode += nodes.Text(prefix + ' ', prefix + u'\xa0')
github mongodb / docs / bin / aggregation_domain.py View on Github external
return _('%s (aggregation framework group expression)') % (name)
        return ''

class AggregationCallable(MongoDBMethod):
    pass

class AggregationXRefRole(MongoDBXRefRole):
    pass

class AggregationDomain(MongoDBDomain):
    """Aggregation Framework Documentation domain."""
    name = 'agg'
    label = 'Aggregation Framework'
    # if you add a new object type make sure to edit AggregationObject.get_index_string
    object_types = {
        'pipeline':     ObjType(l_('pipeline'),    'pipeline'),
        'group':        ObjType(l_('group'),       'group'),
        'expression':   ObjType(l_('expression'),  'expression'),
    }
    directives = {
        'pipeline':      AggregationObject,
        'group':         AggregationObject,
        'expression':    AggregationObject,
    }
    roles = {
        'pipeline':    AggregationXRefRole(),
        'group':       AggregationXRefRole(),
        'expression':  AggregationXRefRole(),
    }

def setup(app):
    app.add_domain(AggregationDomain)
github zeek / zeek / doc / ext / broxygen.py View on Github external
class IdentifierDirective(BroxygenDirective):

    target_type = "identifier"


class BroxygenDomain(Domain):

    name = "broxygen"
    label = "Broxygen"

    object_types = {
        "package":          ObjType(l_("package")),
        "package_index":    ObjType(l_("package_index")),
        "script":           ObjType(l_("script")),
        "script_summary":   ObjType(l_("script_summary")),
        "script_index":     ObjType(l_("script_index")),
        "proto_analyzer":   ObjType(l_("proto_analyzer")),
        "file_analyzer":    ObjType(l_("file_analyzer")),
        "identifier":       ObjType(l_("identifier")),
    }

    directives = {
        "package":          PackageDirective,
        "package_index":    PackageIndexDirective,
        "script":           ScriptDirective,
        "script_summary":   ScriptSummaryDirective,
        "script_index":     ScriptIndexDirective,
        "proto_analyzer":   ProtoAnalyzerDirective,
        "file_analyzer":    FileAnalyzerDirective,
        "identifier":       IdentifierDirective,
    }
github Source-Python-Dev-Team / Source.Python / addons / source-python / packages / site-packages / sphinx / domains / c.py View on Github external
r'''^\s*([^(,]+?)      # return type
        \( ([^()]+) \) \s* # name in parentheses
        \( (.*) \)         # arguments
        (\s+const)?        # const specifier
        \s*(?=$|,)         # end with comma or end of string
    ''', re.VERBOSE)
c_funcptr_name_re = re.compile(r'^\(\s*\*\s*(.*?)\s*\)$')


class CObject(ObjectDescription):
    """
    Description of a C language object.
    """

    doc_field_types = [
        TypedField('parameter', label=l_('Parameters'),
                   names=('param', 'parameter', 'arg', 'argument'),
                   typerolename='type', typenames=('type',)),
        Field('returnvalue', label=l_('Returns'), has_arg=False,
              names=('returns', 'return')),
        Field('returntype', label=l_('Return type'), has_arg=False,
              names=('rtype',)),
    ]

    # These C types aren't described anywhere, so don't try to create
    # a cross-reference to them
    stopwords = set((
        'const', 'void', 'char', 'wchar_t', 'int', 'short',
        'long', 'float', 'double', 'unsigned', 'signed', 'FILE',
        'clock_t', 'time_t', 'ptrdiff_t', 'size_t', 'ssize_t',
        'struct', '_Bool',
    ))
github agraef / pure-lang / sphinx / puredomain / sphinxcontrib / puredomain.py View on Github external
# addnodes.desc_name seem to work reasonably well for our purposes.
def desc_args(s, t):
    return addnodes.desc_type(s, t)

class PureObject(ObjectDescription):
    """
    Description of a Pure language object.
    """

    doc_field_types = [
        TypedField('parameter', label=l_('Parameters'),
                   names=('param', 'parameter', 'arg', 'argument'),
                   typerolename='obj', typenames=('type',)),
        Field('returnvalue', label=l_('Returns'), has_arg=False,
              names=('returns', 'return')),
        Field('returntype', label=l_('Return type'), has_arg=False,
              names=('rtype',)),
    ]

    def add_signature_prefix(self, signode):
        if self.objtype != 'function':
            descr = "%s " % self.objtype
            signode += addnodes.desc_annotation(descr, descr)

    def needs_arglist(self):
        # We never want this.
        return False

    def handle_signature(self, sig, signode):
        if self.objtype == 'variable' or self.objtype == 'constant':
            return self._handle_data_signature(sig, signode)
        return self._handle_function_signature(sig, signode)
github agraef / pure-lang / sphinx / puredomain / sphinxcontrib / puredomain.py View on Github external
# explicit title.)
            if title[0:1] == '~':
                dcolon = title.rfind('::')
                if dcolon != -1:
                    title = title[dcolon+2:]
                    target = target[1:]
        return title, target


class PureModuleIndex(Index):
    """
    Index subclass to provide the Pure module index.
    """

    name = 'modindex'
    localname = l_('Module Index')
    shortname = l_('modules')

    def generate(self, docnames=None):
        content = {}
        # list of prefixes to ignore
        ignores = self.domain.env.config['modindex_common_prefix']
        ignores = sorted(ignores, key=len, reverse=True)
        # list of all modules, sorted by module name
        modules = sorted(self.domain.data['modules'].items(),
                         key=lambda x: x[0].lower())
        # sort out collapsable modules
        prev_modname = ''
        num_toplevels = 0
        for modname, (docname, synopsis, platforms, deprecated) in modules:
            if docnames and docname not in docnames:
                continue