Skip to content

Instantly share code, notes, and snippets.

@shimizukawa
Created October 30, 2012 04:09
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 shimizukawa/3978232 to your computer and use it in GitHub Desktop.
Save shimizukawa/3978232 to your computer and use it in GitHub Desktop.
Sphinx: Link to outer non-sphinx document by using intersphinx. https://groups.google.com/d/topic/sphinx-users/P_FolrZVoNg/discussion
extensions = ['sphinx.ext.intersphinx']
intersphinx_mapping = {
'javaapi': ('http://api.example.com/', 'javaapi.inv'),
}
# -*- coding: utf-8 -*-
import zlib
inventory_header = u'''\
# Sphinx inventory version 2
# Project: javaapi
# Version: 2.0
# The remainder of this file is compressed with zlib.
'''.encode('utf-8')
inventory_payload = u'''\
api1 std:label -1 api.html#api1 API 1
'''.encode('utf-8')
# inventory_payload lines spec:
# name domainname:type priority uri dispname
#
# * `name` -- fully qualified name
# * `dispname` -- name to display when searching/linking
# * `type` -- object type, a key in ``self.object_types``
# * `docname` -- the document where it is to be found
# * `anchor` -- the anchor name for the object
# * `priority` -- how "important" the object is (determines placement in search results)
#
# - 1: default priority (placed before full-text matches)
# - 0: object is important (placed before default-priority objects)
# - 2: object is unimportant (placed after full-text matches)
# - -1: object should not show up in search at all
#
inventory = inventory_header + zlib.compress(inventory_payload)
open('javaapi.inv','wb').write(inventory)
<div class="section" id="example-link-to-outer-non-sphinx-by-using-intersphinx">
<h1>Example: Link to outer non-sphinx by using intersphinx<a class="headerlink" href="#example-link-to-outer-non-sphinx-by-using-intersphinx" title="Permalink to this headline">ツカ</a></h1>
<p><a class="reference external" href="http://api.example.com/api.html#api1" title="(in javaapi v2.0)"><em class="xref std std-ref">Java API 1</em></a></p>
</div>

Example: Link to outer non-sphinx by using intersphinx

Java API 1 <javaapi:api1>

Example: Link to outer non-sphinx by using intersphinx
==========================================================================
:ref:`Java API 1 <javaapi:api1>`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment