wikipedia

Sphinx extension to create links to Wikipedia articles.

New in version 0.2.0.

Enable sphinx_toolbox.wikipedia by adding the following to the extensions variable in your conf.py:

extensions = [
    ...
    'sphinx_toolbox.wikipedia',
    ]

For more information see https://www.sphinx-doc.org/en/master/usage/extensions#third-party-extensions .

Configuration

wikipedia_lang
Type: str
Required: False
Default: 'en'

The Wikipedia language to use for wikipedia roles.

New in version 0.2.0.

Usage

:wikipedia:

Role which shows a link to the given article on Wikipedia.

The title and language can be customised.

Example

:wikipedia:`Sphinx`

:wikipedia:`mythical creature <Sphinx>`

:wikipedia:`Answer to the Ultimate Question of Life, the Universe, and Everything <:de:42 (Antwort)>`

Sphinx

mythical creature

Answer to the Ultimate Question of Life, the Universe, and Everything

:wikipedia:`:zh:斯芬克斯`

斯芬克斯

API Reference

Functions:

make_wikipedia_link(name, rawtext, text, …)

Adds a link to the given article on Wikipedia.

setup(app)

Setup sphinx_toolbox.wikipedia.

Adds a link to the given article on Wikipedia.

Parameters
  • name (str) – The local name of the interpreted role, the role name actually used in the document.

  • rawtext (str) – A string containing the entire interpreted text input, including the role and markup.

  • text (str) – The interpreted text content.

  • lineno (int) – The line number where the interpreted text begins.

  • inliner (Inliner) – The docutils.parsers.rst.states.Inliner object that called source_role(). It contains the several attributes useful for error reporting and document tree access.

  • options (Dict) – A dictionary of directive options for customization (from the role directive), to be interpreted by the function. Used for additional attributes for the generated elements and other functionality. Default {}.

  • content (List[str]) – A list of strings, the directive content for customization (from the role directive). To be interpreted by the function. Default [].

Return type

Tuple[List[reference], List[system_message]]

Returns

A list containing the created node, and a list containing any messages generated during the function.

setup(app)[source]

Setup sphinx_toolbox.wikipedia.

New in version 1.0.0.

Parameters

app (Sphinx) – The Sphinx application.

Return type

SphinxExtMetadata