summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2016-04-15 14:08:34 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2016-05-12 11:59:09 +0100
commitd199a270003c916a0f868afd89990e556d19bf9a (patch)
treed507d3d1a9c8f3a3962a7f16bcd0cca2012d9c11
parente9899fcf70c46aef29f026d2504f55567a70fb0f (diff)
downloadefl-d199a270003c916a0f868afd89990e556d19bf9a.tar.gz
docgen: move all path handling stuff to a single location
-rw-r--r--gendoc.lua30
1 files changed, 22 insertions, 8 deletions
diff --git a/gendoc.lua b/gendoc.lua
index bf93db40ce..e839234f81 100644
--- a/gendoc.lua
+++ b/gendoc.lua
@@ -9,17 +9,31 @@ local verbose = false
-- utils
+local path_sep = "/"
+
+local path_join = function(...)
+ return table.concat({ ... }, path_sep)
+end
+
+local path_to_nspace = function(p)
+ return p:gsub(path_sep, ":"):lower()
+end
+
+local nspace_to_path = function(ns)
+ return ns:gsub(":", path_sep):lower()
+end
+
local make_page = function(path)
- return doc_root .. "/" .. path .. ".txt"
+ return path_join(doc_root, path .. ".txt")
end
local mkdir_r = function(dirn)
- local fullp = dirn and (doc_root .. "/" .. dirn) or doc_root
+ local fullp = dirn and path_join(doc_root, dirn) or doc_root
local prev
- for x in fullp:gmatch("[^/]+") do
+ for x in fullp:gmatch("[^" .. path_sep .. "]+") do
local p
if prev then
- p = prev .. "/" .. x
+ p = path_join(prev, x)
else
p = x
end
@@ -33,7 +47,7 @@ local mkdir_r = function(dirn)
end
local mkdir_p = function(path)
- mkdir_r(path:match("(.+)/([^/]+)"))
+ mkdir_r(path:match("(.+)" .. path_sep .. "([^" .. path_sep .. "]+)"))
end
local str_split = function(str, delim)
@@ -477,9 +491,9 @@ local Writer = util.Object:clone {
__ctor = function(self, path)
local subs
if type(path) == "table" then
- subs = table.concat(path, "/")
+ subs = path_join(unpack(path))
else
- subs = path:gsub(":", "/"):lower()
+ subs = nspace_to_path(path)
end
mkdir_p(subs)
self.file = assert(io.open(make_page(subs), "w"))
@@ -1238,7 +1252,7 @@ getopt.parse {
if not opts["r"] then
error("no documentation root supplied")
end
- doc_root = opts["r"] .. "/" .. root_nspace:gsub(":", "/")
+ doc_root = path_join(opts["r"], nspace_to_path(root_nspace))
if not args[1] then
if not eolian.system_directory_scan() then
error("failed scanning system directory")