summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/lua-filters.md103
-rw-r--r--tools/update-lua-docs.lua35
2 files changed, 128 insertions, 10 deletions
diff --git a/doc/lua-filters.md b/doc/lua-filters.md
index 112a9bab2..8cdb96194 100644
--- a/doc/lua-filters.md
+++ b/doc/lua-filters.md
@@ -1479,3 +1479,106 @@ storage. The "media bag" is used when pandoc is called with the
local diagram_url = "https://pandoc.org/diagram.jpg"
local contents = pandoc.mediabag.fetch(diagram_url, ".")
+
+# Module pandoc.List
+
+Pandoc\'s List type and helper methods
+
+## Metamethods
+
+[`pandoc.List:__concat (list)`]{#pandoc.List:__concat}
+
+: Concatenates two lists.
+
+ Parameters:
+
+ `list`:
+ : second list concatenated to the first
+
+ Returns: a new list containing all elements from list1 and
+ list2
+
+## Methods
+
+[`pandoc.List:clone ()`]{#pandoc.List:clone}
+
+: Returns a (shallow) copy of the list.
+
+[`pandoc.List:includes (needle, init)`]{#pandoc.List:includes}
+
+: Checks if the list has an item equal to the given needle.
+
+ Parameters:
+
+ `needle`:
+ : item to search for
+
+ `init`:
+ : index at which the search is started
+
+ Returns: true if a list item is equal to the needle, false
+ otherwise
+
+[`pandoc.List:find (needle, init)`]{#pandoc.List:find}
+
+: Returns the value and index of the first occurrence of the
+ given item.
+
+ Parameters:
+
+ `needle`:
+ : item to search for
+
+ `init`:
+ : index at which the search is started
+
+ Returns: first item equal to the needle, or nil if no such
+ item exists.
+
+[`pandoc.List:find_if (pred, init)`]{#pandoc.List:find_if}
+
+: Returns the value and index of the first element for which
+ the predicate holds true.
+
+ Parameters:
+
+ `pred`:
+ : the predicate function
+
+ `init`:
+ : index at which the search is started
+
+ Returns: first item for which \`test\` succeeds, or nil if
+ no such item exists.
+
+[`pandoc.List:extend (list)`]{#pandoc.List:extend}
+
+: Adds the given list to the end of this list.
+
+ Parameters:
+
+ `list`:
+ : list to appended
+
+[`pandoc.List:map (fn)`]{#pandoc.List:map}
+
+: Returns a copy of the current list by applying the given
+ function to all elements.
+
+ Parameters:
+
+ `fn`:
+ : function which is applied to all list items.
+
+[`pandoc.List:filter (pred)`]{#pandoc.List:filter}
+
+: Returns a new list containing all items satisfying a given
+ condition.
+
+ Parameters:
+
+ `pred`:
+ : condition items must satisfy.
+
+ Returns: a new list containing all items for which \`test\`
+ was true.
diff --git a/tools/update-lua-docs.lua b/tools/update-lua-docs.lua
index 223ba3722..daa685269 100644
--- a/tools/update-lua-docs.lua
+++ b/tools/update-lua-docs.lua
@@ -1,14 +1,26 @@
local in_module_section = false
-function pandoc_module_blocks()
- local tmp_folder = os.tmpname()
- os.remove(tmp_folder)
- os.execute("mkdir -p " .. tmp_folder)
- os.execute("ldoc -q -l tools -d " .. tmp_folder .. " data/pandoc.lua")
- local module_file = io.open(tmp_folder .. "/index.html")
- local module_html = module_file:read("*a")
- local module_doc = pandoc.read(module_html, "html")
- return module_doc.blocks
+-- Generate tmp folder
+local tmp_folder = os.tmpname()
+os.remove(tmp_folder)
+os.execute("mkdir -p " .. tmp_folder)
+
+function extend(list1, list2)
+ for i = 1, #list2 do
+ list1[#list1 + 1] = list2[i]
+ end
+end
+
+function module_blocks(module_filenames)
+ local blocks = {}
+ for _, filename in pairs(module_filenames) do
+ os.execute("ldoc -q -l tools -d " .. tmp_folder .. " " .. filename)
+ local module_file = io.open(tmp_folder .. "/index.html")
+ local module_html = module_file:read("*a")
+ local module_doc = pandoc.read(module_html, "html")
+ extend(blocks, module_doc.blocks)
+ end
+ return blocks
end
function Header (el)
@@ -21,7 +33,10 @@ function Header (el)
end
elseif el.identifier == "module-pandoc" then
in_module_section = true
- return pandoc_module_blocks()
+ return module_blocks{'data/pandoc.lua'}
+ elseif el.identifier == "module-pandoc.list" then
+ in_module_section = true
+ return module_blocks{'data/List.lua'}
end
end