diff --git a/CHANGELOG.md b/CHANGELOG.md
index f6aade5e..b9606a25 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
+## [0.10.1](https://github.com/mkdocstrings/python/releases/tag/0.10.1) - 2023-05-07
+
+[Compare with 0.10.0](https://github.com/mkdocstrings/python/compare/0.10.0...0.10.1)
+
+### Bug Fixes
+
+- Format signatures with full-path names ([685512d](https://github.com/mkdocstrings/python/commit/685512decf1a14c53fa6ca82048e65619aa6a463) by Timothée Mazzucotelli).
+
## [0.10.0](https://github.com/mkdocstrings/python/releases/tag/0.10.0) - 2023-05-07
[Compare with 0.9.0](https://github.com/mkdocstrings/python/compare/0.9.0...0.10.0)
diff --git a/docs/usage/configuration/signatures.md b/docs/usage/configuration/signatures.md
index 822c8f6d..9d978fb5 100644
--- a/docs/usage/configuration/signatures.md
+++ b/docs/usage/configuration/signatures.md
@@ -36,13 +36,14 @@ plugins:
import markdown
import markupsafe
+
def convert(text: str, md: markdown.Markdown) -> markupsafe.Markup:
"""Convert text to Markdown.
Parameters:
text: The text to convert.
md: A Markdown instance.
-
+
Returns:
Converted markup.
"""
diff --git a/duties.py b/duties.py
index 3d7592d3..9b93ca81 100644
--- a/duties.py
+++ b/duties.py
@@ -197,7 +197,7 @@ def docs_deploy(ctx: Context) -> None:
if config_file == "mkdocs.yml":
ctx.run(lambda: False, title="Not deploying docs without Material for MkDocs Insiders!")
origin = ctx.run("git config --get remote.origin.url", silent=True)
- if "pawamoy-insiders/python" in origin:
+ if "pawamoy-insiders/mkdocstrings-python" in origin:
ctx.run("git remote add upstream git@github.com:mkdocstrings/python", silent=True, nofail=True)
ctx.run(
mkdocs.gh_deploy(config_file=config_file, remote_name="upstream", force=True),
@@ -224,7 +224,7 @@ def format(ctx: Context) -> None:
)
ctx.run(black.run(*PY_SRC_LIST, config="config/black.toml"), title="Formatting code")
ctx.run(
- blacken_docs.run(*PY_SRC_LIST, "docs", exts=["py", "md"], line_length=120),
+ blacken_docs.run(*PY_SRC_LIST, "docs", exts=["py", "md"], line_length=120, skip_errors=True),
title="Formatting docs",
nofail=True,
)
diff --git a/src/mkdocstrings_handlers/python/rendering.py b/src/mkdocstrings_handlers/python/rendering.py
index 70a34ca3..7edfd7ac 100644
--- a/src/mkdocstrings_handlers/python/rendering.py
+++ b/src/mkdocstrings_handlers/python/rendering.py
@@ -73,10 +73,18 @@ def do_format_signature(signature: str, line_length: int) -> str:
code = signature.strip()
if len(code) < line_length:
return code
+
+ # Black cannot format names with dots, so we replace
+ # the whole name with a string of equal length
+ name_length = code.index("(")
+ name = code[:name_length]
formatter = _get_black_formatter()
- formatted = formatter(f"def {code}: pass", line_length)
- # remove starting `def ` and trailing `: pass`
- return formatted[4:-5].strip()[:-1]
+ formatable = f"def {'x' * name_length}{code[name_length:]}: pass"
+ formatted = formatter(formatable, line_length)
+
+ # We put back the original name
+ # and remove starting `def ` and trailing `: pass`
+ return name + formatted[4:-5].strip()[name_length:-1]
def do_order_members(
diff --git a/tests/test_rendering.py b/tests/test_rendering.py
index 45b6048b..fc970c57 100644
--- a/tests/test_rendering.py
+++ b/tests/test_rendering.py
@@ -11,12 +11,35 @@
from mkdocstrings_handlers.python import rendering
-def test_format_code_and_signature() -> None:
- """Assert code and signatures can be Black-formatted."""
- assert rendering.do_format_code("print('Hello')", 100)
- assert rendering.do_format_code('print("Hello")', 100)
- assert rendering.do_format_signature("(param: str = 'hello') -> 'Class'", 100)
- assert rendering.do_format_signature('(param: str = "hello") -> "Class"', 100)
+@pytest.mark.parametrize(
+ "code",
+ [
+ "print('Hello')",
+ "aaaaa(bbbbb, ccccc=1) + ddddd.eeeee[ffff] or {ggggg: hhhhh, iiiii: jjjjj}",
+ ],
+)
+def test_format_code(code: str) -> None:
+ """Assert code can be Black-formatted.
+
+ Parameters:
+ code: Code to format.
+ """
+ for length in (5, 100):
+ assert rendering.do_format_code(code, length)
+
+
+@pytest.mark.parametrize(
+ "signature",
+ ["Class.method(param: str = 'hello') -> 'OtherClass'"],
+)
+def test_format_signature(signature: str) -> None:
+ """Assert signatures can be Black-formatted.
+
+ Parameters:
+ signature: Signature to format.
+ """
+ for length in (5, 100):
+ assert rendering.do_format_signature(signature, length)
@dataclass