ferron

Ferron is a fast and simple static website generator made with Lua.
Log | Files | Refs | Submodules | README | LICENSE

commit a9936f385f71490333987e5b1f348c8c6636a1d5
parent 5ff190d2c260abab09a8bc225cf525fe0314dd9d
Author: Hugo Soucy <hs0ucy@h50ucy.local>
Date:   Fri,  5 Jul 2019 06:55:27 -0400

Start the luadoc fileutils documentation

Diffstat:
Mferron/utilities/file-utils.lua | 16++++++++++++++++
1 file changed, 16 insertions(+), 0 deletions(-)

diff --git a/ferron/utilities/file-utils.lua b/ferron/utilities/file-utils.lua @@ -12,10 +12,18 @@ local mimetypes = require 'mimetypes' local config = require 'ferron.config' local tb = require 'ferron.utilities.table-utils' +--- Returns non-directory portion of a pathname +-- @name getbasename +-- @param filepath a pathname to a file +-- @return a string that represents the filename portion of pathname function fileutils.getbasename(filepath) return string.gsub(filepath, '(.*/)(.*)', '%2') end +--- Check if the pathname target is a file +-- @name isFile +-- @param filepath a pathname to a file +-- @return if true the filepath param, else false function fileutils.isFile(filepath) if lfs.attributes(filepath) and lfs.attributes(filepath).mode == 'file' @@ -26,6 +34,10 @@ function fileutils.isFile(filepath) return false end +--- Check if the pathname target is a directory +-- @name isDirectory +-- @param filepath a pathname to a directory +-- @return if true the filepath param, else false function fileutils.isDirectory(filepath) if lfs.attributes(filepath) and lfs.attributes(filepath).mode == 'directory' @@ -47,6 +59,10 @@ function fileutils.isNotDotDirectory(dirname) return false end +--- Check if the pathname target is a markdown file +-- @name isMarkdown +-- @param filepath a pathname to a file +-- @return if true the filepath param, else false function fileutils.isMarkdown(filepath) if fileutils.isFile(filepath) and (mimetypes.guess(filepath) == 'text/x-markdown'