From 52671842d509dbc728c8640e1f61b1493459cc9f Mon Sep 17 00:00:00 2001
From: David Byrne <David-Byrne@users.noreply.github.com>
Date: Mon, 2 Oct 2017 07:10:01 +0100
Subject: [PATCH] Fixes broken source links in API docs (#9636)

* Fixes broken source links in API docs

* Removes illegal blank line
---
 docs/source/conf.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/docs/source/conf.py b/docs/source/conf.py
index bcb2699f57b..8ca22e1a126 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -117,7 +117,11 @@ def linkcode_resolve(domain, info):
         linespec = "#L%d" % (lineno + 1)
     else:
         linespec = ""
-    fn = relpath(fn, start='../')
+    index = fn.find("/homeassistant/")
+    if index == -1:
+        index = 0
+
+    fn = fn[index:]
 
     return '{}/blob/{}/{}{}'.format(GITHUB_URL, code_branch, fn, linespec)