Skip to main content

This Sphinx extension converts GitHub alerts to Sphinx admonitions.

Project description

Sphinx GitHub Alerts

Introduction

This Sphinx extension converts GitHub alerts to Sphinx admonitions.

What does it do?

This extension allows you to use GitHub alerts within your Sphinx project. This is particulary useful if you're editing your sphinx / jupyterbook / teachbook in GitHub, making use of GitHub alerts and the markdown previewer of GitHub. Your Sphinx project will look similar to the preview in GitHub for these GitHub alerts.

Only top-level alerts are allowed and are convert to a top-level admonition in the language (MD or rST) of the source file. The source file does not change.

Nesting is not supported.

If an alert is not recognised, a warning is returned.

Installation

To use this extension, follow these steps:

Step 1: Install the Package

Install the module sphinx-github-alerts package using pip:

pip install sphinx-github-alerts

Step 2: Add to requirements.txt

Make sure that the package is included in your project's requirements.txt to track the dependency:

sphinx-github-alerts

Step 3: Enable in _config.yml or conf.py

In your _config.yml file, add the extension to the list of Sphinx extra extensions (important: underscore, not dash this time):

sphinx: 
    extra_extensions:
        .
        .
        .
        - sphinx_github_alerts
        .
        .
        .

or in your conf.py file, add the extension to the extensions list and specify the location of your bib file:

extensions = [...,"sphinx_github_alerts",...]

Configuration

The extension provides several configuration values, which can be added to your configuration file:

  • sphinx_github_alerts_backquotes: 3 (default) or integer: (only relevant for MarkDown based files) The number of backticks used to start and end the admonitions. Should be at minimum 3.
  • sphinx_github_alerts_leading_spaces: 3 (default) or integer: (only relevant for reStructeredText based files) The number of spaces for indentation within the admonitions. Should be at minimum 1.
  • sphinx_github_alerts_redirects: {} (default) or dict: Every key-value pair in this dictionary redirects the GitHub alert indicated by key to the Sphinx admonition indicated by value.

Examples

For each of the five GitHub alerts, you can see the result below. Note that the result depends on where you are visiting this page.

The codes contain a leading space to enforce showing the code and not converting the code. In any application these leading spaces should not be present.

Note

 > [!NOTE]
 > Useful information that users should know, even when skimming content.

[!NOTE] Useful information that users should know, even when skimming content.

Tip

 > [!TIP]
 > Helpful advice for doing things better or more easily.

[!TIP] Helpful advice for doing things better or more easily.

Important

 > [!IMPORTANT]
 > Key information users need to know to achieve their goal.

[!IMPORTANT] Key information users need to know to achieve their goal.

Warning

 > [!WARNING]
 > Urgent info that needs immediate user attention to avoid problems.

[!WARNING] Urgent info that needs immediate user attention to avoid problems.

Caution

 > [!CAUTION]
 > Advises about risks or negative outcomes of certain actions.
 >
 > But multiline alerts can also be used.

[!CAUTION] Advises about risks or negative outcomes of certain actions.

But multiline alerts can also be used.

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_alerts-1.1.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

sphinx_github_alerts-1.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file sphinx_github_alerts-1.1.tar.gz.

File metadata

  • Download URL: sphinx_github_alerts-1.1.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sphinx_github_alerts-1.1.tar.gz
Algorithm Hash digest
SHA256 6e3065e613b089e6e86821927f70cf4b7af92b038854c693ef44e495cf76121f
MD5 105842df8e17ad26fe44f6e423583395
BLAKE2b-256 da6b38ecddb6faa15a8ca359afcabaa728df66a2559a68e98851bdc38adbd898

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_github_alerts-1.1.tar.gz:

Publisher: python-publish.yml on TeachBooks/Sphinx-GitHub-Alerts

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sphinx_github_alerts-1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for sphinx_github_alerts-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 57ff740d461c1670386c40aa4dd1e42794b5b7d48eabb6889b680ef1a17a1602
MD5 475c0da0038d48e601db64e6a4c0ed6f
BLAKE2b-256 19a5ec4c322063caff100c15415a48facc1501083e81ebf7a01426c1167d63bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_github_alerts-1.1-py3-none-any.whl:

Publisher: python-publish.yml on TeachBooks/Sphinx-GitHub-Alerts

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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