Skip to content

Commit

Permalink
[enhance] opadoc: allow different naming schemes (both buggy), depend…
Browse files Browse the repository at this point in the history
…ing on an option
  • Loading branch information
François-Régis Sinot committed Sep 1, 2011
1 parent 4afcd49 commit 0c2802e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
9 changes: 9 additions & 0 deletions opadoc/common/opaDocParameters.opa
Expand Up @@ -43,6 +43,7 @@ type OpaDocParameters.t = {
help : bool
output_dir : option(string)
private : bool
long_uris : bool
}

/**
Expand All @@ -59,6 +60,7 @@ OpaDocParameters = {{
help = false
output_dir = {none}
private = false
long_uris = false
}

/**
Expand Down Expand Up @@ -101,6 +103,13 @@ OpaDocParameters = {{
state = { state with output_dir = {some = Text.to_string(path)}}
{no_params = state}
},
{ CommandLine.default_parser with
names = [ "--long-uris" ]
description = "Use long uris of the form stdlib.core.rpc.core.network.opa instead of network.opa"
on_encounter(state) =
state = { state with long_uris = true }
{no_params = state}
},
]
}

Expand Down
4 changes: 4 additions & 0 deletions opadoc/common/opaDocUtils.opa
Expand Up @@ -87,4 +87,8 @@ OpaDocUtils = {{
String.ordering(String.to_lower(p1), String.to_lower(p2))
List.sort_with(aux, list)

uri_of_path =
if OpaDocParameters.get().long_uris
then String.replace(File.dir_sep, ".", _)
else File.basename
}}
6 changes: 1 addition & 5 deletions opadoc/generator/opaApiFile.opa
Expand Up @@ -31,10 +31,6 @@ OpaApiFile = {{
l = List.map(Xhtml.of_string, l)
<>{ List.intersperse(<br />, l) }</>

/* not really the basename ... */
@private basename(s) =
String.replace(File.dir_sep, ".", s)

/**
* Build the association from types to values hyperlink, and entries by path_name
**/
Expand All @@ -43,7 +39,7 @@ OpaApiFile = {{
if OpaDocUtils.is_private(entry) then tuple_acc else
path_name = String.concat(".", entry.path)
path_html = OpaDocUtils.sanitize_path("{entry.pkg}.{path_name}")
entry_html = (path_name, (entry, path_html, basename(entry.fname))) : Entry.html
entry_html = (path_name, (entry, path_html, OpaDocUtils.uri_of_path(entry.fname))) : Entry.html
type_table =
match entry.code_elt with
| { value = { ty = opatype ; ... } } ->
Expand Down
3 changes: 1 addition & 2 deletions opadoc/generator/opaDocJoin.opa
Expand Up @@ -92,10 +92,9 @@ OpaDocJoin = {{
* of mixed elements indexed by the original filenames.
**/
file_separation(all_join : list(Join.mix)) =
basename(s) = String.replace(File.dir_sep, ".", s)
// list ==> stringmap of list, indexed by filename
upd(mix, map) =
f = basename(get_file(mix))
f = OpaDocUtils.uri_of_path(get_file(mix))
new_list = List.cons(mix, StringMap.get(f, map) ? [])
StringMap.add(f, new_list, map)
List.foldl(upd, all_join, StringMap.empty)
Expand Down
2 changes: 1 addition & 1 deletion opadoc/generator/opaDocTree.opa
Expand Up @@ -281,7 +281,7 @@ OpaDocTree = {{
of_files(files) =
aux(acc, path) =
key = {file = path}
path_dot = String.replace(File.dir_sep, ".", path)
path_dot = OpaDocUtils.uri_of_path(path)
node = {
tree = none
id = "node_file_{path_dot}"
Expand Down

0 comments on commit 0c2802e

Please sign in to comment.