##// END OF EJS Templates
Fix broken links on install/index.rst...
Fix broken links on install/index.rst Currently the links in the section summary on the index.rst/index.html file are broken. Can be reproduced by going to http://ipython.readthedocs.io/en/stable/install/index.html and clicking on *installing IPython itself*, or *kernels for Jupyter* links. Specific changes ---------------- * Added a reference label to the `install.rst` file * Modified links from external link format to Sphinx arbitrary location cross-referencing format in the `index.rst` file Testing ------- Changes have been tested with a local sphinx build through the supplied makefile and specific links touched are fixed. Tested a few possibly overlapping links (Jupyter:install for instance) and they seem to be unaffected by the change.

File last commit:

r21874:3ffdf6f9
r22679:367c6fe3
Show More
magics.py
45 lines | 1.4 KiB | text/x-python | PythonLexer
Thomas Kluyver
Add Sphinx extension to document line & cell magics
r18184 import re
from sphinx import addnodes
Thomas Kluyver
Various improvements to docs infrastructure for magics
r18296 from sphinx.domains.std import StandardDomain
from sphinx.roles import XRefRole
Thomas Kluyver
Add Sphinx extension to document line & cell magics
r18184
Thomas Kluyver
Various improvements to docs infrastructure for magics
r18296 name_re = re.compile(r"[\w_]+")
Thomas Kluyver
Add Sphinx extension to document line & cell magics
r18184
def parse_magic(env, sig, signode):
Thomas Kluyver
Various improvements to docs infrastructure for magics
r18296 m = name_re.match(sig)
Thomas Kluyver
Add Sphinx extension to document line & cell magics
r18184 if not m:
raise Exception("Invalid magic command: %s" % sig)
Thomas Kluyver
Various improvements to docs infrastructure for magics
r18296 name = "%" + sig
signode += addnodes.desc_name(name, name)
return m.group(0)
class LineMagicRole(XRefRole):
"""Cross reference role displayed with a % prefix"""
prefix = "%"
def process_link(self, env, refnode, has_explicit_title, title, target):
if not has_explicit_title:
title = self.prefix + title.lstrip("%")
target = target.lstrip("%")
return title, target
Thomas Kluyver
Add Sphinx extension to document line & cell magics
r18184
def parse_cell_magic(env, sig, signode):
Thomas Kluyver
Various improvements to docs infrastructure for magics
r18296 m = name_re.match(sig)
Thomas Kluyver
Add Sphinx extension to document line & cell magics
r18184 if not m:
raise ValueError("Invalid cell magic: %s" % sig)
Thomas Kluyver
Various improvements to docs infrastructure for magics
r18296 name = "%%" + sig
signode += addnodes.desc_name(name, name)
return m.group(0)
Thomas Kluyver
Add Sphinx extension to document line & cell magics
r18184
Thomas Kluyver
Various improvements to docs infrastructure for magics
r18296 class CellMagicRole(LineMagicRole):
"""Cross reference role displayed with a %% prefix"""
prefix = "%%"
Thomas Kluyver
Add Sphinx extension to document line & cell magics
r18184
Thomas Kluyver
Various improvements to docs infrastructure for magics
r18296 def setup(app):
Thomas Kluyver
Generate documentation of line & cell magics
r18294 app.add_object_type('magic', 'magic', 'pair: %s; magic command', parse_magic)
Thomas Kluyver
Various improvements to docs infrastructure for magics
r18296 StandardDomain.roles['magic'] = LineMagicRole()
Thomas Kluyver
Generate documentation of line & cell magics
r18294 app.add_object_type('cellmagic', 'cellmagic', 'pair: %s; cell magic', parse_cell_magic)
Thomas Kluyver
Various improvements to docs infrastructure for magics
r18296 StandardDomain.roles['cellmagic'] = CellMagicRole()
Michael Droettboom
Support parallel sphinx building
r21874
metadata = {'parallel_read_safe': True, 'parallel_write_safe': True}
return metadata