aboutsummaryrefslogtreecommitdiff
path: root/ide/ideutils.ml
diff options
context:
space:
mode:
authorherbelin2009-08-14 14:02:23 +0000
committerherbelin2009-08-14 14:02:23 +0000
commit6af2902ddd8ea6d4171b882726e9bb4d2fc45748 (patch)
tree049d8e8c360f11bcd9ac9bc4a60f2c10f6e39adf /ide/ideutils.ml
parent79a25a71dd3519d8e7a6bd9f3a004c7c0da3a1b5 (diff)
Tried to make F1 documentation tool working in CoqIDE.
In trunk: New strategy for compiling and finding index_url.txt. After all, this file is not specific to CoqIDE but to the documentation. Hence, it seems better to install it close to the documentation. If the documentation is locally installed, it is easy to find the file index_url.txt but what to do if the documentation is remote? We would need a http getter. Does this mean we have to rely on wget or so? In the absence of answer to this question, it seems reasonable, first to assume the doc to be locally installed, second to have a local copy of index_url.txt ready in the installation directory of CoqIDE. Also added an "automatic" field in the CoqIDE url preference to prevent the user to have to update his preference file every time a new version of Coq is out and the link to the doc change. In 8.2: Added a minima the installation of index_urls.txt but the user will have to update its preferences because the links "http://coq.inria.fr/doc/Reference-Manual010.html#..." do not longer exist. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@12278 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'ide/ideutils.ml')
-rw-r--r--ide/ideutils.ml35
1 files changed, 29 insertions, 6 deletions
diff --git a/ide/ideutils.ml b/ide/ideutils.ml
index dec23e36d9..ebf789fb37 100644
--- a/ide/ideutils.ml
+++ b/ide/ideutils.ml
@@ -312,10 +312,31 @@ let browse f url =
f ("Could not execute\n\""^com^
"\"\ncheck your preferences for setting a valid browser command\n")
+let doc_url () =
+ if !current.doc_url = use_default_doc_url || !current.doc_url = "" then
+ if Sys.file_exists
+ (String.sub Coq_config.localwwwrefman 7
+ (String.length Coq_config.localwwwrefman - 7))
+ then
+ Coq_config.localwwwrefman
+ else
+ Coq_config.wwwrefman
+ else !current.doc_url
+
let url_for_keyword =
let ht = Hashtbl.create 97 in
+ lazy (
begin try
- let cin = open_in (lib_ide_file "index_urls.txt") in
+ let cin =
+ try open_in (lib_ide_file "index_urls.txt")
+ with _ ->
+ let doc_url = doc_url () in
+ let n = String.length doc_url in
+ if n > 8 && String.sub doc_url 0 7 = "file://" then
+ open_in (String.sub doc_url 7 (n-7) ^ "index_urls.txt")
+ else
+ raise Exit
+ in
try while true do
let s = input_line cin in
try
@@ -324,18 +345,20 @@ let url_for_keyword =
let u = String.sub s (i + 1) (String.length s - i - 1) in
Hashtbl.add ht k u
with _ ->
- ()
+ Printf.eprintf "Warning: Cannot parse documentation index file.\n";
+ flush stderr
done with End_of_file ->
close_in cin
with _ ->
- ()
+ Printf.eprintf "Warning: Cannot find documentation index file.\n";
+ flush stderr
end;
- (Hashtbl.find ht : string -> string)
+ Hashtbl.find ht : string -> string)
let browse_keyword f text =
- try let u = url_for_keyword text in browse f (!current.doc_url ^ u)
- with Not_found -> f ("No documentation found for "^text)
+ try let u = Lazy.force url_for_keyword text in browse f (doc_url() ^ u)
+ with Not_found -> f ("No documentation found for \""^text^"\".\n")
(*