mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-22 09:50:37 +00:00
Add sphinx extension that replaces absolut RTD urls
This makes it possible to add proper links when showing an rst on github, while also resolving it to relative links on readthedocs
This commit is contained in:
parent
62b87f22d5
commit
6980dd6517
3 changed files with 22 additions and 2 deletions
|
@ -7,8 +7,8 @@ bootstrap-vz runs without any user intervention and
|
|||
generates ready-to-boot images for a number of virtualization
|
||||
platforms.
|
||||
Its aim is to provide a reproducable bootstrapping process using
|
||||
`manifests <http://andsens.github.io/bootstrap-vz/manifest.html>`__ as
|
||||
well as supporting a high degree of customizability through plugins.
|
||||
`manifests <http://bootstrap-vz.readthedocs.org/en/master/manifest.html>`__
|
||||
as well as supporting a high degree of customizability through plugins.
|
||||
|
||||
bootstrap-vz was coded from scratch in python once the bash script
|
||||
architecture that was used in the
|
||||
|
|
|
@ -31,6 +31,7 @@ sys.path.insert(0, os.path.abspath(os.pardir))
|
|||
extensions = ['sphinx.ext.coverage',
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx.ext.linkcode',
|
||||
'docs.replace_rtd_links',
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
|
|
19
docs/replace_rtd_links.py
Normal file
19
docs/replace_rtd_links.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
|
||||
def setup(app):
|
||||
app.connect('doctree-resolved', replace_rtd_links)
|
||||
|
||||
return {'version': '0.1'}
|
||||
|
||||
|
||||
def replace_rtd_links(app, doctree, fromdocname):
|
||||
from docutils import nodes
|
||||
import re
|
||||
|
||||
rtd_baseurl = 'http://bootstrap-vz.readthedocs.org/en/master/'
|
||||
search = re.compile('^' + re.escape(rtd_baseurl) + '(.*)$')
|
||||
for node in doctree.traverse(nodes.reference):
|
||||
if 'refuri' not in node:
|
||||
continue
|
||||
if not node['refuri'].startswith(rtd_baseurl):
|
||||
continue
|
||||
node['refuri'] = re.sub(search, r'\1', node['refuri'])
|
Loading…
Add table
Reference in a new issue