Add "SEE ALSO" section to manual pages where applicable
This commit is contained in:
parent
80f2f33bfb
commit
48b9922071
9
Makefile
9
Makefile
|
@ -9,6 +9,7 @@ MAN_PATH = $(MANUAL_ROOT)/man
|
|||
MAN_SRCS = $(wildcard $(MAN_PATH)/*/*.md)
|
||||
MAN_DSTS = $(MAN_SRCS:%.md=%)
|
||||
MAN_TEXS = $(MAN_SRCS:%.md=%.tex)
|
||||
MAN_FILTER = $(MANUAL_ROOT)/filter_man.lua
|
||||
|
||||
TEX_PATH = $(MANUAL_ROOT)/tex
|
||||
MAN_TEX = $(TEX_PATH)/man.tex
|
||||
|
@ -26,11 +27,11 @@ doc-pdf: $(TEX_MAIN_DSTS)
|
|||
doc-man: $(MAN_DSTS)
|
||||
find assets/manual/man -regex '.*/[^.]+\.[^.]+$$' | tar -cJf ${MANUAL_ROOT}/man.tar.xz -T -
|
||||
|
||||
%:: %.md
|
||||
$(PANDOC) -s -t man -o $@ $<
|
||||
%:: %.md ${MAN_FILTER}
|
||||
$(PANDOC) -L ${MAN_FILTER} -s -t man -o $@ $<
|
||||
|
||||
$(MAN_TEX): $(MAN_TEXS)
|
||||
find $(MAN_PATH) -name '*.tex' -printf '\\input{../man/%P}\n' | sort > $(MAN_TEX)
|
||||
|
||||
%.tex:: %.md ${MANUAL_ROOT}/filter_man_md2tex.lua
|
||||
$(PANDOC) -L ${MANUAL_ROOT}/filter_man_md2tex.lua -t latex -o $@ $<
|
||||
%.tex:: %.md ${MAN_FILTER}
|
||||
$(PANDOC) -L ${MAN_FILTER} -t latex -o $@ $<
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
local filters = {}
|
||||
|
||||
local function add_filter(x)
|
||||
table.insert(filters, x)
|
||||
end
|
||||
|
||||
local is_latex = FORMAT:match "latex"
|
||||
local is_man = FORMAT:match "man"
|
||||
|
||||
add_filter {
|
||||
Pandoc = function(elem)
|
||||
local seealso = elem.meta.seealso
|
||||
if not seealso then
|
||||
return
|
||||
end
|
||||
local blocks = elem.blocks
|
||||
blocks:insert(pandoc.Header(1, pandoc.Str("SEE ALSO")))
|
||||
if is_man then
|
||||
for k, v in pairs(seealso) do
|
||||
seealso[k] = v[1].text
|
||||
end
|
||||
blocks:insert(pandoc.Str(table.concat(seealso, ", ")))
|
||||
else
|
||||
local list = {}
|
||||
for _, i in ipairs(seealso) do
|
||||
local page = i[1].text
|
||||
local pgname, pgsection = string.match(page, "^([^%)]+)%(([^%)]+)%)$")
|
||||
local item = pandoc.Str(page)
|
||||
if is_latex and pgname and pgsection then
|
||||
pgname = pgname:gsub("_","\\string_")
|
||||
item = pandoc.RawInline("latex", string.format("\\manref{%s}{%s}", pgname, pgsection))
|
||||
end
|
||||
table.insert(list, item)
|
||||
end
|
||||
blocks:insert(pandoc.BulletList(list))
|
||||
end
|
||||
return elem
|
||||
end
|
||||
}
|
||||
|
||||
if is_latex then
|
||||
add_filter {
|
||||
Str = function(elem)
|
||||
if elem.tex == "Advtrains" then
|
||||
return pandoc.RawInline("latex", "\\advtrains{}")
|
||||
end
|
||||
end
|
||||
}
|
||||
add_filter {
|
||||
Header = function(elem)
|
||||
local attr = {
|
||||
class = "unnumbered unlisted",
|
||||
}
|
||||
return pandoc.Header(elem.level+1, elem.content, attr)
|
||||
end,
|
||||
}
|
||||
add_filter {
|
||||
Pandoc = function(elem)
|
||||
local outputfn = PANDOC_STATE.output_file or error("No output file specified")
|
||||
local pgname, pgsection = outputfn:match("([^%./\\]+)%.([^%.]+)%.tex$")
|
||||
assert(pgname and pgsection, "Cannot fetch manpage name and section")
|
||||
local blocks = elem.blocks
|
||||
local titlestr = string.format("%s(%s)", pgname, pgsection)
|
||||
local titleid = string.format("man:%s.%s", pgname, pgsection)
|
||||
local titleobj = pandoc.Header(1, pandoc.Code(titlestr))
|
||||
titleobj.identifier = titleid
|
||||
blocks:insert(1, titleobj)
|
||||
return elem
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
return filters
|
|
@ -1,31 +0,0 @@
|
|||
return {
|
||||
{
|
||||
Str = function(elem)
|
||||
if elem.text == "Advtrains" then
|
||||
return pandoc.RawInline("latex", "\\advtrains{}")
|
||||
end
|
||||
end
|
||||
},
|
||||
{
|
||||
Header = function(elem)
|
||||
local attr = {
|
||||
class = "unnumbered unlisted",
|
||||
}
|
||||
return pandoc.Header(elem.level+1, elem.content, attr)
|
||||
end,
|
||||
},
|
||||
{
|
||||
Pandoc = function(elem)
|
||||
local outputfn = PANDOC_STATE.output_file or error("No output file specified")
|
||||
local pgname, pgsection = outputfn:match("([^%./\\]+)%.([^%.]+)%.tex$")
|
||||
assert(pgname and pgsection, "Cannot fetch manpage name and section")
|
||||
local blocks = elem.blocks
|
||||
local titlestr = string.format("%s(%s)", pgname, pgsection)
|
||||
local titleid = string.format("man:%s.%s", pgname, pgsection)
|
||||
local titleobj = pandoc.Header(1, pandoc.Code(titlestr))
|
||||
titleobj.identifier = titleid
|
||||
blocks:insert(1, titleobj)
|
||||
return elem
|
||||
end,
|
||||
},
|
||||
}
|
|
@ -1,4 +1,11 @@
|
|||
% RWT(7ADVTRAINS) | Advtrains Developer's Manual
|
||||
---
|
||||
title: 'RWT(7ADVTRAINS) | Advtrains Developer''s Manual'
|
||||
seealso:
|
||||
- rwt_add(3advtrains)
|
||||
- rwt_copy(3advtrains)
|
||||
- rwt_last_rpt(3advtrains)
|
||||
- rwt_now(3advtrains)
|
||||
---
|
||||
|
||||
# NAME
|
||||
`rwt` - Advtrains railway time
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
% SPEED(7ADVTRAINS) | Advtrains Developer's Manual
|
||||
---
|
||||
title: 'SPEED(7ADVTRAINS) | Advtrains Developer''s Manual'
|
||||
seealso:
|
||||
- speed_lessp(3advtrains)
|
||||
- speed_set_restriction(3advtrains)
|
||||
---
|
||||
|
||||
# NAME
|
||||
`speed` - Advtrains speed limit library
|
||||
|
|
Loading…
Reference in New Issue