Ported luadoc to use luaposix instead of lfs

This commit is contained in:
Steven Barth 2008-07-23 14:04:26 +00:00
parent ce5f619c4f
commit dba6854d65
4 changed files with 17 additions and 17 deletions

View file

@ -41,7 +41,7 @@ function start (doc)
luadoc.logger:info(string.format("generating file `%s'", filename)) luadoc.logger:info(string.format("generating file `%s'", filename))
-- TODO: confirm file overwrite -- 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)) assert(f, string.format("could not open `%s' for writing", filename))
for _, block in ipairs(file_doc.doc) do for _, block in ipairs(file_doc.doc) do

View file

@ -14,7 +14,7 @@
local assert, getfenv, ipairs, loadstring, pairs, setfenv, tostring, tonumber, type = assert, getfenv, ipairs, loadstring, pairs, setfenv, tostring, tonumber, type local assert, getfenv, ipairs, loadstring, pairs, setfenv, tostring, tonumber, type = assert, getfenv, ipairs, loadstring, pairs, setfenv, tostring, tonumber, type
local io = require"io" local io = require"io"
local lfs = require "lfs" local posix = require "posix"
local lp = require "luadoc.lp" local lp = require "luadoc.lp"
local luadoc = require"luadoc" local luadoc = require"luadoc"
local package = package local package = package
@ -220,7 +220,7 @@ function start (doc)
if (#doc.files > 0 or #doc.modules > 0) and (not options.noindexpage) then if (#doc.files > 0 or #doc.modules > 0) and (not options.noindexpage) then
local filename = options.output_dir.."index.html" local filename = options.output_dir.."index.html"
logger:info(string.format("generating file `%s'", filename)) 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)) assert(f, string.format("could not open `%s' for writing", filename))
io.output(f) io.output(f)
include("index.lp", { doc = doc }) include("index.lp", { doc = doc })
@ -235,7 +235,7 @@ function start (doc)
local filename = out_module(modulename) local filename = out_module(modulename)
logger:info(string.format("generating file `%s'", filename)) 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)) assert(f, string.format("could not open `%s' for writing", filename))
io.output(f) io.output(f)
include("module.lp", { doc = doc, module_doc = module_doc }) include("module.lp", { doc = doc, module_doc = module_doc })
@ -251,7 +251,7 @@ function start (doc)
local filename = out_file(file_doc.name) local filename = out_file(file_doc.name)
logger:info(string.format("generating file `%s'", filename)) 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)) assert(f, string.format("could not open `%s' for writing", filename))
io.output(f) io.output(f)
include("file.lp", { doc = doc, file_doc = file_doc} ) include("file.lp", { doc = doc, file_doc = file_doc} )
@ -260,7 +260,7 @@ function start (doc)
end end
-- copy extra files -- 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) io.output(f)
include("luadoc.css") include("luadoc.css")
f:close() f:close()

View file

@ -4,7 +4,7 @@
local assert, pairs, tostring, type = assert, pairs, tostring, type local assert, pairs, tostring, type = assert, pairs, tostring, type
local io = require "io" local io = require "io"
local lfs = require "lfs" local posix = require "posix"
local luadoc = require "luadoc" local luadoc = require "luadoc"
local util = require "luadoc.util" local util = require "luadoc.util"
local tags = require "luadoc.taglet.standard.tags" local tags = require "luadoc.taglet.standard.tags"
@ -433,14 +433,14 @@ end
-- @return table with documentation -- @return table with documentation
function directory (path, doc) function directory (path, doc)
for f in lfs.dir(path) do for f in posix.files(path) do
local fullpath = path .. "/" .. f local fullpath = path .. "/" .. f
local attr = lfs.attributes(fullpath) local attr = posix.stat(fullpath)
assert(attr, string.format("error stating file `%s'", fullpath)) assert(attr, string.format("error stating file `%s'", fullpath))
if attr.mode == "file" then if attr.type == "regular" then
doc = file(fullpath, doc) 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) doc = directory(fullpath, doc)
end end
end end
@ -475,12 +475,12 @@ function start (files, doc)
assert(doc.modules, "undefined `modules' field") assert(doc.modules, "undefined `modules' field")
table.foreachi(files, function (_, path) table.foreachi(files, function (_, path)
local attr = lfs.attributes(path) local attr = posix.stat(path)
assert(attr, string.format("error stating path `%s'", path)) assert(attr, string.format("error stating path `%s'", path))
if attr.mode == "file" then if attr.type == "regular" then
doc = file(path, doc) doc = file(path, doc)
elseif attr.mode == "directory" then elseif attr.type == "directory" then
doc = directory(path, doc) doc = directory(path, doc)
end end
end) end)

View file

@ -3,7 +3,7 @@
-- @release $Id: util.lua,v 1.16 2008/02/17 06:42:51 jasonsantos Exp $ -- @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 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 -- @param mode mode of opening
-- @return file handle -- @return file handle
function lfs.open (filename, mode) function posix.open (filename, mode)
local f = io.open(filename, mode) local f = io.open(filename, mode)
if f == nil then if f == nil then
filename = string.gsub(filename, "\\", "/") filename = string.gsub(filename, "\\", "/")
local dir = "" local dir = ""
for d in string.gfind(filename, ".-/") do for d in string.gfind(filename, ".-/") do
dir = dir .. d dir = dir .. d
lfs.mkdir(dir) posix.mkdir(dir)
end end
f = io.open(filename, mode) f = io.open(filename, mode)
end end