From 42ec7286b2d36a9ba22925f816a17cb1cc2aa5ce Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 30 Oct 2021 11:32:16 +0800 Subject: + Penlight --- .../Penlight/docs/examples/seesubst.lua.html | 174 +++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 Data/Libraries/Penlight/docs/examples/seesubst.lua.html (limited to 'Data/Libraries/Penlight/docs/examples/seesubst.lua.html') diff --git a/Data/Libraries/Penlight/docs/examples/seesubst.lua.html b/Data/Libraries/Penlight/docs/examples/seesubst.lua.html new file mode 100644 index 0000000..e850122 --- /dev/null +++ b/Data/Libraries/Penlight/docs/examples/seesubst.lua.html @@ -0,0 +1,174 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

seesubst.lua

+
+-- shows how replacing '@see module' in the Markdown documentation
+-- can be done more elegantly using PL.
+-- We either have something like 'pl.config' (a module reference)
+-- or 'pl.seq.map' (a function reference); these cases must be distinguished
+-- and a Markdown link generated pointing to the LuaDoc file.
+
+local sip = require 'pl.sip'
+local stringx = require 'pl.stringx'
+
+local res = {}
+local s = [[
+(@see pl.bonzo.dog)
+remember about @see pl.bonzo
+
+]]
+
+local _gsub_patterns = {}
+
+local function gsub (s,pat,subst,start)
+    local fpat = _gsub_patterns[pat]
+    if not fpat then
+        -- use SIP to generate a proper string pattern.
+        -- the _whole thing_ is a capture, to get the whole match
+        -- and the unnamed capture.
+        fpat = '('..sip.create_pattern(pat)..')'
+        _gsub_patterns[pat] = fpat
+    end
+    return s:gsub(fpat,subst,start)
+end
+
+
+local mod = sip.compile '$v.$v'
+local fun = sip.compile '$v.$v.$v'
+
+for line in stringx.lines(s) do
+    line = gsub(line,'@see $p',function(see,path)
+        if fun(path,res) or mod(path,res) then
+            local ret = ('[see %s](%s.%s.html'):format(path,res[1],res[2])
+            if res[3] then
+                return ret..'#'..res[3]..')'
+            else
+                return ret..')'
+            end
+        end
+    end)
+    print(line)
+end
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + -- cgit v1.1-26-g67d0