Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Support absolute snippet references

  • Loading branch information...
commit 02fbe0ef75394855cd4a80f62658dcc4bc83b64a 1 parent b4c8b06
@lunaryorn authored
Showing with 6 additions and 3 deletions.
  1. +1 −1  doc/python-misc.rst
  2. +5 −2 doc/snippets.py
View
2  doc/python-misc.rst
@@ -60,7 +60,7 @@ Available snippets
:synopsis: POSIX getch() implementation
POSIX-compatible implementation of :py:func:`msvcrt.getch()` with
- :py:mod:`termios`. See :snippet:`posix_getch.c` for a C implementation.
+ :py:mod:`termios`. See :snippet:`/posix_getch.c` for a C implementation.
.. snippet:: pruefercode.py
:synopsis: Prüfer code calculation
View
7 doc/snippets.py
@@ -60,6 +60,7 @@ def normalized_snippet_name(name, directory=None):
snippet = posixpath.join(directory, name)
else:
snippet = name
+ snippet = snippet.lstrip('/')
return posixpath.normpath(snippet)
@@ -166,14 +167,16 @@ def add_target_and_index(self, snippet, sig, signode):
class SnippetXRefRole(XRefRole):
def process_link(self, env, refnode, has_explicit_title, title, target):
- refnode['snip:directory'] = env.temp_data.get('snip:directory')
if not has_explicit_title:
target = target.lstrip('~')
if title.startswith('~'):
_, title = posixpath.split(title)
- return title, target
+ if not target.startswith('/'):
+ refnode['snip:directory'] = env.temp_data.get('snip:directory')
+
+ return title.lstrip('/'), target
class DirectoryXRefRole(XRefRole):
Please sign in to comment.
Something went wrong with that request. Please try again.