How to use the sphinx.locale._ 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 VACUMM / vacumm / lib / python / vacumm / sphinxext / fortran_domain.py View on Github external
package = modname.split(f_sep)[0]
            if package != modname:
                # it's a submodule
                if prev_modname == package:
                    # first submodule - make parent a group head
                    entries[-1][1] = 1
                elif not prev_modname.startswith(package):
                    # submodule without parent in list, add dummy entry
                    entries.append([stripped + package, 1, '', '', '', '', ''])
                subtype = 2
            else:
                num_toplevels += 1
                subtype = 0

            qualifier = deprecated and _('Deprecated') or ''
            #entries.append([stripped + modname, subtype, docname,
                            #'module-' + stripped + modname, platforms,
                            #qualifier, synopsis])
            entries.append([stripped + modname, subtype, docname,
                            'f' + f_sep + stripped + modname, platforms,
                            qualifier, synopsis or ''])
            prev_modname = modname

        # apply heuristics when to collapse modindex at page load:
        # only collapse if number of toplevel modules is larger than
        # number of submodules
        collapse = len(modules) - num_toplevels < num_toplevels

        # sort by first letter
        content = sorted(content.iteritems())
github VACUMM / vacumm / lib / python / vacumm / sphinxext / fortran_domain.py View on Github external
def get_index_text(self, modname, name):
        add_modules = self.env.config.add_module_names
        if name.startswith('f'+f_sep): name = name[2:]
        mn = modname or '_'
        sobj = ''
        if name.startswith(mn+f_sep):
            name = name[len(mn)+1:]
        if self.objtype=='type':
            sobj = _('fortran type')
        if self.objtype=='typefield':
            sobj = _('fortran type field')
        elif self.objtype=='variable':
            sobj = _('fortran variable')
        elif self.objtype=='subroutine':
            sobj = _('fortran subroutine')
        elif self.objtype=='function':
            sobj = _('fortran function')
        elif self.objtype=='module':
            sobj = _('fortran module')
            modname = ''
        elif self.objtype=='program':
            sobj = _('fortran program')
            modname = ''
        sinmodule = (_(' in module %s')%modname) if modname and add_modules else ''
        return '%s%s (%s%s)'%(name, self._parens, sobj, sinmodule)
github opencv / opencv / doc / ocv.py View on Github external
def get_type_name(self, type, primary=False):
        """
        Return full name for given ObjType.
        """
        if primary:
            return type.lname

        return {
            'class':         _('C++ class'),
            'struct':        _('C/C++ struct'),
            'function':      _('C++ function'),
            'cfunction':     _('C function'),
            'jfunction':     _('Java method'),
            'pyfunction':    _('Python function'),
            'pyoldfunction': _('Legacy Python function'),
            'member':        _('C++ member'),
            'emember':       _('enum member'),
            'type':          _('C/C++ type'),
            'enum':          _('C/C++ enum'),
            'namespace':     _('C++ namespace'),
            }.get(type.lname, _('%s %s') % (self.label, type.lname))
