Code Monkey home page Code Monkey logo

mkdocstrings-python-xref's Introduction

mkdocstrings-python-xref

Python handler for mkdocstrings supporting relative cross-references.

pypi version conda version documentation
PyPI - Python Version GitHub
CI GitHub issues

mkdocstrings is an awesome plugin for MkDocs that can generate Markdown API documentation from comments in code. The standard python handler allows you to create cross-reference links using the syntax [<title>][<path>] where the path must either be the fully qualified name of the referent or is empty, in which case the path is taken from the title. This works well when the names are short, but can be burdensome in larger codebases with deeply nested package structures.

This package extends mkdocstrings-python to support a relative cross-reference syntax, that allows you to write doc-strings with cross-references like:

class MyClass:
    def this_method(self):
        """
        See [other_method][..] from [MyClass][(c)]
        """

rather than:

class MyClass:
    def this_method(self):
        """
        See [other_method][mypkg.mymod.MyClass.other_method] 
        from [MyClass][mypkg.mymod.Myclass]
        """

Another benefit of this extension is that it will report source locations for bad references so that errors are easier to find and fix. For example:

$ mkdocs build
INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /home/jdoe/my-project/site
WARNING -  mkdocstrings_handlers: file:///home/jdoe/my-project/src/myproj/bar.py:16:
           Cannot load reference 'myproj.bar.bad'

For further details, please see the Documentation

mkdocstrings-python-xref's People

Contributors

analog-cbarber avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

analog-cbarber

mkdocstrings-python-xref's Issues

Consider easier to type class/module/package syntax

Currently, you can write references like [(c)], [(m).foo].

Some other possible syntaxes:

Parens comma colon semicolon equals slash
[(c)] [c,] [c:] [c;] [c=] [c/]
[(c).] [c,.] [c:.] [c;.] [c=.] [c/.]
[(c).foo] [c,foo] [c:foo] [c;foo]. [c=foo] [c/foo].

Limit number of parent specifiers (i.e. ^^ or ..)

In practice, we have found that using too many ^^ or .. specifiers requires too much
mental gymnastics on the part of the reader and detract from readability.

We could either disallow more than one or two levels or we could add an
option to specify the max. Or we could simply recommend against too many
levels in the documentation.

Update to use mkdocstrings-python v1.8+

mkdocstrings-python had a few new releases with very interesting features that would be good to have available in this extension too.

I guess it is probably not doable, but it would be good if this extension could be somehow installed alongside any version of mkdocstring-python, so it is not necessary to catch up to every mkdocstring-python.

Option to check all crossrefs to get correct source info

Currently we only check cross-refs generated using this mechanism, other cross-refs
using absolute paths don't get checked until after rendering so source location
information is lost.

We should add an option to check all cross-refs.

distribute on anaconda channel

Until there is a conda-forge distribution (#7), we could simply build the conda package and
push it to our own anaconda channel.

Find parent doc string for relative crossrefs

mkdocstrings does not currently support references to members not explicitly defined in subclass, so
instead of just being able to write something like [foo][.] you might have to write [foo][(m).ParentClass.]
or worse.

It would be nice if we could automatically handle this redirection.

The syntax `[symbol][]` doesn't work as in `mkdocstrings-python`

I'm trying to migrate a project using mkdocstrings-python to use this handler instead, and I use the syntax [symbol][] quite a bit, but it doesn't seem to be working with this handler. In particular I use it a lot to link to Python stdlib symbols, like [asyncio][], [float][], etc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.