def setup(app): from sphinx.domains.python import PyField from sphinx.util.docfields import Field app.add_css_file('/source/_static/custom.css') app.add_stylesheet('/source/_static/theme_override.css') app.add_object_type( 'confval', 'confval', objname='configuration value', indextemplate='pair: %s; configuration value', doc_field_types=[ PyField( 'type', label=_('Type'), has_arg=False, names=('type',), bodyrolename='class' ), Field( 'default', label=_('Default'), has_arg=False, names=('default',), ), ] )
def setup(app): from sphinx.domains.python import PyField from sphinx.util.docfields import Field app.add_object_type( 'confval', 'confval', objname='configuration value', indextemplate='pair: %s; configuration value', doc_field_types=[ PyField( 'type', label=_('Type'), has_arg=False, names=('type',), bodyrolename='class' ), Field( 'default', label=_('Default'), has_arg=False, names=('default',), ), ] )
def setup(app): from sphinx.domains.python import PyField from sphinx.util.docfields import Field app.add_object_type('confval', 'confval', objname='configuration value', indextemplate='pair: %s; configuration value', doc_field_types=[ PyField('type', label=_('Type'), has_arg=False, names=('type', ), bodyrolename='class'), Field( 'default', label=_('Default'), has_arg=False, names=('default', ), ), ]) app.add_config_value( 'recommonmark_config', { # 'url_resolver': lambda url: github_doc_root + url, 'auto_toc_tree_section': 'Contents', 'enable_math': False, 'enable_inline_math': False, 'enable_eval_rst': True, }, True) app.add_transform(AutoStructify)
def setup(app): from sphinx.domains.python import PyField from sphinx.util.docfields import Field app.add_stylesheet('custom.css') app.add_javascript("custom.js") app.add_javascript( "https://cdn.jsdelivr.net/npm/clipboard@1/dist/clipboard.min.js") app.add_object_type('confval', 'confval', objname='configuration value', indextemplate='pair: %s; configuration value', doc_field_types=[ PyField('type', label=_('Type'), has_arg=False, names=('type', ), bodyrolename='class'), Field( 'default', label=_('Default'), has_arg=False, names=('default', ), ), ])
def setup(app): app.add_object_type('confval', 'confval', objname='configuration value', indextemplate='pair: %s; configuration value', doc_field_types=[ PyField('type', label=_('Type'), has_arg=False, names=('type', ), bodyrolename='class'), Field( 'default', label=_('Default'), has_arg=False, names=('default', ), ), Field( 'required', label=_('Required'), has_arg=False, names=('required', ), ), Field( 'example', label=_('Example'), has_arg=False, ) ]) return { 'version': 'builtin', 'parallel_read_safe': True, 'parallel_write_safe': True, }
def setup(app: Sphinx) -> None: """ A `sphinx` ``setup()`` function setting up the :rst:dir:`confval` directive and :rst:role:`confval` role. """ # this was taken from the sphinx and sphinx_rtd_theme conf.py files and creates # the documenting directive `.. confval::` and role `:confval:` for documenting # sphinx configuration variables app.add_object_type( directivename="confval", rolename="confval", objname="configuration value", indextemplate="pair: %s; configuration value", doc_field_types=[ PyField( name="type", names=("type", ), label=_("Type"), has_arg=False, bodyrolename="class", ), Field( name="default", names=("default", ), label=_("Default"), has_arg=False, ), ], )
def setup(app): from sphinx.domains.python import PyField from sphinx.util.docfields import Field from sphinx.locale import _ app.add_object_type( 'confval', 'confval', objname='configuration value', indextemplate='pair: %s; configuration value', doc_field_types=[ PyField( 'type', label=_('Type'), has_arg=False, names=('type',), bodyrolename='class', ), Field( 'default', label=_('Default'), has_arg=False, names=('default',), ), ], ) app.add_config_value( name='server_address', default=os.getenv('JINA_DOCSBOT_SERVER', 'https://jina-ai-jina-docsqa.jina.ai'), rebuild='', ) app.connect('builder-inited', set_qa_server_address)
def make_confval(app): # Copy-pasted from https://github.com/rtfd/sphinx_rtd_theme from sphinx.locale import _ from sphinx.domains.python import PyField from sphinx.util.docfields import Field app.add_object_type( 'confval', 'confval', objname='configuration value', indextemplate='pair: %s; configuration value', doc_field_types=[ PyField( 'type', label=_('Type'), has_arg=False, names=('type',), bodyrolename='class' ), Field( 'default', label=_('Default'), has_arg=False, names=('default',), ), ] )
def setup(app): from sphinx.domains.python import PyField from sphinx.util.docfields import Field app.add_directive('hidden-code-block', HiddenCodeBlock) app.add_node( hidden_code_block, html=(visit_hcb_html, depart_hcb_html), latex=(visit_hcb_html, depart_hcb_html), text=(visit_hcb_html, depart_hcb_html), man=(visit_hcb_html, depart_hcb_html), texinfo=(visit_hcb_html, depart_hcb_html), ) app.add_object_type('confval', 'confval', objname='configuration value', indextemplate='pair: %s; configuration value', doc_field_types=[ PyField('type', label=_('Type'), has_arg=False, names=('type', ), bodyrolename='class'), Field( 'default', label=_('Default'), has_arg=False, names=('default', ), ), ])
def setup(app) -> Dict[str, Any]: app.add_config_value('ceph_confval_imports', default=[], rebuild='html', types=[str]) app.add_directive('confval', CephOption) app.add_object_type( 'confval_option', 'confval', objname='configuration value', indextemplate='pair: %s; configuration value', doc_field_types=[ PyField( 'type', label=_('Type'), has_arg=False, names=('type',), bodyrolename='class' ), Field( 'default', label=_('Default'), has_arg=False, names=('default',), ), Field( 'required', label=_('Required'), has_arg=False, names=('required',), ), Field( 'example', label=_('Example'), has_arg=False, ) ] ) app.add_object_type( 'confsec', 'confsec', objname='configuration section', indextemplate='pair: %s; configuration section', doc_field_types=[ Field( 'example', label=_('Example'), has_arg=False, )] ) return { 'version': 'builtin', 'parallel_read_safe': True, 'parallel_write_safe': True, }
def setup(app: Sphinx): """ A `sphinx` ``setup()`` function for the extension package `plasmapy_sphinx` to set up convenient, but optional, functionality. This adds: 1. ``confval`` standard directive and role for documenting and cross-linking Sphinx configuration values. 2. ``event`` standard directive and role for documenting and cross-linking Sphinx events. """ # this was taken from the sphinx and sphinx_rtd_theme conf.py files and creates # the documenting directive `.. confval::` and role `:confval:` for documenting # sphinx configuration variables app.add_object_type( "confval", "confval", objname="configuration value", indextemplate="pair: %s; configuration value", doc_field_types=[ PyField( "type", label=_("Type"), has_arg=False, names=("type",), bodyrolename="class", ), Field( "default", label=_("Default"), has_arg=False, names=("default",), ), ], ) # this was taken from the sphinx conf.py file and creates the documenting # directive `.. confval::` and role `:confval:` for documenting sphinx events app.add_object_type( directivename="event", rolename="event", indextemplate="pair: %s; event", parse_node=parse_event, doc_field_types=[ GroupedField( "parameter", label="Parameters", names=("param",), can_collapse=True, ) ], )
def setup(app): from sphinx.domains.python import PyField from sphinx.util.docfields import Field app.add_object_type("confval", "confval", objname="configuration value", indextemplate="pair: %s; configuration value", doc_field_types=[ PyField("type", label=_("Type"), has_arg=False, names=("type", ), bodyrolename="class"), Field( "default", label=_("Default"), has_arg=False, names=("default", ), ), ])
def setup(app): if ditaa is None: # add "ditaa" as an alias of "diagram" from plantweb.directive import DiagramDirective app.add_directive('ditaa', DiagramDirective) app.connect( 'builder-inited', generate_state_diagram( ['src/osd/PeeringState.h', 'src/osd/PeeringState.cc'], 'doc/dev/peering_graph.generated.dot')) app.add_object_type('confval', 'confval', objname='configuration value', indextemplate='pair: %s; configuration value', doc_field_types=[ PyField('type', label=_('Type'), has_arg=False, names=('type', ), bodyrolename='class'), Field( 'default', label=_('Default'), has_arg=False, names=('default', ), ), Field( 'required', label=_('Required'), has_arg=False, names=('required', ), ), Field( 'example', label=_('Example'), has_arg=False, ) ])
def setup(app): from sphinx.domains.python import PyField from sphinx.util.docfields import Field app.add_object_type('confval', 'confval', objname='configuration value', indextemplate='pair: %s; configuration value', doc_field_types=[ PyField('type', label=_('Type'), has_arg=False, names=('type', ), bodyrolename='class'), Field( 'default', label=_('Default'), has_arg=False, names=('default', ), ), ]) app.add_stylesheet("css/theme_overrides.css") app.add_javascript("js/version_switch.js")
def setup(app): from sphinx.domains.python import PyField from sphinx.util.docfields import Field app.add_css_file('/source/_static/custom.css') app.add_stylesheet('/source/_static/theme_override.css') app.add_object_type('confval', 'confval', objname='configuration value', indextemplate='pair: %s; configuration value', doc_field_types=[ PyField('type', label=_('Type'), has_arg=False, names=('type', ), bodyrolename='class'), Field( 'default', label=_('Default'), has_arg=False, names=('default', ), ), ]) # Patch the MATLAB lexer to correct wrong highlighting from sphinx.highlighting import lexers from pygments.lexers import MatlabLexer from pygments.token import Name from pygments.filters import NameHighlightFilter matlab_lexer = MatlabLexer() matlab_lexer.add_filter( NameHighlightFilter( names=[ 'function', 'end', 'if', 'else', 'elseif', 'switch', 'case', 'return', 'otherwise' ], tokentype=Name.Function, )) app.add_lexer('matlab', matlab_lexer)
('index', slug, project, author, slug, project, 'Miscellaneous'), ] # Extensions to theme docs def setup(app): from sphinx.domains.python import PyField from sphinx.util.docfields import Field app.add_object_type( 'confval', 'confval', objname='configuration value', indextemplate='pair: %s; configuration value', doc_field_types=[ PyField( 'type', label=_('Type'), has_arg=False, names=('type',), bodyrolename='class' ), Field( 'default', label=_('Default'), has_arg=False, names=('default',), ), ] )
class HTTPResource(ObjectDescription): doc_field_types = [ PyTypedField('parameter', label='Parameters', names=('param', 'parameter', 'arg', 'argument'), typerolename='obj', typenames=('paramtype', 'type')), PyTypedField('jsonparameter', label='JSON Parameters', names=('jsonparameter', 'jsonparam', 'json'), typerolename='obj', typenames=('jsonparamtype', 'jsontype')), PyTypedField('requestjsonobject', label='Request JSON Object', names=('reqjsonobj', 'reqjson', '<jsonobj', '<json'), typerolename='obj', typenames=('reqjsonobj', '<jsonobj')), PyTypedField('requestjsonarray', label='Request JSON Array of Objects', names=('reqjsonarr', '<jsonarr'), typerolename='obj', typenames=('reqjsonarrtype', '<jsonarrtype')), PyTypedField('responsejsonobject', label='Response JSON Object', names=('resjsonobj', 'resjson', '>jsonobj', '>json'), typerolename='obj', typenames=('resjsonobj', '>jsonobj')), Field('singlejsonvalue', label='Response JSON Object', has_arg=False, names=('returns', 'return')), PyField('singlejsontype', label='Response JSON type', has_arg=False, names=('rtype', ), bodyrolename='obj'), PyTypedField('responsejsonarray', label='Response JSON Array of Objects', names=('resjsonarr', '>jsonarr'), typerolename='obj', typenames=('resjsonarrtype', '>jsonarrtype')), PyTypedField('queryparameter', label='Query Parameters', names=('queryparameter', 'queryparam', 'qparam', 'query'), typerolename='obj', typenames=('queryparamtype', 'querytype', 'qtype')), GroupedField('formparameter', label='Form Parameters', names=('formparameter', 'formparam', 'fparam', 'form')), GroupedField('requestheader', label='Request Headers', rolename='header', names=('<header', 'reqheader', 'requestheader')), GroupedField('responseheader', label='Response Headers', rolename='header', names=('>header', 'resheader', 'responseheader')), GroupedField('statuscode', label='Status Codes', rolename='statuscode', names=('statuscode', 'status', 'code')), PyGroupedField('exceptions', label='Possible error responses', rolename='exc', names=('raises', 'raise', 'exception', 'except'), can_collapse=True), ] option_spec = { 'deprecated': directives.flag, 'noindex': directives.flag, 'synopsis': lambda x: x, } method = NotImplemented def handle_signature(self, sig, signode): method = self.method.upper() + ' ' signode += addnodes.desc_name(method, method) offset = 0 path = None for match in http_sig_param_re.finditer(sig): path = sig[offset:match.start()] signode += addnodes.desc_name(path, path) params = addnodes.desc_parameterlist() typ = match.group('type') if typ: typ += ': ' params += addnodes.desc_annotation(typ, typ) name = match.group('name') params += addnodes.desc_parameter(name, name) signode += params offset = match.end() if offset < len(sig): path = sig[offset:len(sig)] signode += addnodes.desc_name(path, path) assert path is not None, 'no matches for sig: %s' % sig fullname = self.method.upper() + ' ' + path signode['method'] = self.method signode['path'] = sig signode['fullname'] = fullname return (fullname, self.method, sig) def needs_arglist(self): return False def add_target_and_index(self, name_cls, sig, signode): signode['ids'].append(http_resource_anchor(*name_cls[1:])) if 'noindex' not in self.options: self.env.domaindata['http'][self.method][sig] = (self.env.docname, self.options.get( 'synopsis', ''), 'deprecated' in self.options) def get_index_text(self, modname, name): return ''
# Monkey patch in a field type for columns. # try: from sphinx.util.docfields import Field, GroupedField, TypedField from sphinx.domains.python import PythonDomain, PyObject, l_, PyField, PyTypedField PyObject.doc_field_types += [ GroupedField('modelparam', label='Model Parameters', names=('modelparam', ), can_collapse=True, rolename='math' ), PyTypedField('expparam', label=l_('Experiment Parameters'), names=('expparam', ), can_collapse=False, rolename='obj' ), PyField('scalar-expparam', label=l_('Experiment Parameter'), names=('scalar-expparam', ), has_arg=True, rolename='obj' ), GroupedField('columns', label=l_('Columns'), names=('column', ), can_collapse=True), ] # except: # pass ############################################################################### import sys, os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.insert(0, os.path.abspath('../../src'))