scanpydoc
latest
  • scanpydoc.autosummary_generate_imported
  • scanpydoc.definition_list_typed_field
  • scanpydoc.elegant_typehints
  • scanpydoc.rtd_github_links
    • Configuration
    • Usage
    • Functions
      • github_url()
      • setup()
  • scanpydoc.theme
scanpydoc
  • »
  • scanpydoc.rtd_github_links
  • Edit on GitHub

scanpydoc.rtd_github_links¶

GitHub URLs for class and method pages

This extension registers a Jinja filter called github_url() that you can use to convert a module path into a GitHub URL

Configuration¶

Uses the following config values in conf.py:

project_dir: Path = ...  # default: Path.cwd()
html_context = dict(
    github_user=...,
    github_repo=...,
    github_version=...,
)

The project_dir is used to figure out the .py file path relative to the git root, that is to construct the path in the github URL.

The html_context is e.g. also used like this in the sphinx_rtd_theme.

Usage¶

You can use the filter e.g. in autosummary templates. To configure the sphinx_rtd_theme, override the autosummary/base.rst template like this:

:github_url: {{ fullname | github_url }}

{% extends "!autosummary/base.rst" %}

Functions¶

github_url(qualname)¶

Get the full GitHub URL for some object’s qualname.

Parameters:
qualname : str

The full qualified name of a function, class, method or module

Return type:

str

Returns:

A GitHub URL derived from the html_context.

setup(app)¶

Register the github_url() Jinja filter.

Parameters:
app : Sphinx

Sphinx app to set this extension up for

Return type:

{str: Any}Dict[str, Any]

Returns:

Metadata for this extension.

Next Previous

© Copyright 2023, Philipp Angerer.. Revision 909d4817.

Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: latest
Versions
latest
stable
Downloads
On Read the Docs
Project Home
Builds