summaryrefslogtreecommitdiffstats
path: root/ocamldoc/odoc_name.ml
diff options
context:
space:
mode:
Diffstat (limited to 'ocamldoc/odoc_name.ml')
-rw-r--r--ocamldoc/odoc_name.ml40
1 files changed, 36 insertions, 4 deletions
diff --git a/ocamldoc/odoc_name.ml b/ocamldoc/odoc_name.ml
index 9ad618187..e518d57cf 100644
--- a/ocamldoc/odoc_name.ml
+++ b/ocamldoc/odoc_name.ml
@@ -79,10 +79,28 @@ let father name = fst (cut name)
let concat n1 n2 = n1^"."^n2
-let head n =
- match Str.split (Str.regexp "\\.") n with
- [] -> n
- | h :: _ -> h
+let head_and_tail n =
+ try
+ let pos = String.index n '.' in
+ if pos > 0 then
+ let h = String.sub n 0 pos in
+ try
+ ignore (String.index h '(');
+ (n, "")
+ with
+ Not_found ->
+ let len = String.length n in
+ if pos >= (len - 1) then
+ (h, "")
+ else
+ (h, String.sub n (pos + 1) (len - pos - 1))
+ else
+ (n, "")
+ with
+ Not_found -> (n, "")
+
+let head n = fst (head_and_tail n)
+let tail n = snd (head_and_tail n)
let depth name =
try
@@ -98,6 +116,20 @@ let prefix n1 n2 =
(n2.[len1] = '.')
with _ -> false)
+let rec get_relative_raw n1 n2 =
+ let (f1,s1) = head_and_tail n1 in
+ let (f2,s2) = head_and_tail n2 in
+ if f1 = f2 then
+ if f2 = s2 or s2 = "" then
+ s2
+ else
+ if f1 = s1 or s1 = "" then
+ s2
+ else
+ get_relative_raw s1 s2
+ else
+ n2
+
let get_relative n1 n2 =
if prefix n1 n2 then
let len1 = String.length n1 in