Skip to main content

Tweaks for `mkdocstrings[python]`

Project description

Hippogriffe

This is a set of tweaks on top of the MkDocs + mkdocstrings[python] + griffe documentation stack. In particular, we:

  • Add [source] links to GitHub to each top-level class or function.
  • Pretty-format type annotations:
    • Fixes unions/generics/etc. to display as e.g. int | str rather than just Union, or tuple[int, str] rather than just tuple.
    • Respects your public API: if a type is declared in your documentation as ::: yourlib.Foo then its usage in type annotations will match: some_fn(foo: yourlib.Foo).
  • Show base classes inline after the class.
  • Drops the -> None return annotation from __init__ methods.
  • Attributes display as [attr] somelib.someattr instead of [attr] somelib.someattr = some_value [module]. (I don't find usually-long default values to be useful documentation, nor the 'module' tag to be informative.)
Before After
old new

Installation

pip install hippogriffe

Requires MkDocs 1.6.1+ and mkdocstrings[python] 0.28.3+

Usage

In mkdocs.yml:

...

plugins:
    - hippogriffe
    - mkdocstrings:
        ...

Configuration

Hippogriffe supports the following configuration options:

plugins:
    - hippogriffe:
        show_bases: true/false
        show_source_links: all/toplevel/none
        extra_public_modules:
            - foo
            - bar

show_bases:

If false then base classes will not be displayed alongside a class. Defaults to true.

show_source_links:

Sets which objects will have links to their location in the repository (as configured via the usual MkDocs repo_url). If all then all objects will have links. If toplevel then just ::: somelib.value will have links, but their members will not. If none then no links will be added. Defaults to toplevel.

extra_public_modules:

A list of module names whose elements should be treated as part of the public API. Pretty-formatting of type annotations is done strictly: every annotation must be part of the known public API, else an error will be raised. The public API is defined as the combination of:

  • Everything you document using ::: yourlib.Foo, and all of their members.
  • Anything from the standard library.
  • All objects belonging to any of extra_public_modules.

For example,

plugins:
    - hippogriffe:
        extra_public_modules:
            - jax
            - torch

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hippogriffe-0.1.3.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hippogriffe-0.1.3-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file hippogriffe-0.1.3.tar.gz.

File metadata

  • Download URL: hippogriffe-0.1.3.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for hippogriffe-0.1.3.tar.gz
Algorithm Hash digest
SHA256 1d568e25d3f0679229bcbce3f72934649ab3d93f1515b0abf413ffbdb44d23bf
MD5 dbc934f9518420004316f61dae486a5b
BLAKE2b-256 f2345b78a6fb2e3699de923f0b83eaa9ee1e7b45c74b4197fb6c968c13b2e2c6

See more details on using hashes here.

File details

Details for the file hippogriffe-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: hippogriffe-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for hippogriffe-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ae584b7a129edb54db45cf6a3ae62242f21c06d3c409ab3f7d737b1a390a47c3
MD5 752b4b18fbb1ba0ba78bd4729a2bcde2
BLAKE2b-256 b5813561d6020e83112a4bf508e80c8efec8ceee787a8b77c3e56c1ecaec58c6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page