summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrant Knudson <bknudson@us.ibm.com>2016-02-01 14:39:14 -0600
committerBrant Knudson <bknudson@us.ibm.com>2016-02-02 08:56:12 -0600
commit7de972255141e462e68ac7a04e25ce2b13bc911a (patch)
tree7494d77dfd4c66ab56e9b39af4c4871d61ce526d
parent6903e98bfbf1e5e5386c256ec5ee6a53ce6e9ec6 (diff)
downloadoslosphinx-7de972255141e462e68ac7a04e25ce2b13bc911a.tar.gz
Correct project source guessing for OpenStack
The links to the project source in all the developer docs are incorrect. The link for keystone is like http://git.openstack.org/cgit/p/openstack/keystone when it should be http://git.openstack.org/cgit/openstack/keystone See the link to "Project Source" on the left on http://docs.openstack.org/developer/keystone/ for example. Also, developers sometimes use a ".git" URL when they clone so strip off the .git. Change-Id: I8e7620119a169e3322d602ea633303cf9f941605
-rw-r--r--oslosphinx/__init__.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/oslosphinx/__init__.py b/oslosphinx/__init__.py
index 2dd655d..77f962f 100644
--- a/oslosphinx/__init__.py
+++ b/oslosphinx/__init__.py
@@ -13,6 +13,7 @@
# under the License.
import os
+import re
import six
from six.moves.urllib import parse
import subprocess
@@ -33,7 +34,9 @@ def _guess_cgit_link():
if six.PY3:
git_remote = os.fsdecode(git_remote)
parsed = parse.urlparse(git_remote)
- return CGIT_BASE + parsed.path.lstrip('/')
+ parsed = '/'.join(parsed.path.rstrip('/').split('/')[-2:])
+ parsed = re.sub(r'\.git$', '', parsed)
+ return CGIT_BASE + parsed
def _html_page_context(app, pagename, templatename, context, doctree):