Skip to content
This repository was archived by the owner on Apr 18, 2018. It is now read-only.

Commit e720e29

Browse files
authored
Merge pull request #6 from jahn/link-roles
add roles for linking to files and code search
2 parents 2190d3d + c7e7169 commit e720e29

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

doc/_extensions/mitgcm.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from docutils import nodes
2+
3+
def setup(app):
4+
app.add_role('filelink', autolink('https://github.com/altMITgcm/MITgcm/blob/master/%s'))
5+
app.add_role('varlink', autolink('http://mitgcm.org/lxr/ident/MITgcm?_i=%s'))
6+
7+
def autolink(pattern):
8+
def role(name, rawtext, text, lineno, inliner, options={}, content=[]):
9+
url = pattern % (text,)
10+
node = nodes.reference(rawtext, text, refuri=url, **options)
11+
return [node], []
12+
return role

doc/conf.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
# add these directories to sys.path here. If the directory is relative to the
1717
# documentation root, use os.path.abspath to make it absolute, like shown here.
1818
#
19-
# import os
20-
# import sys
21-
# sys.path.insert(0, os.path.abspath('.'))
19+
import os
20+
import sys
21+
sys.path.insert(0, os.path.join(os.path.abspath('.'), '_extensions'))
2222

2323

2424
# -- General configuration ------------------------------------------------
@@ -33,7 +33,8 @@
3333
extensions = ['sphinx.ext.autodoc',
3434
'sphinx.ext.mathjax',
3535
'sphinx.ext.viewcode',
36-
'sphinxcontrib.bibtex']
36+
'sphinxcontrib.bibtex',
37+
'mitgcm']
3738

3839
# Add any paths that contain templates here, relative to this directory.
3940
templates_path = ['_templates']

0 commit comments

Comments
 (0)