From 3d003bc0874ea168c24bac26d3d090579cadf255 Mon Sep 17 00:00:00 2001 From: "Y. Wang" Date: Sun, 14 Aug 2022 17:31:48 +0200 Subject: Auto-generate title information from metadata --- assets/manual/filter_man.lua | 44 ++++++++++++++++++---- .../manual/man/man3advtrains/rwt_add.3advtrains.md | 10 +++-- .../man/man3advtrains/rwt_copy.3advtrains.md | 12 ++++-- .../man/man3advtrains/rwt_last_rpt.3advtrains.md | 11 ++++-- .../manual/man/man3advtrains/rwt_now.3advtrains.md | 8 ++-- .../man/man3advtrains/speed_lessp.3advtrains.md | 15 ++++++-- .../speed_set_restriction.3advtrains.md | 9 +++-- .../man7advtrains/node_definition.7advtrains.md | 8 ++-- assets/manual/man/man7advtrains/rwt.7advtrains.md | 8 ++-- .../man/man7advtrains/signal_aspects.7advtrains.md | 8 ++-- .../manual/man/man7advtrains/speed.7advtrains.md | 8 ++-- 11 files changed, 94 insertions(+), 47 deletions(-) (limited to 'assets') diff --git a/assets/manual/filter_man.lua b/assets/manual/filter_man.lua index e80442b..ab9d009 100644 --- a/assets/manual/filter_man.lua +++ b/assets/manual/filter_man.lua @@ -13,18 +13,48 @@ add_filter { Pandoc = function(elem) local blocks, meta = elem.blocks, elem.meta - local page_title = utils.stringify(meta.title) + local page_names = {} + for k, v in ipairs(meta.titles) do + page_names[k] = utils.stringify(v) + end + local page_firstname = page_names[1] + local page_section = utils.stringify(meta.section) local page_manual = utils.stringify(meta.manual) - local page_name, page_section = page_title:match("^([^%(]+)%(([^%)]+)%)$") + local page_firsttitle = string.format("%s(%s)", page_firstname, page_section) + local page_shortdesc = meta.shortdesc -- add page title - meta.title = pandoc.MetaString(string.format("%s | %s", text.upper(page_title), page_manual)) + meta.title = pandoc.MetaString(string.format("%s | %s", text.upper(page_firsttitle), page_manual)) + local startidx = 1 if is_latex then - local titleid = string.format("man:%s.%s", page_name, page_section) - local titleobj = pandoc.Header(1, pandoc.Code(page_title)) + local titleid = string.format("man:%s.%s", page_firstname, page_section) + local titleobj = pandoc.Header(1, pandoc.Code(page_firsttitle)) titleobj.identifier = titleid blocks:insert(1, titleobj) + for i = 2, #page_names do + blocks:insert(i, pandoc.RawBlock("latex", string.format("\\label{man:%s.%s}", page_names[i], page_section))) + end + startidx = #page_names+1 + end + + -- insert naming information + if is_man then + blocks:insert(1, pandoc.Header(1, "NAME")) + startidx = 2 + end + local format_name = pandoc.Code + if is_man then + format_name = pandoc.Str + end + local nameinfo = pandoc.Plain(format_name(page_firstname)) + for i = 2, #page_names do + nameinfo.content:insert(pandoc.Str(", ")) + nameinfo.content:insert(format_name(page_names[i])) end + nameinfo.content:insert(pandoc.Str(" - ")) + nameinfo.content:extend(page_shortdesc) + blocks:insert(startidx, nameinfo) + startidx = startidx + 1 -- add "See Also" section local seealso = elem.meta.seealso @@ -58,8 +88,8 @@ add_filter { if is_latex then add_filter { Str = function(elem) - if elem.tex == "Advtrains" then - return pandoc.RawInline("latex", "\\advtrains{}") + if elem.text == "Advtrains" then + return pandoc.SmallCaps("advtrains") end end } diff --git a/assets/manual/man/man3advtrains/rwt_add.3advtrains.md b/assets/manual/man/man3advtrains/rwt_add.3advtrains.md index de4cf37..5243b3e 100644 --- a/assets/manual/man/man3advtrains/rwt_add.3advtrains.md +++ b/assets/manual/man/man3advtrains/rwt_add.3advtrains.md @@ -1,11 +1,13 @@ --- -title: 'rwt_add(3advtrains)' +titles: +- rwt_add +- rwt_diff +- rwt_sub +section: 3advtrains manual: 'Advtrains Developer''s Manual' +shortdesc: add or subtract railway time objects --- -# Name -`add`, `diff`, `sub` - Add or subtract railway time objects - # Synopsis * `add(t1, t2)` diff --git a/assets/manual/man/man3advtrains/rwt_copy.3advtrains.md b/assets/manual/man/man3advtrains/rwt_copy.3advtrains.md index 1d2ba28..5a49048 100644 --- a/assets/manual/man/man3advtrains/rwt_copy.3advtrains.md +++ b/assets/manual/man/man3advtrains/rwt_copy.3advtrains.md @@ -1,11 +1,15 @@ --- -title: 'rwt_copy(3advtrains)' +titles: +- rwt_copy +- rwt_new +- rwt_to_table +- rwt_to_secs +- rwt_to_string +section: 3advtrains manual: 'Advtrains Developer''s Manual' +shortdesc: create and copy railway time objects --- -# Name -`copy`, `new`, `to_table`, `to_secs`, `to_string` - Create and copy railway time objects - # Synopsis * `copy(obj)` diff --git a/assets/manual/man/man3advtrains/rwt_last_rpt.3advtrains.md b/assets/manual/man/man3advtrains/rwt_last_rpt.3advtrains.md index db5bad5..b5149e7 100644 --- a/assets/manual/man/man3advtrains/rwt_last_rpt.3advtrains.md +++ b/assets/manual/man/man3advtrains/rwt_last_rpt.3advtrains.md @@ -1,11 +1,14 @@ --- -title: 'rwt_last_rpt(3advtrains)' +titles: +- rwt_last_rpt +- rwt_next_rpt +- rwt_time_from_last_rpt +- rwt_time_to_next_rpt +section: 3advtrains manual: 'Advtrains Developer''s Manual' +shortdesc: calculate time for repeating events --- -# Name -`last_rpt`, `next_rpt`, `time_from_last_rpt`, `time_to_next_rpt` - Calculate time for repeating events - # Synopsis * `last_rpt(time, interval, offset)` diff --git a/assets/manual/man/man3advtrains/rwt_now.3advtrains.md b/assets/manual/man/man3advtrains/rwt_now.3advtrains.md index 0f52258..7eb3650 100644 --- a/assets/manual/man/man3advtrains/rwt_now.3advtrains.md +++ b/assets/manual/man/man3advtrains/rwt_now.3advtrains.md @@ -1,10 +1,10 @@ --- -title: 'rwt_now(3advtrains)' +titles: +- rwt_now +section: 3advtrains manual: 'Advtrains Developer''s Manual' +shortdesc: get the current railway time --- -# Name -`now` - Get the current railway time - # Description `now()` returns the current railway time as a table. diff --git a/assets/manual/man/man3advtrains/speed_lessp.3advtrains.md b/assets/manual/man/man3advtrains/speed_lessp.3advtrains.md index af1319f..61c37b2 100644 --- a/assets/manual/man/man3advtrains/speed_lessp.3advtrains.md +++ b/assets/manual/man/man3advtrains/speed_lessp.3advtrains.md @@ -1,11 +1,18 @@ --- -title: 'speed_lessp(3advtrains)' +titles: +- speed_lessp +- speed_greaterp +- speed_equalp +- speed_not_lessp +- speed_not_greaterp +- speed_not_equalp +- speed_min +- speed_max +section: 3advtrains manual: 'Advtrains Developer''s Manual' +shortdesc: compare speed limits --- -# Name -`lessp`, `greaterp`, `equalp`, `not_lessp`, `not_greaterp`, `not_equalp`, `min`, `max` - Speed limit comparison functions - # Synopsis * `lessp(a, b)` diff --git a/assets/manual/man/man3advtrains/speed_set_restriction.3advtrains.md b/assets/manual/man/man3advtrains/speed_set_restriction.3advtrains.md index 1a3bd80..619cf3f 100644 --- a/assets/manual/man/man3advtrains/speed_set_restriction.3advtrains.md +++ b/assets/manual/man/man3advtrains/speed_set_restriction.3advtrains.md @@ -1,11 +1,12 @@ --- -title: 'speed_set_restriction(3advtrains)' +titles: +- speed_set_restriction +- speed_merge_aspect +section: 3advtrains manual: 'Advtrains Developer''s Manual' +shortdesc: apply speed limits to trains --- -# Name -`set_restriction`, `merge_aspect` - Apply speed limits to trains - # Synopsis * `set_restriction(train, type, val)` diff --git a/assets/manual/man/man7advtrains/node_definition.7advtrains.md b/assets/manual/man/man7advtrains/node_definition.7advtrains.md index 8b6407a..db9db08 100644 --- a/assets/manual/man/man7advtrains/node_definition.7advtrains.md +++ b/assets/manual/man/man7advtrains/node_definition.7advtrains.md @@ -1,13 +1,13 @@ --- -title: 'node_definition(7advtrains)' +titles: +- node_definition +section: 7advtrains manual: 'Advtrains Developer''s Manual' +shortdesc: node definition entries specific to Advtrains seealso: - signal_aspects(7advtrains) --- -# Name -`node_definition` - Advtrains-specific node definition entries - # Description This page describes various fields in node definition tables that are used by Advtrains. diff --git a/assets/manual/man/man7advtrains/rwt.7advtrains.md b/assets/manual/man/man7advtrains/rwt.7advtrains.md index 3c1690a..d1efc80 100644 --- a/assets/manual/man/man7advtrains/rwt.7advtrains.md +++ b/assets/manual/man/man7advtrains/rwt.7advtrains.md @@ -1,6 +1,9 @@ --- -title: 'rwt(7advtrains)' +titles: +- rwt +section: 7advtrains manual: 'Advtrains Developer''s Manual' +shortdesc: Advtrains railway time seealso: - rwt_add(3advtrains) - rwt_copy(3advtrains) @@ -8,9 +11,6 @@ seealso: - rwt_now(3advtrains) --- -# Name -`rwt` - Advtrains railway time - # Description Advtrains depends on Minetest's "dtime" for most operations, and may slow itself down when necessary to prevent unexpected behavior, such as in a situation with a significant amount of lag. As a result, the internal time used by Advtrains is not synchronized to real-life time due to lag and server restarts. Railway time was therefore introduced as a method of accurately measuring internal time and, with this information, implementing a scheduling system. It can, however, also be set up to keep in sync with real-life time. diff --git a/assets/manual/man/man7advtrains/signal_aspects.7advtrains.md b/assets/manual/man/man7advtrains/signal_aspects.7advtrains.md index 110d642..1cb5d7e 100644 --- a/assets/manual/man/man7advtrains/signal_aspects.7advtrains.md +++ b/assets/manual/man/man7advtrains/signal_aspects.7advtrains.md @@ -1,13 +1,13 @@ --- -title: 'signal_aspects(7advtrains)' +titles: +- signal_aspects +section: 7advtrains manual: 'Advtrains Developer''s Manual' +shortdesc: signal aspect tables for Advtrains seealso: - speed(7advtrains) --- -# Name -`signal_aspects` - Signal aspect tables for Advtrains - # Description A signal aspect table describes the status of a signal in relation to a train following it. diff --git a/assets/manual/man/man7advtrains/speed.7advtrains.md b/assets/manual/man/man7advtrains/speed.7advtrains.md index b963686..8b3fe1e 100644 --- a/assets/manual/man/man7advtrains/speed.7advtrains.md +++ b/assets/manual/man/man7advtrains/speed.7advtrains.md @@ -1,15 +1,15 @@ --- -title: 'speed(7advtrains)' +titles: +- speed +section: 7advtrains manual: 'Advtrains Developer''s Manual' +shortdesc: Advtrains speed limit library seealso: - speed_lessp(3advtrains) - speed_set_restriction(3advtrains) - signal_aspects(7advtrains) --- -# Name -`speed` - Advtrains speed limit library - # Description The speed library allows the manipulation of speed limits, which can be represented with -- cgit v1.2.3