^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) # -*- coding: utf-8; mode: python -*-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # pylint: disable=W0141,C0113,C0103,C0325
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) u"""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) cdomain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) ~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) Replacement for the sphinx c-domain.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) :copyright: Copyright (C) 2016 Markus Heiser
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) :license: GPL Version 2, June 1991 see Linux/COPYING for details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) List of customizations:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * Moved the *duplicate C object description* warnings for function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) declarations in the nitpicky mode. See Sphinx documentation for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) the config values for ``nitpick`` and ``nitpick_ignore``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * Add option 'name' to the "c:function:" directive. With option 'name' the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) ref-name of a function can be modified. E.g.::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) .. c:function:: int ioctl( int fd, int request )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) :name: VIDIOC_LOG_STATUS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) The func-name (e.g. ioctl) remains in the output but the ref-name changed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) from 'ioctl' to 'VIDIOC_LOG_STATUS'. The function is referenced by::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * :c:func:`VIDIOC_LOG_STATUS` or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * :any:`VIDIOC_LOG_STATUS` (``:any:`` needs sphinx 1.3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * Handle signatures of function-like macros well. Don't try to deduce
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) arguments types of function-like macros.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) """
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) from docutils import nodes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) from docutils.parsers.rst import directives
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) import sphinx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) from sphinx import addnodes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) from sphinx.domains.c import c_funcptr_sig_re, c_sig_re
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) from sphinx.domains.c import CObject as Base_CObject
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) from sphinx.domains.c import CDomain as Base_CDomain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) from itertools import chain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) import re
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) __version__ = '1.1'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) # Get Sphinx version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) major, minor, patch = sphinx.version_info[:3]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) # Namespace to be prepended to the full name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) namespace = None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) # Handle trivial newer c domain tags that are part of Sphinx 3.1 c domain tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) # - Store the namespace if ".. c:namespace::" tag is found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) RE_namespace = re.compile(r'^\s*..\s*c:namespace::\s*(\S+)\s*$')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) def markup_namespace(match):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) global namespace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) namespace = match.group(1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) return ""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) # Handle c:macro for function-style declaration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) RE_macro = re.compile(r'^\s*..\s*c:macro::\s*(\S+)\s+(\S.*)\s*$')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) def markup_macro(match):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) return ".. c:function:: " + match.group(1) + ' ' + match.group(2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) # Handle newer c domain tags that are evaluated as .. c:type: for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) # backward-compatibility with Sphinx < 3.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) RE_ctype = re.compile(r'^\s*..\s*c:(struct|union|enum|enumerator|alias)::\s*(.*)$')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) def markup_ctype(match):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) return ".. c:type:: " + match.group(2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) # Handle newer c domain tags that are evaluated as :c:type: for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) # backward-compatibility with Sphinx < 3.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) RE_ctype_refs = re.compile(r':c:(var|struct|union|enum|enumerator)::`([^\`]+)`')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) def markup_ctype_refs(match):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) return ":c:type:`" + match.group(2) + '`'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) # Simply convert :c:expr: and :c:texpr: into a literal block.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) RE_expr = re.compile(r':c:(expr|texpr):`([^\`]+)`')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) def markup_c_expr(match):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) return '\ ``' + match.group(2) + '``\ '
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) # Parse Sphinx 3.x C markups, replacing them by backward-compatible ones
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) def c_markups(app, docname, source):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) result = ""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) markup_func = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) RE_namespace: markup_namespace,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) RE_expr: markup_c_expr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) RE_macro: markup_macro,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) RE_ctype: markup_ctype,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) RE_ctype_refs: markup_ctype_refs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) lines = iter(source[0].splitlines(True))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) for n in lines:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) match_iterators = [regex.finditer(n) for regex in markup_func]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) matches = sorted(chain(*match_iterators), key=lambda m: m.start())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) for m in matches:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) n = n[:m.start()] + markup_func[m.re](m) + n[m.end():]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) result = result + n
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) source[0] = result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) # Now implements support for the cdomain namespacing logic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) def setup(app):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) # Handle easy Sphinx 3.1+ simple new tags: :c:expr and .. c:namespace::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) app.connect('source-read', c_markups)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) if (major == 1 and minor < 8):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) app.override_domain(CDomain)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) else:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) app.add_domain(CDomain, override=True)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) return dict(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) version = __version__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) parallel_read_safe = True,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) parallel_write_safe = True
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) class CObject(Base_CObject):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) """
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) Description of a C language object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) """
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) option_spec = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) "name" : directives.unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) def handle_func_like_macro(self, sig, signode):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) u"""Handles signatures of function-like macros.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) If the objtype is 'function' and the the signature ``sig`` is a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) function-like macro, the name of the macro is returned. Otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) ``False`` is returned. """
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) global namespace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) if not self.objtype == 'function':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) return False
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) m = c_funcptr_sig_re.match(sig)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) if m is None:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) m = c_sig_re.match(sig)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) if m is None:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) raise ValueError('no match')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) rettype, fullname, arglist, _const = m.groups()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) arglist = arglist.strip()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) if rettype or not arglist:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) return False
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) arglist = arglist.replace('`', '').replace('\\ ', '') # remove markup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) arglist = [a.strip() for a in arglist.split(",")]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) # has the first argument a type?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) if len(arglist[0].split(" ")) > 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) return False
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) # This is a function-like macro, it's arguments are typeless!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) signode += addnodes.desc_name(fullname, fullname)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) paramlist = addnodes.desc_parameterlist()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) signode += paramlist
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) for argname in arglist:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) param = addnodes.desc_parameter('', '', noemph=True)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) # separate by non-breaking space in the output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) param += nodes.emphasis(argname, argname)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) paramlist += param
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) if namespace:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) fullname = namespace + "." + fullname
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) return fullname
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) def handle_signature(self, sig, signode):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) """Transform a C signature into RST nodes."""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) global namespace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) fullname = self.handle_func_like_macro(sig, signode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) if not fullname:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) fullname = super(CObject, self).handle_signature(sig, signode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) if "name" in self.options:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) if self.objtype == 'function':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) fullname = self.options["name"]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) else:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) # FIXME: handle :name: value of other declaration types?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) pass
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) else:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) if namespace:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) fullname = namespace + "." + fullname
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) return fullname
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) def add_target_and_index(self, name, sig, signode):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) # for C API items we add a prefix since names are usually not qualified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) # by a module name and so easily clash with e.g. section titles
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) targetname = 'c.' + name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) if targetname not in self.state.document.ids:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) signode['names'].append(targetname)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) signode['ids'].append(targetname)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) signode['first'] = (not self.names)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) self.state.document.note_explicit_target(signode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) inv = self.env.domaindata['c']['objects']
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) if (name in inv and self.env.config.nitpicky):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) if self.objtype == 'function':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) if ('c:func', name) not in self.env.config.nitpick_ignore:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) self.state_machine.reporter.warning(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 'duplicate C object description of %s, ' % name +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 'other instance in ' + self.env.doc2path(inv[name][0]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) line=self.lineno)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) inv[name] = (self.env.docname, self.objtype)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) indextext = self.get_index_text(name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) if indextext:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) if major == 1 and minor < 4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) # indexnode's tuple changed in 1.4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) # https://github.com/sphinx-doc/sphinx/commit/e6a5a3a92e938fcd75866b4227db9e0524d58f7c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) self.indexnode['entries'].append(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) ('single', indextext, targetname, ''))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) else:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) self.indexnode['entries'].append(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) ('single', indextext, targetname, '', None))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) class CDomain(Base_CDomain):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) """C language domain."""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) name = 'c'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) label = 'C'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) directives = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 'function': CObject,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 'member': CObject,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 'macro': CObject,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 'type': CObject,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 'var': CObject,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) }