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-performance - CLI tool to measure the build time of different, free configurable Sphinx-Projects

CLI tool to measure the build time of different, free configurable Sphinx-Projec

useblocks 11 Nov 25, 2022
Main repository for the Sphinx documentation builder

Sphinx Sphinx is a tool that makes it easy to create intelligent and beautiful documentation for Python projects (or other documents consisting of mul

null 5.1k Jan 2, 2023
A curated list of awesome tools for Sphinx Python Documentation Generator

Awesome Sphinx (Python Documentation Generator) A curated list of awesome extra libraries, software and resources for Sphinx (Python Documentation Gen

Hyunjun Kim 831 Dec 27, 2022
Main repository for the Sphinx documentation builder

Sphinx Sphinx is a tool that makes it easy to create intelligent and beautiful documentation for Python projects (or other documents consisting of mul

null 5.1k Jan 4, 2023
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
Numpy's Sphinx extensions

numpydoc -- Numpy's Sphinx extensions This package provides the numpydoc Sphinx extension for handling docstrings formatted according to the NumPy doc

NumPy 234 Dec 26, 2022
ReStructuredText and Sphinx bridge to Doxygen

Breathe Packagers: PGP signing key changes for Breathe >= v4.23.0. https://github.com/michaeljones/breathe/issues/591 This is an extension to reStruct

Michael Jones 643 Dec 31, 2022
Type hints support for the Sphinx autodoc extension

sphinx-autodoc-typehints This extension allows you to use Python 3 annotations for documenting acceptable argument types and return value types of fun

Alex Grönholm 462 Dec 29, 2022
Watch a Sphinx directory and rebuild the documentation when a change is detected. Also includes a livereload enabled web server.

sphinx-autobuild Rebuild Sphinx documentation on changes, with live-reload in the browser. Installation sphinx-autobuild is available on PyPI. It can

Executable Books 440 Jan 6, 2023
sphinx builder that outputs markdown files.

sphinx-markdown-builder sphinx builder that outputs markdown files Please ★ this repo if you found it useful ★ ★ ★ If you want frontmatter support ple

Clay Risser 144 Jan 6, 2023
Sphinx Bootstrap Theme

Sphinx Bootstrap Theme This Sphinx theme integrates the Bootstrap CSS / JavaScript framework with various layout options, hierarchical menu navigation

Ryan Roemer 584 Nov 16, 2022
A powerful Sphinx changelog-generating extension.

What is Releases? Releases is a Python (2.7, 3.4+) compatible Sphinx (1.8+) extension designed to help you keep a source control friendly, merge frien

Jeff Forcier 166 Dec 29, 2022
📖 Generate markdown API documentation from Google-style Python docstring. The lazy alternative to Sphinx.

lazydocs Generate markdown API documentation for Google-style Python docstring. Getting Started • Features • Documentation • Support • Contribution •

Machine Learning Tooling 118 Dec 31, 2022
Seamlessly integrate pydantic models in your Sphinx documentation.

Seamlessly integrate pydantic models in your Sphinx documentation.

Franz Wöllert 71 Dec 26, 2022
Speed up Sphinx builds by selectively removing toctrees from some pages

Remove toctrees from Sphinx pages Improve your Sphinx build time by selectively removing TocTree objects from pages. This is useful if your documentat

Executable Books 8 Jan 4, 2023
python package sphinx template

python-package-sphinx-template python-package-sphinx-template

Soumil Nitin Shah 2 Dec 26, 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
This is a template (starter kit) for writing Maturity Work with Sphinx / LaTeX at Collège du Sud

sphinx-tm-template Ce dépôt est un template de base utilisable pour écrire ton travail de maturité dans le séminaire d'informatique du Collège du Sud.

null 6 Dec 22, 2022
In this Github repository I will share my freqtrade files with you. I want to help people with this repository who don't know Freqtrade so much yet.

My Freqtrade stuff In this Github repository I will share my freqtrade files with you. I want to help people with this repository who don't know Freqt

Simon Kebekus 104 Dec 31, 2022