A `:github:` role for Sphinx

Overview

sphinx-github-role

Documentation Status Code style: black

A github role for Sphinx.

Usage

Basic usage

MyST:

:caption: index.md
See {github}`astrojuanlu/sphinx-github-role#1`.

reStructuredText:

:caption: index.rst
See :github:`astrojuanlu/sphinx-github-role#1`.

Configuring a default organization and project

The extension accepts a configuration github_default_org_project that can be a tuple ("default_org", "default_project") to save some typing. For example, with this configuration:

:caption: conf.py
github_default_org_project = ("astrojuanlu", None)

you can type this:

:caption: index.md
See {github}`sphinx-github-role#1`.

and with this configuration:

:caption: conf.py
github_default_org_project = ("astrojuanlu", "sphinx-github-role")

you only need to type this:

:caption: index.md
See {github}`#1`.

Customizing link text

You can also customize the link text, by wrapping the target in angle brackets:

:caption: index.md
See {github}`this issue <#1>`.

Contribute

Feel free to open an issue to report problems or suggest new features!

Comments
  • Using in RST: Unknown interpreted text role

    Using in RST: Unknown interpreted text role "github".

    Hi there, having seen your recent tweet I wanted to give this package (thanks for developing it!) a shot at https://github.com/autoreject/autoreject/pull/251.

    I did the following:

    • pip-installed sphinx-github-role in my doc build job
    • added the following to my conf.py: github_default_org_project = ("autoreject", "autoreject")
    • used the following syntax in my changelog:
    :github:`#225`
    

    Yet, the rendered docs look broken.

    And the build log gives me an error:

    Using in RST: Unknown interpreted text role "github".

    Can you see what's going wrong? Is that some user error of mine? Or something with sphinx-github-role?

    bug documentation 
    opened by sappelhoff 2
  • Extend the role to allow linking to entire repos

    Extend the role to allow linking to entire repos

    Fixes #17

    This implements the change I described in #17.

    There was one required change to an existing test, since what was previously a malformed link now could now be a reference to a GitHub repository. This has produced a different failure message.

    I've not spent a ton of time working with Python projects before, so let me know if there's anything you'd like changed.

    opened by zml2008 1
  • Support linking directly to projects without an issue

    Support linking directly to projects without an issue

    I'd like to use this role to be able to link directly to GitHub projects, rather than just to specific issues within the projects.

    For example:

    :github:`astrojuanlu/sphinx-github-role`
    

    would link to this repository, without requiring an issue to be specified.

    I'm documenting a project with different components across a variety of repositories, so a shorthand syntax for referencing specific repositories would be helpful.

    enhancement 
    opened by zml2008 1
  • Allow link text change

    Allow link text change

    In the same way that folks can do

    {ref}`doc`
    {ref}`My document <doc>`
    

    it would be cool if we could allow

    {github}`#13`
    {github}`PR #13 <#13>`
    
    enhancement 
    opened by astrojuanlu 0
  • Misc followup from twitter.

    Misc followup from twitter.

    1. docs don't seem to have easy link back to github.

    2. Do you think that non-github / gitlab will be a potential extensions, so you can just do :issue:`#31` regardless of the vcs, and this leads to

    3. Do you believe there could be a project mapping org -> github|gitlab, so that :issue:`projongithub#31` and :issue:`projongitlab#31`

    4. which is not dependent of previous ones, I'd love to have some standardization and use the same extensions on many projects of the scientific ecosystem, and I can try to replace the one we use in IPython when you belive this is ready enough.

    documentation enhancement 
    opened by Carreau 4
  • Float social media previews?

    Float social media previews?

    Wouldn't it be cool if we could show a modal or tooltip with these cool social media previews?

    Screenshot 2021-11-21 at 17-31-23 Card Validator Twitter Developers

    (source: https://cards-dev.twitter.com/validator)

    Content:

    <meta name="twitter:image:src" content="https://opengraph.githubassets.com/d0b6e212f5531e99b4deb14274afa748ddb99ff75bc5d1d8e28d1034ffa2e62d/poliastro/poliastro/pull/1184" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="Move flyby computation to core by Yash-10 · Pull Request #1184 · poliastro/poliastro" /><meta name="twitter:description" content="This PR tries to move computations for threebody flybys to core.
    Thanks!" />
    

    pinging @humitos as my local sphinx-hoverxref expert, and @choldgraf because I've seen you mention this topic a few times on Twitter

    enhancement 
    opened by astrojuanlu 9
  • Disambiguate URL

    Disambiguate URL

    The cool thing about the current approach is that URLs with /issues redirect to /pull if the ID corresponds to a pull request. See it in action:

    https://github.com/astrojuanlu/sphinx-github-role/issues/2 (https://github.com/astrojuanlu/sphinx-github-role/issues/2)

    However, it might "look bad" to have these URLs pointing to issues that are, in fact, pull requests. To my knowledge, the only way to disambiguate this is to make an API call:

    $ curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/astrojuanlu/sphinx-github-role/issues/2 | jq '.["pull_request"]["html_url"]'
    "https://github.com/astrojuanlu/sphinx-github-role/pull/2"
    $ curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/astrojuanlu/sphinx-github-role/issues/4 | jq '.["pull_request"]["html_url"]'
    null
    

    I wonder if it's worth the hassle?

    Pros:

    • Always uses correct-looking URL

    Cons:

    • Can be slow
    • Can be unreliable
    • Might be rate-limited
    • Might require an API key
    question 
    opened by astrojuanlu 0
Releases(v0.1.0)
Owner
Juan Luis Cano Rodríguez
Open Knowledge + Radical Transparency
Juan Luis Cano Rodríguez
Sphinx theme for readthedocs.org

Read the Docs Sphinx Theme This Sphinx theme was designed to provide a great reader experience for documentation users on both desktop and mobile devi

Read the Docs 4.3k Dec 31, 2022
Clases y ejercicios del curso de python diactodo por la UNSAM

Programación en Python En el marco del proyecto de Inteligencia Artificial Interdisciplinaria, la Escuela de Ciencia y Tecnología de la UNSAM vuelve a

Maximiliano Villalva 3 Jan 06, 2022
Read write method - Read files in various types of formats

一个关于所有格式文件读取的方法 1。 问题描述: 各种各样的文件格式,读写操作非常的麻烦,能够有一种方法,可以整合所有格式的文件,方便用户进行读取和写入。 2

2 Jan 26, 2022
This repository outlines deploying a local Kubeflow v1.3 instance on microk8s and deploying a simple MNIST classifier using KFServing.

Zero to Inference with Kubeflow Getting Started This repository houses all of the tools, utilities, and example pipeline implementations for exploring

Ed Henry 3 May 18, 2022
🐱‍🏍 A curated list of awesome things related to Hugo themes.

awesome-hugo-themes Automated deployment @ 2021-10-12 06:24:07 Asia/Shanghai &sorted=updated Theme Author License GitHub Stars Updated Blonde wamo MIT

13 Dec 12, 2022
A tutorial for people to run synthetic data replica's from source healthcare datasets

Synthetic-Data-Replica-for-Healthcare Description What is this? A tailored hands-on tutorial showing how to use Python to create synthetic data replic

11 Mar 22, 2022
Example Python code for running the mango-explorer marketmaker

🥭 Mango Explorer 📖 Introduction This guide will show you how to load and run a customisable marketmaker that runs on Mango Markets using the mango-e

Blockworks Foundation 2 Apr 11, 2022
epub2sphinx is a tool to convert epub files to ReST for Sphinx

epub2sphinx epub2sphinx is a tool to convert epub files to ReST for Sphinx. It uses Pandoc for converting HTML data inside epub files into ReST. It cr

Nihaal 8 Dec 15, 2022
Course Materials for Math 340

UBC Math 340 Materials This repository aims to be the one repository for which you can find everything you about Math 340. Lecture Notes Lecture Notes

2 Nov 25, 2021
This is a small project written to help build documentation for projects in less time.

Documentation-Builder This is a small project written to help build documentation for projects in less time. About This project builds documentation f

Tom Jebbo 2 Jan 17, 2022
Python bindings to OpenSlide

OpenSlide Python OpenSlide Python is a Python interface to the OpenSlide library. OpenSlide is a C library that provides a simple interface for readin

OpenSlide 297 Dec 21, 2022
My Sublime Text theme

rsms sublime text theme Install: cd path/to/your/sublime/packages git clone https://github.com/rsms/sublime-theme.git rsms-theme You'll also need the

Rasmus 166 Jan 04, 2023
SqlAlchemy Flask-Restful Swagger Json:API OpenAPI

SAFRS: Python OpenAPI & JSON:API Framework Overview Installation JSON:API Interface Resource Objects Relationships Methods Custom Methods Class Method

Thomas Pollet 361 Nov 16, 2022
Obmovies - A short guide on setting up the system and environment dependencies required for ob's Movies database

Obmovies - A short guide on setting up the system and environment dependencies required for ob's Movies database

1 Jan 04, 2022
Fast, efficient Blowfish cipher implementation in pure Python (3.4+).

blowfish This module implements the Blowfish cipher using only Python (3.4+). Blowfish is a block cipher that can be used for symmetric-key encryption

Jashandeep Sohi 41 Dec 31, 2022
Python script to generate Vale linting rules from word usage guidance in the Red Hat Supplementary Style Guide

ssg-vale-rules-gen Python script to generate Vale linting rules from word usage guidance in the Red Hat Supplementary Style Guide. These rules are use

Vale at Red Hat 1 Jan 13, 2022
Python For Finance Cookbook - Code Repository

Python For Finance Cookbook - Code Repository

Packt 544 Dec 25, 2022
A swagger tool for tornado, using python to write api doc!

SwaggerDoc About A swagger tool for tornado, using python to write api doc! Installation pip install swagger-doc Quick Start code import tornado.ioloo

aaashuai 1 Jan 10, 2022
A `:github:` role for Sphinx

sphinx-github-role A github role for Sphinx. Usage Basic usage MyST: :caption: index.md See {github}`astrojuanlu/sphinx-github-role#1`. reStructuredT

Juan Luis Cano Rodríguez 4 Nov 22, 2022
Source Code for 'Practical Python Projects' (video) by Sunil Gupta

Apress Source Code This repository accompanies %Practical Python Projects by Sunil Gupta (Apress, 2021). Download the files as a zip using the green b

Apress 2 Jun 01, 2022