|
3 | 3 | from io import StringIO
|
4 | 4 | from pathlib import PosixPath
|
5 | 5 | from copy import deepcopy
|
6 |
| -from numpydoc.numpydoc import mangle_docstrings, _clean_text_signature, update_config |
| 6 | + |
| 7 | +from docutils import nodes |
| 8 | + |
| 9 | +from numpydoc.numpydoc import ( |
| 10 | + mangle_docstrings, |
| 11 | + _clean_text_signature, |
| 12 | + update_config, |
| 13 | + clean_backrefs, |
| 14 | +) |
7 | 15 | from numpydoc.xref import DEFAULT_LINKS
|
8 | 16 | from sphinx.ext.autodoc import ALL
|
9 | 17 | from sphinx.util import logging
|
@@ -262,6 +270,22 @@ def test_update_config_exclude_str():
|
262 | 270 | update_config(app)
|
263 | 271 |
|
264 | 272 |
|
| 273 | +def test_clean_backrefs(): |
| 274 | + """Check ids are not cleaned from inline backrefs.""" |
| 275 | + par = nodes.paragraph(rawsource="", text="") |
| 276 | + inline_ref = nodes.inline(rawsource="", text="", ids=["id1"]) |
| 277 | + inline_ref += nodes.reference(rawsource="", text="[1]", refid="r123-1") |
| 278 | + citation = nodes.citation( |
| 279 | + rawsource="", docname="index", backrefs=["id1"], ids=["r123-1"] |
| 280 | + ) |
| 281 | + citation += nodes.label("1") |
| 282 | + citation += nodes.paragraph(rawsource="", text="Author. Title.") |
| 283 | + par += inline_ref |
| 284 | + par += citation |
| 285 | + clean_backrefs(app=MockApp(), doc=par, docname="index") |
| 286 | + assert "id1" in citation["backrefs"] |
| 287 | + |
| 288 | + |
265 | 289 | if __name__ == "__main__":
|
266 | 290 | import pytest
|
267 | 291 |
|
|
0 commit comments