Skip to content

Fix bug32 #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# mkdocstring-python-xref changes

## 1.16.0

* Compatibility with mkdocstrings-python 1.16.*
* Removed some deprecated imports from mkdoctrings

## 1.14.1

* Restrict to mkdocstrings-python <1.16 (see bug #32)
Expand Down
3 changes: 2 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ channels:
dependencies:
# runtime
- python >=3.9,<3.14
- mkdocstrings-python >=1.14,<1.16 # BUG: #32
- mkdocstrings-python >=1.16.6,<2
- griffe >=1.0
# build
- python-build >=1.0.0
Expand All @@ -24,3 +24,4 @@ dependencies:
- mkdocs >=1.5.3,<2.0
- mkdocs-material >=9.5.4
- linkchecker >=10.4
- pydantic >=2.0
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ keywords = [
dynamic = ["version"]
requires-python = ">=3.9"
dependencies = [
"mkdocstrings-python >=1.14,<1.16", # BUG: #32
"mkdocstrings-python >=1.16.6,<2.0",
"griffe >=1.0"
]

Expand Down
3 changes: 2 additions & 1 deletion src/mkdocstrings_handlers/python_xref/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
1.14.1
1.16

2 changes: 1 addition & 1 deletion src/mkdocstrings_handlers/python_xref/crossref.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from typing import Callable, List, Optional, cast

from griffe import Docstring, Object
from mkdocstrings.loggers import get_logger
from mkdocstrings import get_logger

__all__ = [
"substitute_relative_crossrefs"
Expand Down
35 changes: 4 additions & 31 deletions src/mkdocstrings_handlers/python_xref/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,12 @@
import sys
from dataclasses import dataclass, fields
from pathlib import Path
from textwrap import dedent
from typing import Annotated, Any, ClassVar, Mapping, MutableMapping, Optional
from typing import Any, ClassVar, Mapping, MutableMapping, Optional
from warnings import warn

from mkdocs.config.defaults import MkDocsConfig
from mkdocstrings.handlers.base import CollectorItem
from mkdocstrings.loggers import get_logger
from mkdocstrings_handlers.python.config import PythonOptions, Field, PythonConfig
from mkdocstrings_handlers.python.handler import PythonHandler
from mkdocstrings import CollectorItem, get_logger
from mkdocstrings_handlers.python import PythonHandler, PythonOptions, PythonConfig

from .crossref import substitute_relative_crossrefs

Expand All @@ -38,38 +35,14 @@

logger = get_logger(__name__)


# TODO mkdocstrings 0.28
# - `name` and `domain` (py) must be specified as class attributes
# - `handler` arg to superclass is deprecated
# - add `mdx` arg to constructor to pass on to superclass
# - `config_file_path` arg will no longer be passed
#

# TODO python 3.9 - remove when 3.9 support is dropped
_dataclass_options = {"frozen": True}
if sys.version_info >= (3, 10):
_dataclass_options["kw_only"] = True

@dataclass(**_dataclass_options)
class PythonRelXRefOptions(PythonOptions):
check_crossrefs: Annotated[
bool,
Field(
group="docstrings",
parent="docstring_options",
description=dedent(
"""
Enables early checking of all cross-references.

Note that this option only takes affect if **relative_crossrefs** is
also true. This option is true by default, so this option is used to
disable checking. Checking can also be disabled on a per-case basis by
prefixing the reference with '?', e.g. `[something][?dontcheckme]`.
"""
),
),
] = True
check_crossrefs: bool = True

class PythonRelXRefHandler(PythonHandler):
"""Extended version of mkdocstrings Python handler
Expand Down
Loading