MCPcopy Index your code
hub / github.com/python/cpython / _stable_abi_annotation

Function _stable_abi_annotation

Doc/tools/extensions/c_annotations.py:206–279  ·  view source on GitHub ↗

Create the Stable ABI annotation. These have two forms: Part of the `Stable ABI `_. Part of the `Stable ABI `_ since version X.Y. For structs, there's some more info in the message: Part of the `Limited API `_ (as an opaque struct). Part of the `Sta

(
    record: StableABIEntry,
    is_corresponding_slot: bool = False,
)

Source from the content-addressed store, hash-verified

204
205
206def _stable_abi_annotation(
207 record: StableABIEntry,
208 is_corresponding_slot: bool = False,
209) -> nodes.emphasis:
210 """Create the Stable ABI annotation.
211
212 These have two forms:
213 Part of the `Stable ABI <link>`_.
214 Part of the `Stable ABI <link>`_ since version X.Y.
215 For structs, there&#x27;s some more info in the message:
216 Part of the `Limited API <link>`_ (as an opaque struct).
217 Part of the `Stable ABI <link>`_ (including all members).
218 Part of the `Limited API <link>`_ (Only some members are part
219 of the stable ABI.).
220 ... all of which can have "since version X.Y" appended.
221 """
222 stable_added = record.added
223 emph_node = nodes.emphasis('', '', classes=["stableabi"])
224 if is_corresponding_slot:
225 # See "Type slot annotations" in add_annotations
226 ref_node = addnodes.pending_xref(
227 "slot ID",
228 refdomain="c",
229 reftarget="PyType_Slot",
230 reftype="type",
231 refexplicit="True",
232 )
233 ref_node += nodes.Text(sphinx_gettext("slot ID"))
234
235 message = sphinx_gettext("The corresponding")
236 emph_node += nodes.Text(" " + message + " ")
237 emph_node += ref_node
238 emph_node += nodes.Text(" ")
239 emph_node += nodes.literal(record.name, record.name)
240 message = sphinx_gettext("is part of the")
241 emph_node += nodes.Text(" " + message + " ")
242 else:
243 message = sphinx_gettext("Part of the")
244 emph_node += nodes.Text(" " + message + " ")
245 ref_node = addnodes.pending_xref(
246 "Stable ABI",
247 refdomain="std",
248 reftarget="stable",
249 reftype="ref",
250 refexplicit="False",
251 )
252 struct_abi_kind = record.struct_abi_kind
253 if struct_abi_kind in {"opaque", "members"}:
254 ref_node += nodes.Text(sphinx_gettext("Limited API"))
255 else:
256 ref_node += nodes.Text(sphinx_gettext("Stable ABI"))
257 emph_node += ref_node
258 if struct_abi_kind == "opaque":
259 emph_node += nodes.Text(" " + sphinx_gettext("(as an opaque struct)"))
260 elif struct_abi_kind == "full-abi":
261 emph_node += nodes.Text(
262 " " + sphinx_gettext("(including all members)")
263 )

Callers 2

add_annotationsFunction · 0.85
runMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…