Ported luadoc to use luaposix instead of lfs
authorSteven Barth <steven@midlink.org>
Wed, 23 Jul 2008 14:04:26 +0000 (14:04 +0000)
committerSteven Barth <steven@midlink.org>
Wed, 23 Jul 2008 14:04:26 +0000 (14:04 +0000)
contrib/luadoc/lua/luadoc/doclet/formatter.lua
contrib/luadoc/lua/luadoc/doclet/html.lua
contrib/luadoc/lua/luadoc/taglet/standard.lua
contrib/luadoc/lua/luadoc/util.lua

index af070d5..2d72538 100644 (file)
@@ -41,7 +41,7 @@ function start (doc)
                luadoc.logger:info(string.format("generating file `%s'", filename))
 
                -- TODO: confirm file overwrite
                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
                assert(f, string.format("could not open `%s' for writing", filename))
 
                for _, block in ipairs(file_doc.doc) do
index b736a9d..9a38c87 100644 (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 io = require"io"
 
 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
 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))
        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 })
                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 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 })
                        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 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} )
                        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
        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()
        io.output(f)
        include("luadoc.css")
        f:close()
index 144755e..334f4a2 100644 (file)
@@ -4,7 +4,7 @@
 
 local assert, pairs, tostring, type = assert, pairs, tostring, type
 local io = require "io"
 
 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"
 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)
 -- @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 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)
                end
        end
                        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)
        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))
                
                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)
                end
        end)
                        doc = directory(path, doc)
                end
        end)
index e51e2e5..3a48e74 100644 (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
 -- @return file handle
 
 -- @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
        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
                end
                f = io.open(filename, mode)
        end