Required Sphinx extension setup function.
769942
def setup(app):
    '''  '''
    app.connect('html-page-context', html_page_context)
    app.connect('build-finished',    build_finished)
    app.sitemap_links = set()
111875
def create_extension(name,
                     if_not_exists=None,
                     schema=None,
                     ext_version=None,
                     from_version=None,
                     user=None,
                     host=None,
                     port=None,
                     maintenance_db=None,
                     password=None,
                     runas=None):
    '''
    

    '''
    if if_not_exists is None:
        if_not_exists = True
    mtdata = create_metadata(name,
                             ext_version=ext_version,
                             schema=schema,
                             user=user,
                             host=host,
                             port=port,
                             maintenance_db=maintenance_db,
                             password=password,
                             runas=runas)
    installed = _EXTENSION_NOT_INSTALLED not in mtdata
    installable = is_available_extension(name,
                                         user=user,
                                         host=host,
                                         port=port,
                                         maintenance_db=maintenance_db,
                                         password=password,
                                         runas=runas)
    if installable:
        if not installed:
            args = ['CREATE EXTENSION']
            if if_not_exists:
                args.append('IF NOT EXISTS')
            args.append('"{0}"'.format(name))
            sargs = []
            if schema:
                sargs.append('SCHEMA "{0}"'.format(schema))
            if ext_version:
                sargs.append('VERSION {0}'.format(ext_version))
            if from_version:
                sargs.append('FROM {0}'.format(from_version))
            if sargs:
                args.append('WITH')
                args.extend(sargs)
            args.append(';')
            cmd = ' '.join(args).strip()
        else:
            args = []
            if schema and _EXTENSION_TO_MOVE in mtdata:
                args.append('ALTER EXTENSION "{0}" SET SCHEMA "{1}";'.format(
                    name, schema))
            if ext_version and _EXTENSION_TO_UPGRADE in mtdata:
                args.append('ALTER EXTENSION "{0}" UPDATE TO {1};'.format(
                    name, ext_version))
            cmd = ' '.join(args).strip()
        if cmd:
            _psql_prepare_and_run(
                ['-c', cmd],
                runas=runas, host=host, user=user, port=port,
                maintenance_db=maintenance_db, password=password)
    mtdata = create_metadata(name,
                             ext_version=ext_version,
                             schema=schema,
                             user=user,
                             host=host,
                             port=port,
                             maintenance_db=maintenance_db,
                             password=password,
                             runas=runas)
    ret = True
    for i in _EXTENSION_FLAGS:
        if (i in mtdata) and (i != _EXTENSION_INSTALLED):
            ret = False
    if not ret:
        log.info('Failed to create ext: %s', name)
    return ret
761915
def sphinx(self):
        """"""
        if callable(self.default):
            default_val = self.default()
            default_str = 'new instance of {}'.format(
                default_val.__class__.__name__
            )
        else:
            default_val = self.default
            default_str = '{}'.format(self.default)
        try:
            if default_val is None or default_val is undefined:
                default_str = ''
            elif len(default_val) == 0:                                        #pylint: disable=len-as-condition
                default_str = ''
            else:
                default_str = ', Default: {}'.format(default_str)
        except TypeError:
            default_str = ', Default: {}'.format(default_str)

        prop_doc = super(Property, self).sphinx()
        return '{doc}{default}'.format(doc=prop_doc, default=default_str)
1248401
def docs(ctx, output='html', rebuild=False, show=True, verbose=True):
    """"""
    sphinx_build = ctx.run(
        'sphinx-build -b {output} {all} {verbose} docs docs/_build'.format(
            output=output,
            all='-a -E' if rebuild else '',
            verbose='-v' if verbose else ''))
    if not sphinx_build.ok:
        fatal("Failed to build the docs", cause=sphinx_build)

    if show:
        path = os.path.join(DOCS_OUTPUT_DIR, 'index.html')
        if sys.platform == 'darwin':
            path = 'file://%s' % os.path.abspath(path)
        webbrowser.open_new_tab(path)
1153791
def setup(sphinx):
    
    create_auto_documentation()

    # add the py3status lexer (for code blocks)
    from sphinx.highlighting import lexers
    lexers['py3status'] = Py3statusLexer()

    # enable screenshot directive for dynamic screenshots
    sphinx.add_directive('screenshot', ScreenshotDirective)
864740
protected function setup() {
		// Clear global hashes.
		$this->urls        = $this->predef_urls;
		$this->titles      = $this->predef_titles;
		$this->html_hashes = array();
		$this->in_anchor   = false;
	}
961351
def setup(app) -> Dict[str, Any]:
    
    app.setup_extension("sphinx.ext.graphviz")
    app.add_node(
        inheritance_diagram,
        html=(html_visit_inheritance_diagram, None),
        latex=(latex_visit_inheritance_diagram, None),
        man=(skip, None),
        texinfo=(skip, None),
        text=(skip, None),
    )
    app.add_directive("inheritance-diagram", InheritanceDiagram)
    return {
        "version": uqbar.__version__,
        "parallel_read_safe": True,
        "parallel_write_safe": True,
    }
418161
def setup(cls) -> None:
        """"""
        cls.prepare()
        setuptools.setup(
            name=cls.name, version=cls.version, description=cls.description,
            long_description=cls.long_description, url=cls.url, download_url=cls.download_url,
            author=cls.author, author_email=cls.author_email,
            maintainer=cls.try_fields('maintainer', 'author'),
            maintainer_email=cls.try_fields('maintainer_email', 'author_email'),
            license=cls.license_str, classifiers=cls.classifiers, keywords=cls.keywords,
            packages=cls.packages, package_dir={'': cls.root_directory},
            include_package_data=True,
            package_data=cls.package_data, exclude_package_data=cls.exclude_package_data,
            install_requires=cls.install_requires, extras_require=cls.extras_require,
            python_requires=cls.python_requires,
            entry_points=cls.entry_points, test_suite=cls.test_suite)
1334590
def sphinx(self):
        """"""
        try:
            assert __IPYTHON__
            classdoc = ''
        except (NameError, AssertionError):
            scls = self.sphinx_class()
            classdoc = ' ({})'.format(scls) if scls else ''

        prop_doc = '**{name}**{cls}: {doc}{info}'.format(
            name=self.name,
            cls=classdoc,
            doc=self.doc,
            info=', {}'.format(self.info) if self.info else '',
        )
        return prop_doc
833043
def build(
    c,
    clean=False,
    browse=False,
    nitpick=False,
    opts=None,
    source=None,
    target=None,
):
    
    if clean:
        _clean(c)
    if opts is None:
        opts = ""
    if nitpick:
        opts += " -n -W -T"
    cmd = "sphinx-build{0} {1} {2}".format(
        (" " + opts) if opts else "",
        source or c.sphinx.source,
        target or c.sphinx.target,
    )
    c.run(cmd, pty=True)
    if browse:
        _browse(c)
515457
def setup(app):
    
    app.add_config_value('sphinxmark_enable', False, 'html')
    app.add_config_value('sphinxmark_div', 'default', 'html')
    app.add_config_value('sphinxmark_border', None, 'html')
    app.add_config_value('sphinxmark_repeat', True, 'html')
    app.add_config_value('sphinxmark_fixed', False, 'html')
    app.add_config_value('sphinxmark_image', 'default', 'html')
    app.add_config_value('sphinxmark_text', 'default', 'html')
    app.add_config_value('sphinxmark_text_color', (255, 0, 0), 'html')
    app.add_config_value('sphinxmark_text_size', 100, 'html')
    app.add_config_value('sphinxmark_text_width', 1000, 'html')
    app.add_config_value('sphinxmark_text_opacity', 20, 'html')
    app.add_config_value('sphinxmark_text_spacing', 400, 'html')
    app.add_config_value('sphinxmark_text_rotation', 0, 'html')
    app.connect('env-updated', watermark)

    return {
        'version': '0.1.18',
        'parallel_read_safe': True,
        'parallel_write_safe': True,
    }
1310547
def build_sphinx(pkg_data, projectdir):
    
    try:
        version, _minor_version = pkg_data.version.rsplit('.', 1)
    except ValueError:
        version = pkg_data.version
    args = ' '.join(('sphinx-quickstart',
                     '--sep',
                     '-q',
                     '-p "{name}"',
                     '-a "{author}"',
                     '-v "{version}"',
                     '-r "{release}"',
                     '-l en',
                     '--suffix=.rst',
                     '--master=index',
                     '--ext-autodoc',
                     '--ext-viewcode',
                     '--makefile',
                     '{projectdir}')).format(name=pkg_data.name,
                                             author=pkg_data.author,
                                             version=version,
                                             release=pkg_data.version,
                                             projectdir=projectdir)
    if subprocess.call(shlex.split(args)) == 0:
        _touch_gitkeep(projectdir)
976049
def docs(context: Context):
    
    try:
        from sphinx.application import Sphinx
    except ImportError:
        context.pip_command('install', 'Sphinx')
        from sphinx.application import Sphinx

    context.shell('cp', 'README.rst', 'docs/README.rst')
    app = Sphinx('docs', 'docs', 'docs/build', 'docs/build/.doctrees', buildername='html', parallel=True,
                 verbosity=context.verbosity)
    app.build()
1141421
def _setup(module, extras):
    """"""

    Qt.__binding__ = module.__name__

    for name in list(_common_members) + extras:
        try:
            submodule = _import_sub_module(
                module, name)
        except ImportError:
            try:
                # For extra modules like sip and shiboken that may not be
                # children of the binding.
                submodule = __import__(name)
            except ImportError:
                continue

        setattr(Qt, "_" + name, submodule)

        if name not in extras:
            # Store reference to original binding,
            # but don't store speciality modules
            # such as uic or QtUiTools
            setattr(Qt, name, _new_module(name))
