Skip to content

Instantly share code, notes, and snippets.

@adiroiban
Created February 9, 2014 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adiroiban/8897350 to your computer and use it in GitHub Desktop.
Save adiroiban/8897350 to your computer and use it in GitHub Desktop.
diff --git a/docs/_extensions/apilinks.py b/docs/_extensions/apilinks.py
index 656d350..7b939fb 100644
--- a/docs/_extensions/apilinks.py
+++ b/docs/_extensions/apilinks.py
@@ -23,15 +23,21 @@ def make_api_link(name, rawtext, text, lineno, inliner,
full_name = full_name.strip()
label = label.strip('>').strip()
else:
- full_name = label = text
+ full_name = text
+
+ anchor = ''
+ if '#' in full_name:
+ full_name, anchor = full_name.split('#', 1)
+ # Add back the hash.
+ anchor = '#' + anchor
#get the base url for api links from the config file
env = inliner.document.settings.env
- base_url = env.config.apilinks_base_url
+ base_url = env.config.apilinks_base_url
# not really sufficient, but just testing...
# ...hmmm, maybe this is good enough after all
- ref = ''.join((base_url, full_name, '.html'))
+ ref = ''.join((base_url, full_name, '.html', anchor))
node = nodes.reference(rawtext, utils.unescape(label), refuri=ref,
**options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment