[gtk-doc] fixxref: extract one helper function



commit d8b9fb8e16df963cb5f03c19844e31014c3d4a28
Author: Stefan Sauer <ensonic users sf net>
Date:   Wed Apr 25 20:44:31 2018 +0200

    fixxref: extract one helper function
    
    This lets us test and reuse this separately. It is now written in
    return-early style to be a little faster in the good case.

 gtkdoc/fixxref.py |   35 +++++++++++++++++++++++++++--------
 1 files changed, 27 insertions(+), 8 deletions(-)
---
diff --git a/gtkdoc/fixxref.py b/gtkdoc/fixxref.py
index a5f3af2..05c94f2 100755
--- a/gtkdoc/fixxref.py
+++ b/gtkdoc/fixxref.py
@@ -278,20 +278,39 @@ def FixHTMLFile(src_lang, module, file):
     os.rename(new_file, file)
 
 
-def MakeXRef(module, file, line, id, text):
+def GetXRef(id):
     href = Links.get(id)
+    if href:
+        return (id, href)
 
     # This is a workaround for some inconsistency we have with CreateValidSGMLID
-    if not href and ':' in id:
-        href = Links.get(id.replace(':', '--'))
+    if ':' in id:
+        tid = id.replace(':', '--')
+        href = Links.get(tid)
+        if href:
+            return (tid, href)
+
     # poor mans plural support
-    if not href and id.endswith('s'):
+    if id.endswith('s'):
         tid = id[:-1]
         href = Links.get(tid)
-        if not href:
-            href = Links.get(tid + '-struct')
-    if not href:
-        href = Links.get(id + '-struct')
+        if href:
+            return (tid, href)
+        tid += '-struct'
+        href = Links.get(tid)
+        if href:
+            return (tid, href)
+
+    tid = id + '-struct'
+    href = Links.get(tid)
+    if href:
+        return (tid, href)
+
+    return (id, None)
+
+
+def MakeXRef(module, file, line, id, text):
+    href = GetXRef(id)[1]
 
     if href:
         # if it is a link to same module, remove path to make it work uninstalled


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]