diff --git a/.copier-answers.yml b/.copier-answers.yml
index 9c4832f4..da168350 100644
--- a/.copier-answers.yml
+++ b/.copier-answers.yml
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier
-_commit: 0.16.9
+_commit: 0.16.10
_src_path: gh:pawamoy/copier-pdm
author_email: pawamoy@pm.me
author_fullname: Timothée Mazzucotelli
diff --git a/CHANGELOG.md b/CHANGELOG.md
index afb47eca..e63f4e29 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,18 @@ 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).
+## [1.7.2](https://github.com/mkdocstrings/python/releases/tag/1.7.2) - 2023-10-05
+
+[Compare with 1.7.1](https://github.com/mkdocstrings/python/compare/1.7.1...1.7.2)
+
+### Bug Fixes
+
+- Prevent alias resolution error when source-ordering members ([67df10c](https://github.com/mkdocstrings/python/commit/67df10cbb86225e1e3efc251325cbff883a1ef3c) by Timothée Mazzucotelli). [Issue griffe#213](https://github.com/mkdocstrings/griffe/issues/213)
+
+### Code Refactoring
+
+- Use package relative filepath if filepath is not relative ([aa5a3f7](https://github.com/mkdocstrings/python/commit/aa5a3f7b0928498ba9da10ed1211d1e55b7f6c4b) by Timothée Mazzucotelli). [Discussion mkdocstrings#622](https://github.com/mkdocstrings/mkdocstrings/discussions/622)
+
## [1.7.1](https://github.com/mkdocstrings/python/releases/tag/1.7.1) - 2023-09-28
[Compare with 1.7.0](https://github.com/mkdocstrings/python/compare/1.7.0...1.7.1)
diff --git a/docs/credits.md b/docs/credits.md
index 9db45873..f758db87 100644
--- a/docs/credits.md
+++ b/docs/credits.md
@@ -3,6 +3,8 @@ hide:
- toc
---
+
```python exec="yes"
--8<-- "scripts/gen_credits.py"
```
+
diff --git a/docs/insiders/index.md b/docs/insiders/index.md
index 66146fff..a6df4a4d 100644
--- a/docs/insiders/index.md
+++ b/docs/insiders/index.md
@@ -59,24 +59,20 @@ a handful of them, [thanks to our awesome sponsors][sponsors]! -->
data_source = "docs/insiders/goals.yml"
```
+
```python exec="1" session="insiders"
--8<-- "scripts/insiders.py"
-```
-
-
-We currently don't have any features available to sponsors only.
-Right now we are putting our efforts into the documentation,
-then we will start again implementing features.
-You can get updates on *mkdocstrings-python Insiders* work
-by following **@pawamoy** on :material-mastodon:{ .mastodon } [Fosstodon](https://fosstodon.org/@pawamoy).
+```
+
## How to become a sponsor
diff --git a/scripts/gen_credits.py b/scripts/gen_credits.py
index bc01c0bd..459f2939 100644
--- a/scripts/gen_credits.py
+++ b/scripts/gen_credits.py
@@ -3,7 +3,7 @@
from __future__ import annotations
import re
-import sys
+from importlib.metadata import PackageNotFoundError, metadata
from itertools import chain
from pathlib import Path
from textwrap import dedent
@@ -13,11 +13,6 @@
from jinja2 import StrictUndefined
from jinja2.sandbox import SandboxedEnvironment
-if sys.version_info < (3, 8):
- from importlib_metadata import PackageNotFoundError, metadata
-else:
- from importlib.metadata import PackageNotFoundError, metadata
-
project_dir = Path(".")
pyproject = toml.load(project_dir / "pyproject.toml")
project = pyproject["project"]
diff --git a/src/mkdocstrings_handlers/python/rendering.py b/src/mkdocstrings_handlers/python/rendering.py
index ef4b5071..c54eb2cd 100644
--- a/src/mkdocstrings_handlers/python/rendering.py
+++ b/src/mkdocstrings_handlers/python/rendering.py
@@ -37,6 +37,8 @@ def _sort_key_alphabetical(item: CollectorItem) -> Any:
def _sort_key_source(item: CollectorItem) -> Any:
# if 'lineno' is none, the item will go to the start of the list.
+ if item.is_alias:
+ return item.alias_lineno if item.alias_lineno is not None else -1
return item.lineno if item.lineno is not None else -1
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/class.html b/src/mkdocstrings_handlers/python/templates/material/_base/class.html
index a62459b1..ae8a2774 100644
--- a/src/mkdocstrings_handlers/python/templates/material/_base/class.html
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/class.html
@@ -98,14 +98,28 @@
{% if config.show_source %}
{% if config.merge_init_into_class %}
{% if "__init__" in class.all_members and class.all_members["__init__"].source %}
-
- Source code in {{ class.relative_filepath }}
- {{ class.all_members["__init__"].source|highlight(language="python", linestart=class.all_members["__init__"].lineno, linenums=True) }}
-
+ {% with init = class.all_members["__init__"] %}
+
+ Source code in
+ {%- if init.relative_filepath.is_absolute() -%}
+ {{ init.relative_package_filepath }}
+ {%- else -%}
+ {{ init.relative_filepath }}
+ {%- endif -%}
+
+ {{ init.source|highlight(language="python", linestart=init.lineno, linenums=True) }}
+
+ {% endwith %}
{% endif %}
{% elif class.source %}
- Source code in {{ class.relative_filepath }}
+ Source code in
+ {%- if class.relative_filepath.is_absolute() -%}
+ {{ class.relative_package_filepath }}
+ {%- else -%}
+ {{ class.relative_filepath }}
+ {%- endif -%}
+
{{ class.source|highlight(language="python", linestart=class.lineno, linenums=True) }}
{% endif %}
diff --git a/src/mkdocstrings_handlers/python/templates/material/_base/function.html b/src/mkdocstrings_handlers/python/templates/material/_base/function.html
index c12bb1c3..341b0825 100644
--- a/src/mkdocstrings_handlers/python/templates/material/_base/function.html
+++ b/src/mkdocstrings_handlers/python/templates/material/_base/function.html
@@ -74,7 +74,13 @@
{% block source scoped %}
{% if config.show_source and function.source %}
- {{ lang.t("Source code in") }} {{ function.relative_filepath }}
+ {{ lang.t("Source code in") }}
+ {%- if function.relative_filepath.is_absolute() -%}
+ {{ function.relative_package_filepath }}
+ {%- else -%}
+ {{ function.relative_filepath }}
+ {%- endif -%}
+
{{ function.source|highlight(language="python", linestart=function.lineno, linenums=True) }}
{% endif %}
diff --git a/tests/test_rendering.py b/tests/test_rendering.py
index b7b7af82..38d81dbb 100644
--- a/tests/test_rendering.py
+++ b/tests/test_rendering.py
@@ -156,10 +156,12 @@ def test_ordering_members(order: rendering.Order, members_list: list[str | None]
"""
class Obj:
- def __init__(self, name: str, lineno: int | None = None) -> None:
+ def __init__(self, name: str, lineno: int | None = None, *, is_alias: bool = False) -> None:
self.name = name
self.lineno = lineno
+ self.alias_lineno = lineno
+ self.is_alias = is_alias
- members = [Obj("a", 10), Obj("b", 9), Obj("c", 8)]
+ members = [Obj("a", 10, is_alias=True), Obj("b", 9, is_alias=False), Obj("c", 8, is_alias=True)]
ordered = rendering.do_order_members(members, order, members_list) # type: ignore[arg-type]
assert [obj.name for obj in ordered] == expected_names