mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix C coverage support in `sphinx.ext.coverage
` (#11591)
This commit is contained in:
parent
1e0bc26426
commit
53a930f8c7
2
CHANGES
2
CHANGES
@ -84,6 +84,8 @@ Bugs fixed
|
|||||||
* #11473: Type annotations containing :py:data:`~typing.Literal` enumeration
|
* #11473: Type annotations containing :py:data:`~typing.Literal` enumeration
|
||||||
values now render correctly.
|
values now render correctly.
|
||||||
Patch by Bénédikt Tran.
|
Patch by Bénédikt Tran.
|
||||||
|
* #11591: Fix support for C coverage in ``sphinx.ext.coverage`` extension.
|
||||||
|
Patch by Stephen Finucane.
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
-------
|
-------
|
||||||
|
@ -77,7 +77,7 @@ _macroKeywords = [
|
|||||||
'thread_local',
|
'thread_local',
|
||||||
]
|
]
|
||||||
|
|
||||||
# these are ordered by preceedence
|
# these are ordered by precedence
|
||||||
_expression_bin_ops = [
|
_expression_bin_ops = [
|
||||||
['||', 'or'],
|
['||', 'or'],
|
||||||
['&&', 'and'],
|
['&&', 'and'],
|
||||||
|
@ -114,8 +114,9 @@ class CoverageBuilder(Builder):
|
|||||||
self.write_c_coverage()
|
self.write_c_coverage()
|
||||||
|
|
||||||
def build_c_coverage(self) -> None:
|
def build_c_coverage(self) -> None:
|
||||||
# Fetch all the info from the header files
|
c_objects = {}
|
||||||
c_objects = self.env.domaindata['c']['objects']
|
for obj in self.env.domains['c'].get_objects():
|
||||||
|
c_objects[obj[2]] = obj[1]
|
||||||
for filename in self.c_sourcefiles:
|
for filename in self.c_sourcefiles:
|
||||||
undoc: set[tuple[str, str]] = set()
|
undoc: set[tuple[str, str]] = set()
|
||||||
with open(filename, encoding="utf-8") as f:
|
with open(filename, encoding="utf-8") as f:
|
||||||
@ -124,7 +125,11 @@ class CoverageBuilder(Builder):
|
|||||||
match = regex.match(line)
|
match = regex.match(line)
|
||||||
if match:
|
if match:
|
||||||
name = match.groups()[0]
|
name = match.groups()[0]
|
||||||
if name not in c_objects:
|
if key not in c_objects:
|
||||||
|
undoc.add((key, name))
|
||||||
|
continue
|
||||||
|
|
||||||
|
if name not in c_objects[key]:
|
||||||
for exp in self.c_ignorexps.get(key, []):
|
for exp in self.c_ignorexps.get(key, []):
|
||||||
if exp.match(name):
|
if exp.match(name):
|
||||||
break
|
break
|
||||||
|
@ -133,6 +133,8 @@ C items
|
|||||||
|
|
||||||
.. c:var:: int sphinx_global
|
.. c:var:: int sphinx_global
|
||||||
|
|
||||||
|
.. c:function:: PyObject* Py_SphinxFoo(void)
|
||||||
|
|
||||||
|
|
||||||
Javascript items
|
Javascript items
|
||||||
================
|
================
|
||||||
|
@ -1 +1,2 @@
|
|||||||
PyAPI_FUNC(PyObject *) Py_SphinxTest();
|
PyAPI_FUNC(PyObject *) Py_SphinxTest(void);
|
||||||
|
PyAPI_FUNC(PyObject *) Py_SphinxFoo(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user