mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
This is an important refactor of the way documentation generation works
* Installs luarocks WITH it's executable (easy to install other rocks if necessary) * Use Lua supplied with luarocks * Create Utils/luadocumentor.bat, which works with RELATIVE PATH ! -> Everybody can generate the doc * Updated launch files accordingly
This commit is contained in:
74
Utils/luarocks/lua/luarocks/dir.lua
Normal file
74
Utils/luarocks/lua/luarocks/dir.lua
Normal file
@@ -0,0 +1,74 @@
|
||||
|
||||
--- Generic utilities for handling pathnames.
|
||||
local dir = {}
|
||||
package.loaded["luarocks.dir"] = dir
|
||||
|
||||
dir.separator = "/"
|
||||
|
||||
--- Strip the path off a path+filename.
|
||||
-- @param pathname string: A path+name, such as "/a/b/c"
|
||||
-- or "\a\b\c".
|
||||
-- @return string: The filename without its path, such as "c".
|
||||
function dir.base_name(pathname)
|
||||
assert(type(pathname) == "string")
|
||||
|
||||
local base = pathname:gsub("[/\\]*$", ""):match(".*[/\\]([^/\\]*)")
|
||||
return base or pathname
|
||||
end
|
||||
|
||||
--- Strip the name off a path+filename.
|
||||
-- @param pathname string: A path+name, such as "/a/b/c".
|
||||
-- @return string: The filename without its path, such as "/a/b".
|
||||
-- For entries such as "/a/b/", "/a" is returned. If there are
|
||||
-- no directory separators in input, "" is returned.
|
||||
function dir.dir_name(pathname)
|
||||
assert(type(pathname) == "string")
|
||||
return (pathname:gsub("/*$", ""):match("(.*)[/]+[^/]*")) or ""
|
||||
end
|
||||
|
||||
--- Describe a path in a cross-platform way.
|
||||
-- Use this function to avoid platform-specific directory
|
||||
-- separators in other modules. Removes trailing slashes from
|
||||
-- each component given, to avoid repeated separators.
|
||||
-- Separators inside strings are kept, to handle URLs containing
|
||||
-- protocols.
|
||||
-- @param ... strings representing directories
|
||||
-- @return string: a string with a platform-specific representation
|
||||
-- of the path.
|
||||
function dir.path(...)
|
||||
local t = {...}
|
||||
while t[1] == "" do
|
||||
table.remove(t, 1)
|
||||
end
|
||||
return (table.concat(t, "/"):gsub("([^:])/+", "%1/"):gsub("^/+", "/"):gsub("/*$", ""))
|
||||
end
|
||||
|
||||
--- Split protocol and path from an URL or local pathname.
|
||||
-- URLs should be in the "protocol://path" format.
|
||||
-- For local pathnames, "file" is returned as the protocol.
|
||||
-- @param url string: an URL or a local pathname.
|
||||
-- @return string, string: the protocol, and the pathname without the protocol.
|
||||
function dir.split_url(url)
|
||||
assert(type(url) == "string")
|
||||
|
||||
local protocol, pathname = url:match("^([^:]*)://(.*)")
|
||||
if not protocol then
|
||||
protocol = "file"
|
||||
pathname = url
|
||||
end
|
||||
return protocol, pathname
|
||||
end
|
||||
|
||||
--- Normalize a url or local path.
|
||||
-- URLs should be in the "protocol://path" format. System independent
|
||||
-- forward slashes are used, removing trailing and double slashes
|
||||
-- @param url string: an URL or a local pathname.
|
||||
-- @return string: Normalized result.
|
||||
function dir.normalize(name)
|
||||
local protocol, pathname = dir.split_url(name)
|
||||
pathname = pathname:gsub("\\", "/"):gsub("(.)/*$", "%1"):gsub("//", "/")
|
||||
if protocol ~= "file" then pathname = protocol .."://"..pathname end
|
||||
return pathname
|
||||
end
|
||||
|
||||
return dir
|
||||
Reference in New Issue
Block a user