github sphinx-doc / sphinx / sphinx / domains / c.py View on Github external
(\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=_('Parameters'),
                   names=('param', 'parameter', 'arg', 'argument'),
                   typerolename='type', typenames=('type',)),
        Field('returnvalue', label=_('Returns'), has_arg=False,
              names=('returns', 'return')),
        Field('returntype', label=_('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 = {
        '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',
    }

    def _parse_type(self, node, ctype):
        # type: (nodes.Element, str) -> None
github agraef / pure-lang / sphinx / puredomain / sphinxcontrib / puredomain.py View on Github external
def get_index_text(self, name, fixity, other):
        fname, tag = split_name(name)
        if fixity:
            fixity += " "
        if other:
            fname += " "+other
        if self.objtype == 'function':
            return _('%s (%sfunction)') % (fname,fixity)
        elif self.objtype == 'extern':
            return _('%s (extern %sfunction)') % (fname,fixity)
        elif self.objtype == 'macro':
            return _('%s (%smacro)') % (fname,fixity)
        elif self.objtype == 'constructor':
            return _('%s (%sconstructor)') % (fname,fixity)
        elif self.objtype == 'type':
            return _('%s (type)') % fname
        elif self.objtype == 'variable':
            return _('%s (variable)') % name
        elif self.objtype == 'constant':
            return _('%s (constant)') % name
        else:
            return ''
github OSGeo / gdal / gdal / doc / source / _extensions / driverproperties.py View on Github external
def run(self):

        if not self.content:
            self.content = docutils.statemachine.StringList(['This driver is built-in by default'])
        node = built_in_by_default('\n'.join(self.content))
        node += nodes.title(_('Driver built-in by default'), _('Driver built-in by default'))

        return finish_directive(self, 'built_in_by_default', node)
github mongodb / docs / bin / sphinxext / mongodb.py View on Github external
def get_index_text(self, objectname, name_obj):
        name, obj = name_obj
        if self.objtype == 'dbcommand':
            return _('%s (database command)') % name
        elif self.objtype == 'operator':
            return _('%s (operator)') % name
        elif self.objtype == 'projection':
            return _('%s (projection operator)') % name
        elif self.objtype == 'binary':
            return _('%s (program)') % name
        elif self.objtype == 'setting':
            return _('%s (setting)') % (name)
        elif self.objtype == 'data':
            return _('%s (MongoDB reporting output)') % (name)
        elif self.objtype == 'method':
            return _('%s (shell method)') % (name)
        elif self.objtype == 'collflag':
            return _('%s (collection flag)') % (name)
        elif self.objtype == 'readmode':
            return _('%s (read preference mode)') % (name)
        elif self.objtype == 'error':
            return _('%s (error code)') % (name)
        elif self.objtype == 'macro':
            return _('%s (JavaScript shell macro)') % (name)
        elif self.objtype == 'limit':
            return _('%s (MongoDB system limit)') % (name)
github astropy / astropy-helpers / astropy_helpers / sphinx / ext / viewcode.py View on Github external
if modname.startswith(stack[-1]):
            stack.append(modname + '.')
            html.append('<ul>')
        else:
            stack.pop()
            while not modname.startswith(stack[-1]):
                stack.pop()
                html.append('</ul>')
            stack.append(modname + '.')
        html.append('<li><a href="%s">%s</a></li>\n' % (
            urito('_modules/index', '_modules/' + modname.replace('.', '/')),
            modname))
    html.append('' * (len(stack) - 1))
    context = {
        'title': _('Overview: module code'),
        'body': _('<h1>All modules for which code is available</h1>') + \
            ''.join(html),
    }

    yield ('_modules/index', context, 'page.html')
github VACUMM / sphinx-fortran / sphinxfortran / fortran_domain.py View on Github external
mn = modname or '_'
        sobj = ''
        if name.startswith(mn + f_sep):
            name = name[len(mn) + 1:]
        if self.objtype == 'type':
            sobj = _('fortran type')
        if self.objtype == 'typefield':
            sobj = _('fortran type field')
        elif self.objtype == 'variable':
            sobj = _('fortran variable')
        elif self.objtype == 'subroutine':
            sobj = _('fortran subroutine')
        elif self.objtype == 'function':
            sobj = _('fortran function')
        elif self.objtype == 'module':
            sobj = _('fortran module')
            modname = ''
        elif self.objtype == 'program':
            sobj = _('fortran program')
            modname = ''
        sinmodule = (
            _(' in module %s') %
            modname) if modname and add_modules else ''
        return '%s%s (%s%s)' % (name, self._parens, sobj, sinmodule)
github sphinx-doc / sphinx / sphinx / domains / python.py View on Github external
logger = logging.getLogger(__name__)


# REs for Python signatures
py_sig_re = re.compile(
    r'''^ ([\w.]*\.)?            # class name(s)
          (\w+)  \s*             # thing name
          (?: \(\s*(.*)\s*\)     # optional: arguments
           (?:\s* -> \s* (.*))?  #           return annotation
          )? $                   # and nothing more
          ''', re.VERBOSE)


pairindextypes = {
    'module':    _('module'),
    'keyword':   _('keyword'),
    'operator':  _('operator'),
    'object':    _('object'),
    'exception': _('exception'),
    'statement': _('statement'),
    'builtin':   _('built-in function'),
}

locale.pairindextypes = DeprecatedDict(
    pairindextypes,
    'sphinx.locale.pairindextypes is deprecated. '
    'Please use sphinx.domains.python.pairindextypes instead.',
    RemovedInSphinx30Warning
)


def _pseudo_parse_arglist(signode: desc_signature, arglist: str) -> None: