[latex3-commits] [git/l3build] manifest: manifest: ctan and tds files (eca5bd7)

Will Robertson wspr81 at gmail.com
Tue Dec 26 15:58:05 CET 2017


Repository : https://github.com/latex3/l3build
On branch  : manifest
Link       : https://github.com/latex3/l3build/commit/eca5bd787dbe07570dc2768b130d8fc7a9b96dae

>---------------------------------------------------------------

commit eca5bd787dbe07570dc2768b130d8fc7a9b96dae
Author: Will Robertson <wspr81 at gmail.com>
Date:   Tue Dec 26 22:58:05 2017 +0800

    manifest: ctan and tds files
    
    also add possibility for subheadings in the manifest


>---------------------------------------------------------------

eca5bd787dbe07570dc2768b130d8fc7a9b96dae
 l3build-manifest-setup.lua |   98 +++++++++++++++++++++++++++++++++++++++-----
 l3build-manifest.lua       |   94 +++++++++++++++++++++++++++++++-----------
 l3build.dtx                |   25 ++++++++++-
 3 files changed, 179 insertions(+), 38 deletions(-)

diff --git a/l3build-manifest-setup.lua b/l3build-manifest-setup.lua
index 72b2dce..229f47a 100644
--- a/l3build-manifest-setup.lua
+++ b/l3build-manifest-setup.lua
@@ -41,6 +41,56 @@ for those people who are interested.
 manifest_setup = manifest_setup or function()
   local groups = {
     {
+       subheading = "CTAN manifest",
+       description = [[
+The following group lists the files included in the CTAN package.
+       ]],
+    },
+    {
+       name    = "CTAN files",
+       dir     = ctandir.."/"..module,
+       files   = {"*.*"},
+       exclude = {".",".."},
+       flag    = false,
+       skipfiledescription = true,
+    },
+    {
+       subheading = "TDS manifest",
+       description = [[
+The following groups list the files included in the TeX Directory Structure used to install
+the package into a TeX distribution.
+       ]],
+    },
+    {
+       name    = "Source files (TDS)",
+       dir     = tdsdir.."/source/"..moduledir,
+       files   = {"*.*"},
+       exclude = {".",".."},
+       flag    = false,
+    },
+    {
+       name    = "TeX files (TDS)",
+       dir     = tdsdir.."/tex/"..moduledir,
+       files   = {"*.*"},
+       exclude = {".",".."},
+       flag    = false,
+       skipfiledescription = true,
+    },
+    {
+       name    = "Doc files (TDS)",
+       dir     = tdsdir.."/doc/"..moduledir,
+       files   = {"*.*"},
+       exclude = {".",".."},
+       flag    = false,
+       skipfiledescription = true,
+    },
+    {
+       subheading = "Repository manifest",
+       description = [[
+The following groups list the files included in the development repository of the package.
+       ]],
+    },
+    {
        name    = "Source files",
        description = [[
 These are source files for a number of purposes, including the `unpack` process which
@@ -88,6 +138,7 @@ additional input files for the typeset documentation files listed above.
        name    = "Typeset documents",
        files   = {typesetfiles,typesetsourcefiles,typesetdemofiles},
        rename  = {"%.%w+$", ".pdf"},
+       skipfiledescription = true,
     },
     {
        name    = "Support files needed for unpacking, typesetting, or checking",
@@ -148,13 +199,23 @@ manifest_write_opening = manifest_write_opening or function(filehandle)
 
 end
 
+manifest_write_subheading = manifest_write_subheading or function(filehandle,heading,description)
+
+  filehandle:write("\n\n## " .. heading .. "\n\n")
+
+  if description then
+    filehandle:write(description .. "\n")
+  end
+
+end
+
 manifest_write_group_heading = manifest_write_group_heading or function (filehandle,heading,description)
 
-   filehandle:write("\n## " .. heading .. "\n\n")
+  filehandle:write("\n### " .. heading .. "\n\n")
 
-   if description then
-     filehandle:write(description .. "\n")
-   end
+  if description then
+    filehandle:write(description .. "\n")
+  end
 
 end
 
@@ -166,10 +227,15 @@ manifest_write_group_file = manifest_write_group_file or function(filehandle,fil
         param.dir         : the directory of the file
         param.count       : the name of the file to write
         param.filemaxchar : the maximum number of chars of all filenames in this group
+        param.flag        : false OR string for indicating CTAN/TDS location
+        param.ctanfile    : (boolean) if file is in CTAN dir
+        param.tdsfile     : (boolean) if file is in TDS dir
   --]]
 
   -- no file description: plain bullet list item:
-  filehandle:write("* " .. filename .. "\n")
+
+  flagstr = param.flag or  ""
+  filehandle:write("* " .. filename .. " " .. flagstr .. "\n")
 
   --[[
     -- or if you prefer an enumerated list:
@@ -189,22 +255,30 @@ manifest_write_group_file_descr = manifest_write_group_file_descr or function(fi
         param.count       : the count of the filename to be written
         param.filemaxchar : the maximum number of chars of all filenames in this group
         param.descmaxchar : the maximum number of chars of all descriptions in this group
+        param.flag        : false OR string for indicating CTAN/TDS location
+        param.ctanfile    : (boolean) if file is in CTAN dir
+        param.tdsfile     : (boolean) if file is in TDS dir
   --]]
 
   -- filename+description: Github-flavoured Markdown table
 
   -- header of table
   if param.count == 1 then
-    local p = param
+    local p = {}
+    for k,v in pairs(param) do p[k] = v end
     p.count = -1
+    p.flag = p.flag and "Flag"
     manifest_write_group_file_descr(filehandle,"File","Description",p)
+    p.flag = p.flag and "--- "
     manifest_write_group_file_descr(filehandle,"---","---",p)
   end
 
-  -- entry
-  filehandle:write(string.format(
-    "  | %-"..param.filemaxchar.."s | %-"..param.descmaxchar.."s |\n",
-    filename,descr))
+  -- entry of table
+  filestr = string.format(" | %-"..param.filemaxchar.."s",filename)
+  flagstr = param.flag and string.format(" | %s",param.flag) or  ""
+  descstr = string.format(" | %-"..param.descmaxchar.."s",descr)
+
+  filehandle:write(filestr..flagstr..descstr.." |\n")
 
 end
 
@@ -214,7 +288,9 @@ end
 --]]
 
 manifest_extract_filedesc = manifest_extract_filedesc or function(filehandle)
--- no-op by default; two examples below
+
+  -- no-op by default; two examples below
+
 end
 
 --[[
diff --git a/l3build-manifest.lua b/l3build-manifest.lua
index f3047ac..cad4bb3 100644
--- a/l3build-manifest.lua
+++ b/l3build-manifest.lua
@@ -35,6 +35,18 @@ for those people who are interested.
 
 manifest = manifest or function()
 
+  -- build list of ctan files
+  ctanfiles = {}
+  for _,f in ipairs(filelist(ctandir.."/"..ctanpkg,"*.*")) do
+    ctanfiles[f] = true
+  end
+  tdsfiles = {}
+  for _,subdir in ipairs({"/doc/","/source/","/tex/"}) do
+    for _,f in ipairs(filelist(tdsdir..subdir..moduledir,"*.*")) do
+      tdsfiles[f] = true
+    end
+  end
+
   local manifest_entries = manifest_setup()
 
   for ii,_ in ipairs(manifest_entries) do
@@ -55,32 +67,36 @@ end
 
 manifest_build_list = function(entry)
 
-  entry = manifest_build_init(entry)
+  if not(entry.subheading) then
 
-  -- build list of excluded files
-  for _,glob_list in ipairs(entry.exclude) do
-    for _,this_glob in ipairs(glob_list) do
-      for _,this_file in ipairs(filelist(maindir,this_glob)) do
-        entry.excludes[this_file] = true
+    entry = manifest_build_init(entry)
+  
+    -- build list of excluded files
+    for _,glob_list in ipairs(entry.exclude) do
+      for _,this_glob in ipairs(glob_list) do
+        for _,this_file in ipairs(filelist(maindir,this_glob)) do
+          entry.excludes[this_file] = true
+        end
       end
     end
-  end
     
-  -- build list of matched files
-  for _,glob_list in ipairs(entry.files) do
-    for _,this_glob in ipairs(glob_list) do
+    -- build list of matched files
+    for _,glob_list in ipairs(entry.files) do
+      for _,this_glob in ipairs(glob_list) do
   
-      local these_files = filelist(entry.dir,this_glob)
-      these_files = manifest_sort_within_match(these_files)
+        local these_files = filelist(entry.dir,this_glob)
+        these_files = manifest_sort_within_match(these_files)
   
-      for _,this_file in ipairs(these_files) do
-        entry = manifest_build_file(entry,this_file)
-      end
+        for _,this_file in ipairs(these_files) do
+          entry = manifest_build_file(entry,this_file)
+        end
   
-      entry.files_ordered = manifest_sort_within_group(entry.files_ordered)
+        entry.files_ordered = manifest_sort_within_group(entry.files_ordered)
   
+      end
     end
-  end
+    
+	end
 	
   return entry
 
@@ -89,12 +105,13 @@ end
 
 manifest_build_init = function(entry)
 
-  -- currently these aren't customisable; I guess they could/should be?
+  -- currently these aren't customisable; I guess they could be?
   local manifest_group_defaults = {
     skipfiledescription  = false          ,
     rename               = false          ,
     dir                  = maindir        ,
     exclude              = {excludefiles} ,
+    flag                 = true           ,
   }
 
   -- internal data added to each group in the table that needs to be initialised
@@ -111,7 +128,10 @@ manifest_build_init = function(entry)
 
    -- copy default options to each group if necessary
   for kk,ll in pairs(manifest_group_defaults) do
-    entry[kk] = entry[kk] or ll
+    if entry[kk] == nil then
+      entry[kk] = ll
+    end
+    -- can't use "entry[kk] = entry[kk] or ll" because false/nil are indistinguishable!
   end
 
   -- initialisation for internal data
@@ -135,7 +155,7 @@ end
 manifest_build_file = function(entry,this_file)
 
   if entry.rename then
-    this_file:gsub(entry.rename[1], entry.rename[2])
+    this_file = this_file:gsub(entry.rename[1],entry.rename[2])
   end
 
   if not entry.excludes[this_file] then
@@ -149,7 +169,7 @@ manifest_build_file = function(entry,this_file)
       
     end
 
-    if not(entry.rename) and not(entry.skipfiledescription) then
+    if not(entry.skipfiledescription) then
     
       local ff = assert(io.open(entry.dir .. "/" .. this_file, "r"))
       this_descr  = manifest_extract_filedesc(ff,this_file)
@@ -179,7 +199,9 @@ manifest_write = function(manifest_entries)
   manifest_write_opening(f)
 
   for ii,vv in ipairs(manifest_entries) do
-    if manifest_entries[ii].N > 0 then
+    if manifest_entries[ii].subheading then
+      manifest_write_subheading(f,manifest_entries[ii].subheading,manifest_entries[ii].description)
+    elseif manifest_entries[ii].N > 0 then
       manifest_write_group(f,manifest_entries[ii])
     end
   end
@@ -202,7 +224,19 @@ manifest_write_group = function(f,entry)
         count       = ii                ,
         filemaxchar = entry.Nchar_file  ,
         descmaxchar = entry.Nchar_descr ,
+        ctanfile    = ctanfiles[file]   ,
+        tdsfile     = tdsfiles[file]    ,
+        flag        = false             ,
       }
+      
+      if entry.flag then
+        param.flag = "    "
+	  		if tdsfiles[file] and not(ctanfiles[file]) then
+	  			param.flag = "†   "
+	  		elseif ctanfiles[file] then
+	  			param.flag = "‡   "
+	  		end
+			end
       manifest_write_group_file_descr(f,file,descr,param)
     end
 
@@ -210,10 +244,20 @@ manifest_write_group = function(f,entry)
 
     for ii,file in ipairs(entry.files_ordered) do
       local param = { 
-        dir         = entry.dir        ,
-      	count       = ii               , 
-      	filemaxchar = entry.Nchar_file ,
+        dir         = entry.dir         ,
+      	count       = ii                , 
+      	filemaxchar = entry.Nchar_file  ,
+        ctanfile    = ctanfiles[file]   ,
+        tdsfile     = tdsfiles[file]    ,
       }
+      if entry.flag then
+        param.flag = ""
+	  		if tdsfiles[file] and not(ctanfiles[file]) then
+	  			param.flag = "†"
+	  		elseif ctanfiles[file] then
+	  			param.flag = "‡"
+	  		end
+			end
       manifest_write_group_file(f,file,param)
     end
 
diff --git a/l3build.dtx b/l3build.dtx
index 746a4f9..505af08 100644
--- a/l3build.dtx
+++ b/l3build.dtx
@@ -1427,6 +1427,12 @@
 % manifest_setup = function()
 %   local groups = {
 %     {
+%        subheading = "Repository files",
+%        description = [[
+% Files located in the package development repository.
+%        ]],
+%     },
+%     {
 %        name    = "Source files",
 %        description = [[
 % These are source files generating the package files.
@@ -1448,11 +1454,11 @@
 %
 % The |groups| variable is an ordered array of tables which contain the metadata about each
 % `group' in the manifest listing.
-% The keys supported in these tables are outlined in Table~\ref{tab:manifest-setup}.
+% The keys supported in these tables are outlined in Table~\ref{tab:manifest-setup} and Table~\ref{tab:manifest-subheadings}
 % See the complete setup code in |l3build-manifest-setup.lua| for examples of these in use.
 %
 % \begin{table}
-%   \caption{Table entries used in the manifest setup table.}
+%   \caption{Table entries used in the manifest setup table for a group.}
 %   \label{tab:manifest-setup}
 %   \centering
 %   \begin{tabular}{lp{8cm}}
@@ -1470,6 +1476,20 @@
 %     \end{tabular}
 % \end{table}
 %
+% \begin{table}
+%   \caption{Table entries used in the manifest setup table for a subheading.}
+%   \label{tab:manifest-subheadings}
+%   \centering
+%   \begin{tabular}{lp{8cm}}
+%     \toprule
+%     Entry & Description \\
+%     \midrule
+%       \var{subheading}         & The subheading                                       \\
+%       \var{description}        & The description printed below the subheading         \\
+%     \bottomrule
+%     \end{tabular}
+% \end{table}
+%
 %
 % \subsubsection{Sorting within each manifest group}
 % \label{sec:manifest-sorting}
@@ -1538,6 +1558,7 @@
 % The following functions can be re-defined to change the formatting of the manifest file:
 % \begin{itemize}
 % \item |manifest_write_opening|: Write the heading of the manifest file and its opening paragraph.
+% \item |manifest_write_subheading|: Write a subheading and description
 % \item |manifest_write_group_heading|: Write the section heading of the manifest group and the group description
 % \item |manifest_write_group_file|: Write the filename (when not writing file descriptions)
 % \item |manifest_write_group_file_descr|: Write the filename and the file description





More information about the latex3-commits mailing list