Ported luadoc to use luaposix instead of lfs
This commit is contained in:
parent
ce5f619c4f
commit
dba6854d65
4 changed files with 17 additions and 17 deletions
|
@ -41,7 +41,7 @@ function start (doc)
|
|||
luadoc.logger:info(string.format("generating file `%s'", filename))
|
||||
|
||||
-- TODO: confirm file overwrite
|
||||
local f = lfs.open(filename, "w")
|
||||
local f = posix.open(filename, "w")
|
||||
assert(f, string.format("could not open `%s' for writing", filename))
|
||||
|
||||
for _, block in ipairs(file_doc.doc) do
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
local assert, getfenv, ipairs, loadstring, pairs, setfenv, tostring, tonumber, type = assert, getfenv, ipairs, loadstring, pairs, setfenv, tostring, tonumber, type
|
||||
local io = require"io"
|
||||
local lfs = require "lfs"
|
||||
local posix = require "posix"
|
||||
local lp = require "luadoc.lp"
|
||||
local luadoc = require"luadoc"
|
||||
local package = package
|
||||
|
@ -220,7 +220,7 @@ function start (doc)
|
|||
if (#doc.files > 0 or #doc.modules > 0) and (not options.noindexpage) then
|
||||
local filename = options.output_dir.."index.html"
|
||||
logger:info(string.format("generating file `%s'", filename))
|
||||
local f = lfs.open(filename, "w")
|
||||
local f = posix.open(filename, "w")
|
||||
assert(f, string.format("could not open `%s' for writing", filename))
|
||||
io.output(f)
|
||||
include("index.lp", { doc = doc })
|
||||
|
@ -235,7 +235,7 @@ function start (doc)
|
|||
local filename = out_module(modulename)
|
||||
logger:info(string.format("generating file `%s'", filename))
|
||||
|
||||
local f = lfs.open(filename, "w")
|
||||
local f = posix.open(filename, "w")
|
||||
assert(f, string.format("could not open `%s' for writing", filename))
|
||||
io.output(f)
|
||||
include("module.lp", { doc = doc, module_doc = module_doc })
|
||||
|
@ -251,7 +251,7 @@ function start (doc)
|
|||
local filename = out_file(file_doc.name)
|
||||
logger:info(string.format("generating file `%s'", filename))
|
||||
|
||||
local f = lfs.open(filename, "w")
|
||||
local f = posix.open(filename, "w")
|
||||
assert(f, string.format("could not open `%s' for writing", filename))
|
||||
io.output(f)
|
||||
include("file.lp", { doc = doc, file_doc = file_doc} )
|
||||
|
@ -260,7 +260,7 @@ function start (doc)
|
|||
end
|
||||
|
||||
-- copy extra files
|
||||
local f = lfs.open(options.output_dir.."luadoc.css", "w")
|
||||
local f = posix.open(options.output_dir.."luadoc.css", "w")
|
||||
io.output(f)
|
||||
include("luadoc.css")
|
||||
f:close()
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
local assert, pairs, tostring, type = assert, pairs, tostring, type
|
||||
local io = require "io"
|
||||
local lfs = require "lfs"
|
||||
local posix = require "posix"
|
||||
local luadoc = require "luadoc"
|
||||
local util = require "luadoc.util"
|
||||
local tags = require "luadoc.taglet.standard.tags"
|
||||
|
@ -433,14 +433,14 @@ end
|
|||
-- @return table with documentation
|
||||
|
||||
function directory (path, doc)
|
||||
for f in lfs.dir(path) do
|
||||
for f in posix.files(path) do
|
||||
local fullpath = path .. "/" .. f
|
||||
local attr = lfs.attributes(fullpath)
|
||||
local attr = posix.stat(fullpath)
|
||||
assert(attr, string.format("error stating file `%s'", fullpath))
|
||||
|
||||
if attr.mode == "file" then
|
||||
if attr.type == "regular" then
|
||||
doc = file(fullpath, doc)
|
||||
elseif attr.mode == "directory" and f ~= "." and f ~= ".." then
|
||||
elseif attr.type == "directory" and f ~= "." and f ~= ".." then
|
||||
doc = directory(fullpath, doc)
|
||||
end
|
||||
end
|
||||
|
@ -475,12 +475,12 @@ function start (files, doc)
|
|||
assert(doc.modules, "undefined `modules' field")
|
||||
|
||||
table.foreachi(files, function (_, path)
|
||||
local attr = lfs.attributes(path)
|
||||
local attr = posix.stat(path)
|
||||
assert(attr, string.format("error stating path `%s'", path))
|
||||
|
||||
if attr.mode == "file" then
|
||||
if attr.type == "regular" then
|
||||
doc = file(path, doc)
|
||||
elseif attr.mode == "directory" then
|
||||
elseif attr.type == "directory" then
|
||||
doc = directory(path, doc)
|
||||
end
|
||||
end)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
-- @release $Id: util.lua,v 1.16 2008/02/17 06:42:51 jasonsantos Exp $
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
local lfs = require "lfs"
|
||||
local posix = require "posix"
|
||||
local type, table, string, io, assert, tostring, setmetatable, pcall = type, table, string, io, assert, tostring, setmetatable, pcall
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
@ -144,14 +144,14 @@ end
|
|||
-- @param mode mode of opening
|
||||
-- @return file handle
|
||||
|
||||
function lfs.open (filename, mode)
|
||||
function posix.open (filename, mode)
|
||||
local f = io.open(filename, mode)
|
||||
if f == nil then
|
||||
filename = string.gsub(filename, "\\", "/")
|
||||
local dir = ""
|
||||
for d in string.gfind(filename, ".-/") do
|
||||
dir = dir .. d
|
||||
lfs.mkdir(dir)
|
||||
posix.mkdir(dir)
|
||||
end
|
||||
f = io.open(filename, mode)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue