summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-10-20 14:17:10 +0200
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-10-20 14:17:10 +0200
commitdbf48bf9f572908d39ca30c0f3975926ab1efeb8 (patch)
treef2c575da45af62d8bdcb7ba403f8f0f57b61155f
parent8a0cf1418c62dc17bc9907bcdddfddde277ac044 (diff)
docs: prepare for markdown gendoc backend
-rw-r--r--src/scripts/elua/apps/docgen/writer.lua47
-rw-r--r--src/scripts/elua/apps/gendoc.lua3
2 files changed, 30 insertions, 20 deletions
diff --git a/src/scripts/elua/apps/docgen/writer.lua b/src/scripts/elua/apps/docgen/writer.lua
index 17238eea35..6dc47c1e39 100644
--- a/src/scripts/elua/apps/docgen/writer.lua
+++ b/src/scripts/elua/apps/docgen/writer.lua
@@ -42,7 +42,33 @@ local allowed_incflags = {
42 aftereach = "" 42 aftereach = ""
43} 43}
44 44
45M.Writer = util.Object:clone { 45local writers = {}
46
47local Buffer = {
48 __ctor = function(self)
49 self.buf = {}
50 end,
51
52 write_raw = function(self, ...)
53 for i, v in ipairs({ ... }) do
54 self.buf[#self.buf + 1] = v
55 end
56 return self
57 end,
58
59 finish = function(self)
60 self.result = table.concat(self.buf)
61 self.buf = {}
62 return self.result
63 end
64}
65
66M.set_backend = function(bend)
67 M.Writer = assert(writers[bend], "invalid generation backend")
68 M.Buffer = M.Writer:clone(Buffer)
69end
70
71writers["dokuwiki"] = util.Object:clone {
46 INCLUDE_PAGE = 0, 72 INCLUDE_PAGE = 0,
47 INCLUDE_SECTION = 1, 73 INCLUDE_SECTION = 1,
48 INCLUDE_NAMESPACE = 2, 74 INCLUDE_NAMESPACE = 2,
@@ -432,25 +458,6 @@ M.Writer = util.Object:clone {
432 end 458 end
433} 459}
434 460
435M.Buffer = M.Writer:clone {
436 __ctor = function(self)
437 self.buf = {}
438 end,
439
440 write_raw = function(self, ...)
441 for i, v in ipairs({ ... }) do
442 self.buf[#self.buf + 1] = v
443 end
444 return self
445 end,
446
447 finish = function(self)
448 self.result = table.concat(self.buf)
449 self.buf = {}
450 return self.result
451 end
452}
453
454M.init = function(root_ns, ftrs) 461M.init = function(root_ns, ftrs)
455 root_nspace = root_ns 462 root_nspace = root_ns
456 features = ftrs 463 features = ftrs
diff --git a/src/scripts/elua/apps/gendoc.lua b/src/scripts/elua/apps/gendoc.lua
index 3ecf3dd061..a715a8d591 100644
--- a/src/scripts/elua/apps/gendoc.lua
+++ b/src/scripts/elua/apps/gendoc.lua
@@ -1578,6 +1578,8 @@ getopt.parse {
1578 { nil, "disable-notes", false, help = "Disable notes plugin usage." }, 1578 { nil, "disable-notes", false, help = "Disable notes plugin usage." },
1579 { nil, "disable-folded", false, help = "Disable folded plugin usage." }, 1579 { nil, "disable-folded", false, help = "Disable folded plugin usage." },
1580 { nil, "disable-title", false, help = "Disable title plugin usage." }, 1580 { nil, "disable-title", false, help = "Disable title plugin usage." },
1581 { "m", "use-markdown", false,
1582 help = "Generate Markdown instead of DokuWiki syntax." },
1581 { nil, "pass", true, help = "The pass to run (optional) " 1583 { nil, "pass", true, help = "The pass to run (optional) "
1582 .. "(rm, ref, clist, classes, types, vars, stats or class name)." } 1584 .. "(rm, ref, clist, classes, types, vars, stats or class name)." }
1583 }, 1585 },
@@ -1608,6 +1610,7 @@ getopt.parse {
1608 end 1610 end
1609 dr = dutil.path_join(dr, dutil.nspace_to_path(rootns)) 1611 dr = dutil.path_join(dr, dutil.nspace_to_path(rootns))
1610 dutil.init(dr, rootns) 1612 dutil.init(dr, rootns)
1613 writer.set_backend("dokuwiki")
1611 if #args == 0 then 1614 if #args == 0 then
1612 dtree.scan_directory() 1615 dtree.scan_directory()
1613 else 1616 else