Skip to main content

Sphinx Github Integration and Github Dark Theme Pygments Style

Project description

Sphinx GitHub Style: GitHub Integration and Pygments Style for Sphinx Documentation

GitHub source code links and syntax highlighting for Sphinx docs

Explore the docs »


PyPI Version GitHub Repository https://static.pepy.tech/personalized-badge/sphinx-github-style?period=total&units=none&left_color=grey&right_color=blue&left_text=Downloads Documentation Status

About

sphinx-github-style is a Sphinx extension that makes your docs look like and link to GitHub

Syntax Highlighting

sphinx-github-style also contains a Pygments style to highlight code in your documentation similar to GitHub:


https://user-images.githubusercontent.com/96394652/220946796-bf7aa236-964d-48e7-83e2-142aac00b0dd.png

Installation

To install using pip:

pip install sphinx-github-style

Configuration

Add the extension to your conf.py

extensions = [
    "sphinx_github_style",
]

Optional Configuration Variables

Add any of the following configuration variables to your conf.py

linkcode_blob

linkcode_blob: str = "head"

The blob to link to on GitHub - any of "head", "last_tag", or "{blob}"

  • head (default): links to the most recent commit hash; if this commit is tagged, uses the tag instead

  • last_tag: links to the most recent commit tag on the currently checked out branch

  • blob: links to any blob you want, for example "master" or "v2.0.1"

linkcode_url

linkcode_url: str = f"https://github.com/{html_context['github_user']}/{html_context['github_repo']}/{html_context['github_version']}"

The link to your GitHub repository formatted as https://github.com/user/repo

  • If not provided, will attempt to create the link from the html_context dict

linkcode_resolve

linkcode_resolve: Callable

A linkcode_resolve() function to use for resolving the link target


Noteworthy Components

  • TDKStyle - Pygments Style for syntax highlighting similar to Github Pretty Lights Dark Theme

  • TDKMethLexer - Pygments Lexor to add syntax highlighting to methods

  • get_linkcode_resolve() - to link to GitHub source code using sphinx.ext.linkcode

  • add_linkcode_node_class() - adds a new linkcode-link class, allowing for CSS styling separately from viewcode links

  • github_style.css - CSS styling for linkcode links (icon + text)


Documentation

Full documentation can be found on ReadTheDocs

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

sphinx-github-style-1.0.3.tar.gz (12.2 kB view hashes)

Uploaded Source

Built Distribution

sphinx_github_style-1.0.3-py3-none-any.whl (11.5 kB view hashes)

Uploaded Python 3

Supported by

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