437575
def _setup(app, *, schema,  title=None, app_key=APP_KEY, db=None):
    """"""

    admin = web.Application(loop=app.loop)
    app[app_key] = admin
    loader = jinja2.FileSystemLoader([TEMPLATES_ROOT, ])
    aiohttp_jinja2.setup(admin, loader=loader, app_key=TEMPLATE_APP_KEY)

    if title:
        schema.title = title

    resources = [
        init(db, info['table'], url=info['url'])
        for init, info in schema.resources
    ]

    admin_handler = AdminOnRestHandler(
        admin,
        resources=resources,
        loop=app.loop,
        schema=schema,
    )

    admin['admin_handler'] = admin_handler
    setup_admin_on_rest_handlers(admin, admin_handler)

    return admin
325097
def docs(context, builder='html'):
    ""
    cmdline = 'python -msphinx -M {} {} {} {}'.format(builder, DOCS_SRCDIR, DOCS_BUILDDIR, SPHINX_OPTS)
    context.run(cmdline)
1018036
def construct_meta(need_data, env):
    

    hide_options = env.config.needs_hide_options
    if not isinstance(hide_options, list):
        raise SphinxError('Config parameter needs_hide_options must be of type list')

    node_meta = nodes.line_block(classes=['needs_meta'])
    # need parameters
    param_status = "status: "
    param_tags = "tags: "

    if need_data["status"] is not None and 'status' not in hide_options:
        status_line = nodes.line(classes=['status'])
        # node_status = nodes.line(param_status, param_status, classes=['status'])
        node_status = nodes.inline(param_status, param_status, classes=['status'])
        status_line.append(node_status)
        status_line.append(nodes.inline(need_data["status"], need_data["status"],
                                        classes=["needs-status", str(need_data['status'])]))
        node_meta.append(status_line)

    if need_data["tags"] and 'tags' not in hide_options:
        tag_line = nodes.line(classes=['tags'])
        # node_tags = nodes.line(param_tags, param_tags, classes=['tags'])
        node_tags = nodes.inline(param_tags, param_tags, classes=['tags'])
        tag_line.append(node_tags)
        for tag in need_data['tags']:
            # node_tags.append(nodes.inline(tag, tag, classes=["needs-tag", str(tag)]))
            # node_tags.append(nodes.inline(' ', ' '))
            tag_line.append(nodes.inline(tag, tag, classes=["needs-tag", str(tag)]))
            tag_line.append(nodes.inline(' ', ' '))
        node_meta.append(tag_line)

    # Links incoming
    if need_data['links_back'] and 'links_back' not in hide_options:
        node_incoming_line = nodes.line(classes=['links', 'incoming'])
        prefix = "links incoming: "
        node_incoming_prefix = nodes.inline(prefix, prefix)
        node_incoming_line.append(node_incoming_prefix)
        node_incoming_links = Need_incoming(reftarget=need_data['id'])
        node_incoming_links.append(nodes.inline(need_data['id'], need_data['id']))
        node_incoming_line.append(node_incoming_links)
        node_meta.append(node_incoming_line)

    # # Links outgoing
    if need_data['links'] and 'links' not in hide_options:
        node_outgoing_line = nodes.line(classes=['links', 'outgoing'])
        prefix = "links outgoing: "
        node_outgoing_prefix = nodes.inline(prefix, prefix)
        node_outgoing_line.append(node_outgoing_prefix)
        node_outgoing_links = Need_outgoing(reftarget=need_data['id'])
        node_outgoing_links.append(nodes.inline(need_data['id'], need_data['id']))
        node_outgoing_line.append(node_outgoing_links)
        node_meta.append(node_outgoing_line)

    extra_options = getattr(env.config, 'needs_extra_options', {})
    node_extra_options = []
    for key, value in extra_options.items():
        if key in hide_options:
            continue
        param_data = need_data[key]
        if param_data is None or not param_data:
            continue
        param_option = '{}: '.format(key)
        option_line = nodes.line(classes=['extra_option'])
        option_line.append(nodes.inline(param_option, param_option, classes=['extra_option']))
        option_line.append(nodes.inline(param_data, param_data,
                                        classes=["needs-extra-option", str(key)]))
        node_extra_options.append(option_line)

    node_meta += node_extra_options

    global_options = getattr(env.config, 'needs_global_options', {})
    node_global_options = []
    for key, value in global_options.items():
        # If a global option got locally overwritten, it must already part of extra_options.
        # In this skipp output, as this is done during extra_option handling
        if key in extra_options or key in hide_options:
            continue

        param_data = need_data[key]
        if param_data is None or not param_data:
            continue
        param_option = '{}: '.format(key)
        global_option_line = nodes.line(classes=['global_option'])
        global_option_line.append(nodes.inline(param_option, param_option, classes=['global_option']))
        global_option_line.append(nodes.inline(param_data, param_data,
                                               classes=["needs-global-option", str(key)]))
        node_global_options.append(global_option_line)

    node_meta += node_global_options

    return node_meta