Skip to content

Enable scoped references in mkdocs #472

@llucax

Description

@llucax

What's needed?

In mkdocstrings-python 1.19, finally we can write relative and scoped references in docs, avoiding the huge strings to do cross references:

class VeryLongClassName:

    some_prop: int
    """Some doc.

    This does whatever with [some_meth()][frequenz.some.package.very.nested.and.with.VeryLongClassName.some_meth].
    """

    def some_meth(): ...

Now can be something like:

[`some_meth()`][some_meth]

Proposed solution

Depend on 1.19 and enable the new options in the templates and this project:

plugins:
- mkdocstrings:
    handlers:
      python:
        options:
          relative_crossrefs: true
          scoped_crossrefs: true

Use cases

No response

Alternatives and workarounds

No response

Additional context

Limitations of scoped cross-refs:

Cross-referencing an imported object will directly link to this object if the objects inventory of the project it comes from was loaded. You won't be able to cross-reference it within your own documentation with scoped references, if you happen to be rendering this external object too. In that case, you can use an absolute reference or a relative one instead.

Another limitation is that you won't be able to reference an external package if its name can be resolved in the current object's scope.

Metadata

Metadata

Assignees

No one assigned

    Labels

    part:mkdocsAffects the configuration of mkdocspart:templateAffects the cookiecutter template filestype:enhancementNew feature or enhancement visitble to users

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions