docgen: support windows path sep and sanitize on all platforms

This commit is contained in:
Daniel Kolesa 2016-04-19 21:09:10 +01:00
parent 16b8d21692
commit 6723b8d071
1 changed files with 8 additions and 4 deletions

View File

@ -2,6 +2,7 @@ local eolian = require("eolian")
local getopt = require("getopt")
local cutil = require("cutil")
local util = require("util")
local ffi = require("ffi")
local doc_root
local root_nspace
@ -9,18 +10,21 @@ local verbose = false
-- utils
local path_sep = "/"
local path_sep, rep_sep = "/", "\\"
if ffi.os == "Windows" then
path_sep, rep_sep = rep_sep, path_sep
end
local path_join = function(...)
return table.concat({ ... }, path_sep)
return table.concat({ ... }, path_sep):gsub(rep_sep, path_sep)
end
local path_to_nspace = function(p)
return p:gsub(path_sep, ":"):lower()
return p:gsub(rep_sep, ":"):gsub(path_sep, ":"):lower()
end
local nspace_to_path = function(ns)
return ns:gsub(":", path_sep):lower()
return ns:gsub(":", path_sep):gsub(rep_sep, path_sep):lower()
end
local make_page = function(path)