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
100 Days of Code Learning program to keep a habit of coding daily and learn things at your own pace with help from our remote community.

100 Days of Code Learning program to keep a habit of coding daily and learn things at your own pace with help from our remote community.

Git Commit Show by Invide 41 Dec 30, 2022
300+ Python Interview Questions

300+ Python Interview Questions

Pradeep Kumar 1.1k Jan 02, 2023
Sms Bomber, Tool Encryptor

ɴᴏʙɪᴛᴀシ︎ ғᴏʀ ᴀɴʏ ʜᴇʟᴘシ︎ Install pkg install git -y pkg install python -y pip install requests git clone https://github.com/AK27HVAU/akash Run cd Akash

ɴᴏʙɪᴛᴀシ︎ 4 May 23, 2022
Material for the ros2 crash course

Material for the ros2 crash course

Emmanuel Dean 1 Jan 22, 2022
Version bêta d'un système pour suivre les prix des livres chez Books to Scrape,

Version bêta d'un système pour suivre les prix des livres chez Books to Scrape, un revendeur de livres en ligne. En pratique, dans cette version bêta, le programme n'effectuera pas une véritable surv

Mouhamed Dia 1 Jan 06, 2022
Python Eacc is a minimalist but flexible Lexer/Parser tool in Python.

Python Eacc is a parsing tool it implements a flexible lexer and a straightforward approach to analyze documents.

Iury de oliveira gomes figueiredo 60 Nov 16, 2022
The tutorial is a collection of many other resources and my own notes

Why we need CTC? --- looking back on history 1.1. About CRNN 1.2. from Cross Entropy Loss to CTC Loss Details about CTC 2.1. intuition: forward algor

手写AI 7 Sep 19, 2022
Project created to help beginner programmers to study, despite the lack of internet!

Project created to help beginner programmers to study, despite the lack of internet!

Dev4Dev 2 Oct 25, 2021
An open-source script written in python just for fun

Owersite Owersite is an open-source script written in python just for fun. It do

大きなペニスを持つ少年 7 Sep 21, 2022
30 days of Python programming challenge is a step-by-step guide to learn the Python programming language in 30 days

30 days of Python programming challenge is a step-by-step guide to learn the Python programming language in 30 days. This challenge may take more than100 days, follow your own pace.

Asabeneh 17.7k Jan 07, 2023
The Python Dict that's better than heroin.

addict addict is a Python module that gives you dictionaries whose values are both gettable and settable using attributes, in addition to standard ite

Mats Julian Olsen 2.3k Dec 22, 2022
Markdown documentation generator from Google docstrings

mkgendocs A Python package for automatically generating documentation pages in markdown for Python source files by parsing Google style docstring. The

Davide Nunes 44 Dec 18, 2022
Sane and flexible OpenAPI 3 schema generation for Django REST framework.

drf-spectacular Sane and flexible OpenAPI 3.0 schema generation for Django REST framework. This project has 3 goals: Extract as much schema informatio

T. Franzel 1.4k Jan 08, 2023
Reproducible Data Science at Scale!

Pachyderm: The Data Foundation for Machine Learning Pachyderm provides the data layer that allows machine learning teams to productionize and scale th

Pachyderm 5.7k Dec 29, 2022
Paper and Code for "Curriculum Learning by Optimizing Learning Dynamics" (AISTATS 2021)

Curriculum Learning by Optimizing Learning Dynamics (DoCL) AISTATS 2021 paper: Title: Curriculum Learning by Optimizing Learning Dynamics [pdf] [appen

Tianyi Zhou 15 Dec 06, 2022
Course materials and handouts for #100DaysOfCode in Python course

#100DaysOfCode with Python course Course details page: talkpython.fm/100days Course Summary #100DaysOfCode in Python is your perfect companion to take

Talk Python 1.9k Dec 31, 2022
A comprehensive and FREE Online Python Development tutorial going step-by-step into the world of Python.

FREE Reverse Engineering Self-Study Course HERE Fundamental Python The book and code repo for the FREE Fundamental Python book by Kevin Thomas. FREE B

Kevin Thomas 7 Mar 19, 2022
Legacy python processor for AsciiDoc

AsciiDoc.py This branch is tracking the alpha, in-progress 10.x release. For the stable 9.x code, please go to the 9.x branch! AsciiDoc is a text docu

AsciiDoc.py 178 Dec 25, 2022
Ultimaker Cura 2 Mooraker Upload Plugin

Klipper & Cura - Cura2MoonrakerPlugin Allows you to upload Gcode directly from Cura to your Klipper-based 3D printer (Fluidd, Mainsailos etc.) using t

214 Jan 03, 2023
Pydocstringformatter - A tool to automatically format Python docstrings that tries to follow recommendations from PEP 8 and PEP 257.

Pydocstringformatter A tool to automatically format Python docstrings that tries to follow recommendations from PEP 8 and PEP 257. See What it does fo

Daniël van Noord 31 Dec 29, 2022