How to use Sphinx - 10 common examples

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 sphinx-doc / sphinx / tests / roots / test-root / conf.py View on Github external
def userdesc_parse(env, sig, signode):
    x, y = sig.split(':')
    signode += addnodes.desc_name(x, x)
    signode += addnodes.desc_parameterlist()
    signode[-1] += addnodes.desc_parameter(y, y)
    return x
github ignatenkobrain / sphinxcontrib-issuetracker / test_issuetracker.py View on Github external
def pytest_funcarg__node(request):
    node = pending_xref()
    node['reftype'] = 'issue'
    node['reftarget'] = '10'
    node.append(nodes.Text('#10'))
    return node
github ignatenkobrain / sphinxcontrib-issuetracker / tests / test_resolver.py View on Github external
def pytest_funcarg__node(request):
    issue_id = request.getfuncargvalue('issue_id')
    node = pending_xref()
    node['reftype'] = 'issue'
    node['reftarget'] = issue_id
    node.append(request.getfuncargvalue('contnode'))
    return node
github zyegfryed / django-statici18n / docs / _ext / djangodocs.py View on Github external
def parse_django_admin_node(env, sig, signode):
    command = sig.split(' ')[0]
    env.ref_context['std:program'] = command
    title = "django-admin %s" % sig
    signode += addnodes.desc_name(title, title)
    return command
github Abjad / abjad / abjad / docs / ext / style.py View on Github external
classes_to_attributes = {}

    def get_unique_parts(parts):
        unique_parts = [parts[0]]
        for part in parts[1:]:
            if part != unique_parts[-1]:
                unique_parts.append(part)
            else:
                break
        return unique_parts

    for desc_node in doctree.traverse(addnodes.desc):
        if desc_node.get('domain') != 'py':
            continue

        signature_node = desc_node.traverse(addnodes.desc_signature)[0]
        module_name = signature_node.get('module')
        object_name = signature_node.get('fullname')
        object_type = desc_node.get('objtype')
        module = importlib.import_module(module_name)

        if object_type in ('function', 'class'):
            addname_node = signature_node.traverse(addnodes.desc_addname)[0]
            text = addname_node[0].astext()
            parts = [x for x in text.split('.') if x]
            parts = get_unique_parts(parts)
            if parts[0] in ('abjad', 'experimental', 'ide'):
                parts = parts[-1:]
            if parts:
                text = '{}.'.format('.'.join(parts))
            else:
                text = ''
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 securestate / king-phisher / king_phisher / sphinxext / rpc.py View on Github external
def handle_signature(self, sig, signode):
		m = re.match(r'([a-zA-Z0-9_/\(\):]+)\(([a-zA-Z0-9,\'"_= ]*)\)', sig)
		if not m:
			signode += addnodes.desc_name(sig, sig)
			return sig
		uri_path, args = m.groups()
		signode += addnodes.desc_name(uri_path, uri_path)
		plist = DescRPCArgumentList()
		args = args.split(',')
		for pos, arg in enumerate(args):
			arg = arg.strip()
			if pos < len(args) - 1:
				arg += ','
			x = DescRPCArgument()
			x += addnodes.desc_parameter(arg, arg)
			plist += x
		signode += plist
		return uri_path
github rchain / architecture-docs / conf.py View on Github external
def parse_event(env, sig, signode):
    m = event_sig_re.match(sig)
    if not m:
        signode += addnodes.desc_name(sig, sig)
        return sig
    name, args = m.groups()
    signode += addnodes.desc_name(name, name)
    plist = addnodes.desc_parameterlist()
    for arg in args.split(','):
        arg = arg.strip()
        plist += addnodes.desc_parameter(arg, arg)
        signode += plist
    return name
github sphinx-doc / sphinx / sphinx / builders / manpage.py View on Github external
from sphinx import addnodes
from sphinx.application import Sphinx
from sphinx.builders import Builder
from sphinx.config import Config
from sphinx.errors import NoUri
from sphinx.locale import __
from sphinx.util import logging
from sphinx.util import progress_message
from sphinx.util.console import darkgreen  # type: ignore
from sphinx.util.nodes import inline_all_toctrees
from sphinx.util.osutil import make_filename_from_project
from sphinx.writers.manpage import ManualPageWriter, ManualPageTranslator


logger = logging.getLogger(__name__)


class ManualPageBuilder(Builder):
    """
    Builds groff output in manual page format.
    """
    name = 'man'
    format = 'man'
    epilog = __('The manual pages are in %(outdir)s.')

    default_translator_class = ManualPageTranslator
    supported_image_types = []  # type: List[str]

    def init(self) -> None:
        if not self.config.man_pages:
            logger.warning(__('no "man_pages" config value found; no manual pages '
github codejamninja / sphinx-markdown-builder / sphinx_markdown_builder / markdown_builder.py View on Github external
from os import path
from sphinx.builders import Builder
from sphinx.builders import Builder
from sphinx.locale import __
from sphinx.util import logging
from sphinx.util.osutil import ensuredir, os_path
import shutil
import os


if False:
    from typing import Any, Dict, Iterator, Set, Tuple
    from docutils import nodes
    from sphinx.application import Sphinx

logger = logging.getLogger(__name__)

class MarkdownBuilder(Builder):
    name = 'markdown'
    format = 'markdown'
    epilog = __('The markdown files are in %(outdir)s.')

    out_suffix = '.md'
    allow_parallel = True
    default_translator_class = MarkdownTranslator

    current_docname = None

    markdown_http_base = 'https://localhost'

    def init(self):
        self.secnumbers = {}